Hello all,
Please, I am in dire need of urgent help as I have spent quite large amount of time trying to make this model to work but all my effort is futile.
I honestly cannot figure out what am not doing correctly or even how to fix it.
My code just keep giving an infeasible solution.
Pls,can experts in the house check my code for me. Attached are my code and input data. The model in equation form which I am trying to reproduce can be found on pages 716 of the attached paper.
Thanks guys for your help.
Muna
Infeasible,no solution exist MIP using CPLEX
Infeasible,no solution exist MIP using CPLEX
 Attachments

 Paper.pdf
 (8.57 MiB) Downloaded 38 times

 ProjectDATA.xlsx
 (64.31 KiB) Downloaded 30 times

 Infeasible model.gms
 (16.24 KiB) Downloaded 44 times
Re: Infeasible,no solution exist MIP using CPLEX
Hi
I don't have the time to check your equations, but I noticed that if you solve the model as an LP model by changing to binary to normal variables, the model solves, but no investment in new diesel generators.
Perhaps this might help in detecting the problem
Cheers
Renger
I don't have the time to check your equations, but I noticed that if you solve the model as an LP model by changing to binary to normal variables, the model solves, but no investment in new diesel generators.
Perhaps this might help in detecting the problem
Cheers
Renger
Re: Infeasible,no solution exist MIP using CPLEX
Hi,
Thanks Renger for your reply.I was able to get a feasible solution with the MIP when I increased the existing generator available hours (GH).However, once I reduce it so that the old generators can not meet the load alone, instead of the new generators to dispatch, it doesn't. Instead it gives an infeasible solution. Pls, can you check why the model refuses to allow investment in the new diesel generators.
Thanks!
Muna
Thanks Renger for your reply.I was able to get a feasible solution with the MIP when I increased the existing generator available hours (GH).However, once I reduce it so that the old generators can not meet the load alone, instead of the new generators to dispatch, it doesn't. Instead it gives an infeasible solution. Pls, can you check why the model refuses to allow investment in the new diesel generators.
Thanks!
Muna
Re: Infeasible,no solution exist MIP using CPLEX
Munarita,
A good idea, when implementing a new model is usually to look at the equation listing to make sure that you really modeled the equations properly. A frequent source of errors are for example lag and lead operators and that might be an issue in your model too. Looking for example at constraint ComND(nD,y,h)
ComND(nD,y,h).. CapnD(nD,y,h) + NCAnD(nD,y,h) =E= CapnD(nD,y,h+1);
it seems that you might have made a mistake.
For the last h which is '288' the following equation is generated (because there is no h+1):
ComND(1,1,288).. CapnD(1,1,288) + NCAnD(1,1,288) =E= 0 ; (LHS = 0)
Apparently, that forces CapnD(1,1,288) = NCAnD(1,1,288) = 0; Now that carries forward (or backward) through other equations because in consequence
ComND(1,1,287).. CapnD(1,1,287)  CapnD(1,1,288) + NCAnD(1,1,287) =E= 0 ;
enforces CapnD(1,1,287)=NCAnD(1,1,287)=0 etc.
There might be a similar problem in
SComND(nD,y,h).. CapnD(nD,y,'288') + NCAnD(nD,y,'288') =E= CapnD(nD,y+1,'1') $ ((ord(y) ge 3) and (ord(y)lt 20));
where for the last y='20' this equation reads
SComND(1,20,1).. CapnD(1,20,288) + NCAnD(1,20,288) =E= 0 ; (LHS = 0)
You may want to reformulate the equation definitions as follows
ComND(nD,y,h)$(ord(h)<card(h)).. CapnD(nD,y,h) + NCAnD(nD,y,h) =E= CapnD(nD,y,h+1);
SComND(nD,y,h)$(ord(y)<=3 and ord(y)<card(y)).. CapnD(nD,y,'288') + NCAnD(nD,y,'288') =E= CapnD(nD,y+1,'1') ;
After making those changes I get at least a feasible solution (see attached log). However, no one else but you will be able to guarantee that your model is correct. I suggest to thoroughly go through the equation listing and make sure that the actual model fits your intentions.
I hope this helps!
Fred
A good idea, when implementing a new model is usually to look at the equation listing to make sure that you really modeled the equations properly. A frequent source of errors are for example lag and lead operators and that might be an issue in your model too. Looking for example at constraint ComND(nD,y,h)
ComND(nD,y,h).. CapnD(nD,y,h) + NCAnD(nD,y,h) =E= CapnD(nD,y,h+1);
it seems that you might have made a mistake.
For the last h which is '288' the following equation is generated (because there is no h+1):
ComND(1,1,288).. CapnD(1,1,288) + NCAnD(1,1,288) =E= 0 ; (LHS = 0)
Apparently, that forces CapnD(1,1,288) = NCAnD(1,1,288) = 0; Now that carries forward (or backward) through other equations because in consequence
ComND(1,1,287).. CapnD(1,1,287)  CapnD(1,1,288) + NCAnD(1,1,287) =E= 0 ;
enforces CapnD(1,1,287)=NCAnD(1,1,287)=0 etc.
There might be a similar problem in
SComND(nD,y,h).. CapnD(nD,y,'288') + NCAnD(nD,y,'288') =E= CapnD(nD,y+1,'1') $ ((ord(y) ge 3) and (ord(y)lt 20));
where for the last y='20' this equation reads
SComND(1,20,1).. CapnD(1,20,288) + NCAnD(1,20,288) =E= 0 ; (LHS = 0)
You may want to reformulate the equation definitions as follows
ComND(nD,y,h)$(ord(h)<card(h)).. CapnD(nD,y,h) + NCAnD(nD,y,h) =E= CapnD(nD,y,h+1);
SComND(nD,y,h)$(ord(y)<=3 and ord(y)<card(y)).. CapnD(nD,y,'288') + NCAnD(nD,y,'288') =E= CapnD(nD,y+1,'1') ;
After making those changes I get at least a feasible solution (see attached log). However, no one else but you will be able to guarantee that your model is correct. I suggest to thoroughly go through the equation listing and make sure that the actual model fits your intentions.
I hope this helps!
Fred
 Attachments

 Infeasible model.log
 (12.35 KiB) Downloaded 40 times
