Hello my friends, I have an UC problem to solve using GAMS, however I got stuck on how I can write the equations constraints for the min run/down time, I will post here my code:

```
sets
time periods of time for generation /1*10/
gen generators /1*5/
table gendata(gen,*) generator parameters
* fixed variable start up
* cost cost cost
pmin pmax A B C D E
1 50 110 40 9 220 25 0
2 80 240 55 5 500 20 0
3 70 140 90 8 350 40 0
4 50 130 60 6 290 30 0
5 20 45 30 12 110 80 0
table pdata(time,*) data for each period
* Demand Wind
D R
1 450 80
2 420 105
3 370 120
4 440 90
5 450 50
6 400 75
7 500 35
8 530 75
9 510 20
10 470 80
variables
z overall cost - objective variable
z_1 (time) ;
Positive Variables
p(gen,time) output power of generators;
binary variables
v(gen,time) is equal to 1 if generator is on for that period
x(gen,time) is equal to 1 if generator started up
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;
Parameter wind(time);
wind(time) = pdata(time,"R")$(pdata(time,"R") le pdata(time,"D")*0.2) + pdata(time,"D")*0.2$(pdata(time,"R") gt pdata(time,"D")*0.2) ;
equations
cost objective function
cost_1 (time)
Start_up(gen,time)
pmax(gen,time) maximum output power
pmin(gen,time) minimum output power
load(time) load balance equation;
load(time).. sum(gen,p(gen,time))=e= pdata(time,"D") - wind(time);
cost .. z =e= sum((gen,time), gendata(gen,"A")*v(gen,time)+gendata(gen,"B")*p(gen,time)+gendata(gen,"C")*x(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")*x(gen,time));
Start_up(gen,time).. x(gen,time)=e=v(gen,time)-v(gen,time-1);
pmax(gen,time).. p(gen,time)=l=gendata(gen,"pmax")*v(gen,time);
pmin(gen,time).. p(gen,time)=g=gendata(gen,"pmin")*v(gen,time);
model uc /all/;
uc.optcr=0.001;
solve uc using mip minimizing z;
display z.l, p.l,x.l,z_1.l;
```

===============================================================================

it is working fine, however this new questions is add:

Units 1, 4 and 5 have been online for 5, 3 and 4 hours, respectively, at the start of the 10 hour period, while units 2 and 3 have been offline for 3 and 2 hours, respectively. If all unit constraints and costs are applied, i.e. including minimum run times and down times, determine the optimal unit commitment and economic dispatch, and the associated cost, for the 10 hour period.

Hint: Conditional constraints and the alias command may be helpful in formulating constraints relating to the minimum run and down times.

Hint: The GAMS program formulation can be simplified if the predicted demand and wind generation profiles for hours 11 - 15 are also known. Assume the following predicted demand and wind profiles:

11 12 13 14 15

Demand (MW) 480 450 410 390 440

Wind (MW) 70 30 85 40 25

please can anyone help, I tried everything.

thanks