## Error 57 with MIP code

Problems with syntax of GAMS
rpereira57
User
Posts: 5
Joined: 10 months ago

### Error 57 with MIP code

can anyone help me with this issue?
I know the problme is within this equation:

WINDY (time)\$(ord(time) GT 5) .. wind(time) =e= pdata(time,"R")\$(pdata(time,"R") le twodandc(time)) + twodandc(time)\$(pdata(time,"R") gt twodandc(time));

I am HAVE to use MIP and I believe this type of equation is not supported, but I have no idea how to fix it, thanks very very much

Code: Select all

``````sets
time periods of time for generation /1*16/
gen generators /1*6/
scalar full/0.8/
Alias (time,al_time);

table gendata(gen,*) generator parameters
*                           fixed    variable   start up
*                           cost     cost       cost
pmin     pmax      A        B          C           D     E     F
1        50       110       40       9          220         25    7     5
2        80       240       55       5          500         20    6     4
3        70       140       90       8          350         40    5     2
4        50       130       60       6          290         30    4     2
5        20       45        30       12         110         80    0.5   0.5
6        5        50                                        100   0.5   0.5

table pdata(time,*) data for each period
*        Demand  Wind
D       R
1        490     0
2        535     0
3        425     0
4        285     0
5        285     0
6        450     80
7        420     105
8        370     120
9        440     90
10       450     50
11       400     75
12       500     35
13       530     75
14       510     20
15       470     80
16       480     70

variables
z overall cost - objective variable
z_1 (time)
v(gen,time) is equal to 1 if generator is on for that period
y(gen,time) is equal to 1 if generator is started-up for period time
s(gen,time) is equal to 1 if generator is shut down in period time
vGenAboveMinLoad(gen,time) Differnce between P and Pmin
vStorLevel(time) Storage level at that hour in MWh
vChrg(time) is equal to 1 if PS is pumping
vDChrg(time) is equal to 1 if PS is generating
control(time);

Positive Variables
p(gen,time) output power of generators
wind(time) wind output
vChrgAmt (time)  Amount of energy taken from the gris by PS in MWh
vDChrgAmt (time) Amount of energy supplied by the PS in MWh
dandc(time)
twodandc(time)
Vdiff(time);

binary variables
v(gen,time) is equal to 1 if generator is on for that period
y(gen,time) is equal to 1 if generator is started-up for period time
s(gen,time) is equal to 1 if generator is shut down in period time
vChrg(time) is equal to 1 if PS is pumping
vDChrg(time) is equal to 1 if PS is generating;

*vStorLevel.fx("5")=50;

v.fx("1","1")=1;v.fx("1","2")=1;v.fx("1","3")=1;v.fx("1","4")=1;v.fx("1","5")=1;
v.fx("4","1")=0;v.fx("4","2")=0;v.fx("4","3")=1;v.fx("4","4")=1;v.fx("4","5")=1;
v.fx("5","1")=0;v.fx("5","2")=1;v.fx("5","3")=1;v.fx("5","4")=1;v.fx("5","5")=1;
v.fx("2","1")=1;v.fx("2","2")=1;v.fx("2","3")=0;v.fx("2","4")=0;v.fx("2","5")=0;
v.fx("3","1")=1;v.fx("3","2")=1;v.fx("3","2")=1;v.fx("3","2")=0;v.fx("3","2")=0;

*Parameter wind(time);

*wind(time)\$(ord(time) GT 5) = pdata(time,"R")\$(pdata(time,"R") le (pdata(time,"D")+vDChrgAmt (time))*0.2) + (pdata(time,"D")+vDChrgAmt (time))*0.2\$(pdata(time,"R") gt (pdata(time,"D")+vDChrgAmt (time))*0.2) ;

Parameter max_Charge_Disc(time);
max_Charge_Disc(time) = 50;

equations
cost objective function
cost_1 (time)
start_logic(gen,time)
pmax(gen,time) maximum output power
pmin(gen,time) minimum output power
Rampup(gen,time)
Rampdown(gen,time)
relationBwnGenAndGenAboveMin(gen,time)
enforceminuptime(gen,time)   min up time
enforcemindowntime(gen,time) min down time
statusofplant(gen,time)

