I was trying to minimize the cost of three generating units and the code is working well but when I added the stochastic part random variable (PV) it became infeasible no solution please anyone can help me
* 6-bus system UC without line constraints only generating units and load
Set
t 'time' / t1*t24 /
i 'generators indices' / g1*g3 /
k 'cost segments' / sg1*sg20 /
char / ch1*ch2 /;
scalar pv /4/;
Alias (t,h);
Table gendata(i,*) 'generator cost characteristics and limits'
bus Pmax Pmin a b c CostsD costst RU RD SU SD UT DT uini U0 S0 fuel
g1 1 220 100 0.050 10 100 0 100 55 55 105 108 4 4 1 4 0 1
g2 2 100 10 0.001 40.66 162 0 200 50 50 106 112 2 3 0 0 3 1
g3 6 20 10 0.006 22.06 171 0 0 20 20 43 45 1 1 0 0 1 1;
* -----------------------------------------------------
* linearizing the quadratic fuel cost FC = a*p*p + b*p + c;
Parameter data(k,i,*);
data(k,i,'DP') =(gendata(i,"Pmax") - gendata(i,"Pmin"))/card(k);
data(k,i,'Pini') =(ord(k) - 1)*data(k,i,'DP') + gendata(i,"Pmin");
data(k,i,'Pfin') = data(k,i,'Pini') + data(k,i,'DP');
data(k,i,'Cini') = gendata(i,"a")*power(data(k,i,'Pini'),2)
+ gendata(i,"b")*data(k,i,'Pini') + gendata(i,"c");
data(k,i,'Cfin') = gendata(i,"a")*power(data(k,i,'Pfin'),2)
+ gendata(i,"b")*data(k,i,'Pfin') + gendata(i,"c");
data(k,i,'s') =(data(k,i,'Cfin') - data(k,i,'Cini'))/data(k,i,'DP');
gendata(i,'Mincost') = gendata(i,'a')*power(gendata(i,"Pmin"),2)
+ gendata(i,'b')*gendata(i,"Pmin") + gendata(i,'c');
* -----------------------------------------------------
* 24 hours load profile
Table dataLP(t,*)
load
t1 175.19
t2 165.15
t3 158.67
t4 154.73
t5 155.06
t6 160.48
t7 168.39
t8 177.6
t9 186.81
t10 206.96
t11 228.61
t12 236.1
t13 242.18
t14 243.6
t15 248.86
t16 255.79
t17 256
t18 246.74
t19 245.97
t20 237.35
t21 236.31
t22 232.67
t23 208.93
t24 195.6;
* eq. (5.5d) page 122
Parameter unit(i,char);
unit(i,'ch1') = 24;
unit(i,'ch2') =(gendata(i,'UT') - gendata(i,'U0'))*gendata(i,'Uini');
gendata(i,'Lj') = smin(char,unit(i,char));
*eq. (5.6d) page 123
Parameter unit2(i,char);
unit2(i,'ch1') = 24;
unit2(i,'ch2') =(gendata(i,'DT') - gendata(i,'S0'))*(1 - gendata(i,'Uini'));
gendata(i,'Fj') = smin(char,unit2(i,char));
Variable costThermal;
Positive Variable pu(i,t), p(i,t), StC(i,t), SDC(i,t), Pk(i,t,k);
Binary Variable u(i,t), y(i,t), z(i,t);
p.up(i,t) = gendata(i,"Pmax");
p.lo(i,t) = 0;
Pk.up(i,t,k) = data(k,i,'DP');
Pk.lo(i,t,k) = 0;
p.up(i,t) = gendata(i,"Pmax");
pu.up(i,h) = gendata(i,"Pmax");
Equation
Uptime1, Uptime2, Uptime3, Dntime1, Dntime2, Dntime3, Ramp1, Ramp2,
startc, shtdnc, genconst1, Genconst2, Genconst3, Genconst4, balance;
* minimum up time constraints
Uptime1(i)$(gendata(i,"Lj")>0)..
sum(t$(ord(t)<(gendata(i,"Lj")+1)), 1 - U(i,t)) =e= 0;
Uptime2(i)$(gendata(i,"UT")>1)..
sum(t$(ord(t)>24-gendata(i,"UT")+1), U(i,t) - y(i,t)) =g= 0;
Uptime3(i,t)$(ord(t)>gendata(i,"Lj") and ord(t)<24-gendata(i,"UT")+2 and not(gendata(i,"Lj")>24-gendata(i,"UT")))..
sum(h$((ord(h)>ord(t)-1) and (ord(h)<ord(t)+gendata(i,"UT"))), U(i,h)) =g= gendata(i,"UT")*y(i,t);
* minimum down time constraints
Dntime1(i)$(gendata(i,"Fj")>0)..
sum(t$(ord(t)<(gendata(i,"Fj")+1)), U(i,t)) =e= 0;
Dntime2(i)$(gendata(i,"DT")>1)..
sum(t$(ord(t)>24-gendata(i,"DT")+1), 1 - U(i,t) - z(i,t)) =g= 0;
Dntime3(i,t)$(ord(t)>gendata(i,"Fj") and ord(t)<24-gendata(i,"DT")+2 and not(gendata(i,"Fj")>24-gendata(i,"DT")))..
sum(h$((ord(h)>ord(t)-1) and (ord(h)<ord(t)+gendata(i,"DT"))), 1-U(i,h)) =g= gendata(i,"DT")*z(i,t);
* start-up and shut-down constraints
startc(i,t).. StC(i,t) =g= gendata(i,"costst")*y(i,t);
shtdnc(i,t).. SDC(i,t) =g= gendata(i,"CostsD")*z(i,t);
* eq. (5.3d) P lower >= Pmin which PL = Pmin + Pk
genconst1(i,h)..
p(i,h) =e= u(i,h)*gendata(i,"Pmin") + sum(k, Pk(i,h,k));
* Eq. (5.4a)
Genconst2(i,h)$(ord(h)>0)..
U(i,h) =e= U(i,h-1)$(ord(h)>1) + gendata(i,"Uini")$(ord(h)=1) + y(i,h) - z(i,h);
* Eq. (5.2a)
Genconst3(i,t,k)..
Pk(i,t,k) =l= U(i,t)*data(k,i,'DP');
* ramp rate constraints
Ramp1(i,t).. p(i,t+1) - p(i,t) =l= gendata(i,'RU');;
Ramp2(i,t).. p(i,t-1) - p(i,t) =l= gendata(i,'RD');;
* Demand-Generation Balance constraint
balance(t).. sum(i, p(i,t)) =e= dataLP(t,'load')-pv;
* Objective Function
Genconst4..
costThermal =e= sum((i,t), StC(i,t) + SDC(i,t))
+ sum((t,i), u(i,t)*gendata(i,'Mincost') + sum(k, data(k,i,'s')*pk(i,t,k)));
Model UCLP / all /;
file emp / '%emp.info%' /; put emp '* problem %gams.i%'/;
$onput
randvar pv beta 4 7
stage 2 pv
stage 2 balance
$offput
putclose emp;
Set scen Scenarios / s1*s6 /;
Parameter
s_pv(scen) pv by scenario;
Set dict / scen .scenario.''
pv .randvar .s_pv /;
option emp=lindo;
*option optCr = 0.0;
option reslim = 86400;
*option Savepoint=1;
option optcr=0.005;
solve UCLP min costThermal use emp scenario dict;
Display s_pv;