SETS
t        /1*7/
s        /1*2/;

SCALAR   Pmax    /150/;
SCALAR   Pmin    /50/;
SCALAR   RU      /150/;
SCALAR   RD      /150/;
SCALAR   PriceC  /48/;
SCALAR   Cost    /20/;
SCALAR   TC      /7/;
SCALAR   Alfa    /0.5/;

TABLE Price(s,t)
         1       2       3       4       5       6       7
1        52      52      52      52      52      52      52
2        47      47      47      47      47      47      47;

PARAMETER Prob(s)
/1       0.5
2        0.5/;

VARIABLES
Profit(s)
CVaR
VaR
;
POSITIVE VARIABLES
PG(s,t)
PP(s,t)
PC
Etta(s)
;


EQUATIONS
FO
Eq1
Eq2
Eq3
Eq4
Eq5
Eq6
Eq7
;

FO..     CVaR =e= VaR - (1/(1-Alfa))*sum(s,Prob(s)*Etta(s));

Eq1(s)..         Profit(s) =e= PriceC*PC*TC + sum(t,PP(s,t)*Price(s,t)-PG(s,t)*Cost);
Eq2(s,t)..       PG(s,t) =e= PP(s,t) + PC;
Eq3(s,t)..       PG(s,t) =l= Pmax;
Eq4(s,t)..       PG(s,t) =g= Pmin;
Eq5(s,t)$(ord(t) gt 1)..   PG(s,t) =l= PG(s,t-1) + RU;
Eq6(s,t)$(ord(t) gt 1)..   PG(s,t) =g= PG(s,t-1) - RD;
Eq7(s)..         Etta(s) =g= -Profit(s) + VaR;


model Forward /all/;

Solve Forward maximizing CVaR using lp;


