SET     i       /1*3/;
SET     j       /1*3/;
SET     w       /1*3/;

SCALAR alfa /0/;

PARAMETER    price(i)
/1       60
2        40
3        10/;

PARAMETER  cost(j)
/1       2
 2       4
 3       5.2/;

PARAMETER demand(i,w)
/1.1       50
1.2        150
1.3        250
2.1        20
2.2        110
2.3        250
3.1        200
3.2        225
3.3        500/;

PARAMETER  material(i,j)
/1.1     8
1.2      4
1.3      2
2.1      6
2.2      2
2.3      1.5
3.1      1
3.2      1.5
3.3      0.5/;

PARAMETER Prob(w)
/1       0.3
2        0.4
3        0.3/;

VARIABLES
TotalProfit
Profit(w)
VaR
;

POSITIVE VARIABLES
Resources(j)
Production(i,w)
eta(w)
;

*Resources.fx('1')=600;
*Resources.fx('2')=300;
*Resources.fx('3')=150;

EQUATIONS
FO
EqProfit
MaxDemand
ResourceEq
EqRisk
;

FO..     TotalProfit =e= VaR - (1/(1-Alfa))*sum(w,Prob(w)*eta(w));

EqProfit(w)..            Profit(w) =e= sum((i),price(i)*Production(i,w))-
                         sum(j,cost(j)*Resources(j));

MaxDemand(i,w)..         Production(i,w) =l= demand(i,w);

ResourceEq(j,w)..        sum(i,material(i,j)*production(i,w)) - Resources(j) =l=0;

EqRisk(w)..              -Profit(w) + VaR - eta(w) =l= 0;

MODEL Tables /all/;

SOLVE Tables USING lp maximizing TotalProfit;