Re: Infeasible,no solution exist MIP using CPLEX
ComND(nD,y,h)$(ord(h)<card(h)).. CapnD(nD,y,h) + NCAnD(nD,y,h) =E= CapnD(nD,y,h+1);
when I run my model like that, I obtain a feasible solution with maintenance cost for new generators taking values, in fact the new generators starts generating; PgnD(nD,y,h) take values but CCnD which is the cost of adding the new generator and NCAnD(nD,y,h) (new capacity addition)and UnDPur(nD,y,h)(binary variable indicating if new capacity is purchased) all become zero. The generator is not suppose to be generating if it is not purchased. However if I change that same equation to this:
ComND(nD,y,h)$(ord(h)<card(h)).. CapnD(nD,y,h1) + NCAnD(nD,y,h1) =E= CapnD(nD,y,h);
It runs and gives me a reasonable result with all variables relating to new diesel(CCnD,PgnD,UnD,UnDPur,OMCnD,NCA) taking a reasonable values.
If I change the equation to this:
ComND(nD,y,h)$(ord(h)<=card(h)).. CapnD(nD,y,h1) + NCAnD(nD,y,h1) =E= CapnD(nD,y,h);
It runs but returns result like the first scenario i.e this :ComND(nD,y,h)$(ord(h)<card(h)).. CapnD(nD,y,h) + NCAnD(nD,y,h) =E= CapnD(nD,y,h+1);
It appears as if my model is showing that new generators cannot be added at the last hour of every year and whatever is added up on till hour "287" is what I will have at hour "288" and use to start hour 1 in y+1.
I have battled with this for a long time, I don't know if there is another constraint in my model that is causing this or if that's how it should be. I have meeting with my supervisor on Monday and I would need to justify this and is driving me nuts.
Please, any urgent help on explaining this or fixing it if its an error in my model will most exceedingly be appreciated.
Thanks,
Munarita
 Attachments

 Model.gms
 (16.17 KiB) Downloaded 10 times