eStorLevel (time) storage level depends on previous hr and the amount discharged or charged
eChrgState (time) Constraining binary charge & discharge variable so that they're not on at the same time
eChrgRate  (time) Constraining the max available charging rate
eDChrgRate (time) so it does not discharge more than available
eStorMax   (time) make sure the storage level is less than max storage capacity
eStorMin   (time) make sure the storage level is above min storage capactiy
totaldemand(time)
twototaldemand(time)
balance (time)
WINDY (time);

cost .. z =e= sum((gen,time), gendata(gen,"A")*v(gen,time)+gendata(gen,"B")*p(gen,time)+gendata(gen,"C")*y(gen,time));
cost_1 (time)..  z_1 (time) =e= sum(gen, gendata(gen,"A")*v(gen,time)+gendata(gen,"B")*p(gen,time)+gendata(gen,"C")*y(gen,time));
start_logic(gen,time)\$(ord(time) GT 5) ..  y(gen,time)-s(gen,time)=e=v(gen,time)-v(gen,time-1);
pmax(gen,time)\$(ord(time) GT 5) .. p(gen,time)=l=gendata(gen,"pmax")*v(gen,time);
pmin(gen,time)\$(ord(time) GT 5) .. p(gen,time)=g=gendata(gen,"pmin")*v(gen,time);

totaldemand(time) .. dandc(time) =e= vChrgAmt(time) + pdata(time,"D");
twototaldemand(time) .. twodandc(time) =e= dandc(time)*0.2;

WINDY (time)\$(ord(time) GT 5) .. wind(time) =e= pdata(time,"R")\$(pdata(time,"R") le twodandc(time)) + twodandc(time)\$(pdata(time,"R") gt twodandc(time));

balance(time)\$(ord(time) GT 5) .. control(time) =e= vChrgAmt(time)+ vDChrgAmt(time)              ;

relationBwnGenAndGenAboveMin(gen,time) .. p(gen,time) =e= v(gen,time)*gendata(gen,"pmin") + vGenAboveMinLoad(gen,time);

enforceminuptime(gen,time)\$(ord(time) GT 5) .. v(gen,time) =g= sum(al_time\$[ORD(al_time)<=ORD(time) and ORD(al_time)>(ORD(time)- gendata(gen,"E"))],y(gen,al_time));
enforcemindowntime(gen,time)\$(ord(time) GT 5) .. 1 - v(gen,time) =g= sum(al_time\$[ORD(al_time)<=ORD(time) and ORD(al_time)>(ORD(time) - gendata(gen,"F"))],s(gen,al_time));
statusofplant(gen,time)\$(ord(time) GT 1) .. v(gen,time) =e= v(gen,time-1)\$[ORD(time)>1]+y(gen,time)-s(gen,time);

eStorLevel (time)\$(ord(time) GT 5) .. vStorLevel(time) =E= vStorLevel(time-1) +  vChrgAmt(time-1) - vDChrgAmt(time-1);
eChrgState (time)\$(ord(time) GT 5) .. vChrg(time) + vDChrg(time) =L= 1;
eChrgRate  (time)\$(ord(time) GT 5) .. vChrgAmt(time) =L= vChrg(time)*max_Charge_Disc(time)    ;
eDChrgRate (time)\$(ord(time) GT 5) .. vDChrgAmt(time) =L= vDChrg(time)*max_Charge_Disc(time)  ;
eStorMax   (time)\$(ord(time) GT 5) .. vStorLevel(time) =L= 125*full               ;
eStorMin   (time)\$(ord(time) GT 5) .. vStorLevel(time) =G= 0                 ;

load(time)\$(ord(time) GT 5) .. sum(gen,p(gen,time)) =e= pdata(time,"D") - wind(time) + vChrgAmt(time)- vDChrgAmt(time);

model uc /all/;
uc.optcr=0.001;

solve uc using mip minimizing z;

display z.l, p.l,y.l,z_1.l,s.l, vDChrgAmt.l, vChrgAmt.l,eChrgRate.l,eDChrgRate.l,vchrg.l,vdchrg.l,vstorlevel.l;

``````