Re: Infeasible,no solution exist MIP using CPLEX
Munarita,
I did not analyze your model in depth but your approach to try different formulations and check afterwards if results are satisfactory does not seem quite right to me.
I think you should have a clear idea what you actually want to model and then verify your modeling approach by looking at the "critical" equations in the equation listing. For your model, it seems that first/last elements of set h are somewhat critical and that you are not exactly sure how lag/lead, card and ord operators work. You mention one exemplary equation for which you say you tried three different formulations (btw: none of them is exactly used in the model you attached).
Apparently, all of them result in different models. If you are not sure what the actual differences are, you can easily figure it out by looking at the equation listing.
The following excerpts of the equation listing shows the equations of some critical time steps (y,h) =(3,1), ..., (3,287), (3,288), (4,1) for the three different formulations.
1)
2)
3)
No one else but you can answer which one is the right formulation for your model (or if actually any of them is right...).
You also might want to read again the chapters on ord/card and lag/lead operators in the documentation:
 https://www.gams.com/latest/docs/UG_Ord ... OrdAndCard
 https://www.gams.com/latest/docs/UG_Ord ... dOperators
I also wonder whether you actually want to connect hours across years. As far as I can see, you do not do that but your latest post implies to me that you might want to have such connection.
I hope this helps you fixing the model yourself.
Best,
Fred
I did not analyze your model in depth but your approach to try different formulations and check afterwards if results are satisfactory does not seem quite right to me.
I think you should have a clear idea what you actually want to model and then verify your modeling approach by looking at the "critical" equations in the equation listing. For your model, it seems that first/last elements of set h are somewhat critical and that you are not exactly sure how lag/lead, card and ord operators work. You mention one exemplary equation for which you say you tried three different formulations (btw: none of them is exactly used in the model you attached).
Code: Select all
1) ComND(nD,y,h)$(ord(h)< card(h)).. CapnD(nD,y,h) + NCAnD(nD,y,h) =E= CapnD(nD,y,h+1);
2) ComND(nD,y,h)$(ord(h)< card(h)).. CapnD(nD,y,h1) + NCAnD(nD,y,h1) =E= CapnD(nD,y,h);
3) ComND(nD,y,h)$(ord(h)<=card(h)).. CapnD(nD,y,h1) + NCAnD(nD,y,h1) =E= CapnD(nD,y,h);
The following excerpts of the equation listing shows the equations of some critical time steps (y,h) =(3,1), ..., (3,287), (3,288), (4,1) for the three different formulations.
1)
Code: Select all
ComND(1,3,1).. CapnD(1,3,1)  CapnD(1,3,2) + NCAnD(1,3,1) =E= 0 ;
[...]
ComND(1,3,287).. CapnD(1,3,287)  CapnD(1,3,288) + NCAnD(1,3,287) =E= 0 ;
ComND(1,3,288).. EQUATION DOES NOT EXIST
ComND(1,4,1).. CapnD(1,4,1)  CapnD(1,4,2) + NCAnD(1,4,1) =E= 0 ;
Code: Select all
ComND(1,3,1)..  CapnD(1,3,1) =E= 0 ;
[...]
ComND(1,3,287).. CapnD(1,3,286)  CapnD(1,3,287) + NCAnD(1,3,286) =E= 0 ;
ComND(1,3,288).. EQUATION DOES NOT EXIST
ComND(1,4,1)..  CapnD(1,4,1) =E= 0 ;
Code: Select all
ComND(1,3,1)..  CapnD(1,3,1) =E= 0 ;
[...]
ComND(1,3,287).. CapnD(1,3,286)  CapnD(1,3,287) + NCAnD(1,3,286) =E= 0 ;
ComND(1,3,288).. CapnD(1,3,287)  CapnD(1,3,288) + NCAnD(1,3,287) =E= 0 ;
ComND(1,4,1)..  CapnD(1,4,1) =E= 0 ;
You also might want to read again the chapters on ord/card and lag/lead operators in the documentation:
 https://www.gams.com/latest/docs/UG_Ord ... OrdAndCard
 https://www.gams.com/latest/docs/UG_Ord ... dOperators
I also wonder whether you actually want to connect hours across years. As far as I can see, you do not do that but your latest post implies to me that you might want to have such connection.
I hope this helps you fixing the model yourself.
Best,
Fred