I need some help with my code.
i made a comparative analysis with the loop procedure.
i was able to determine the best scenario and it set.
but when i want to write the results from optimal scenario to an output file, the assigned results were always from the last scenario.
Do you have any ideas how to write the results from the best scenario.
Cordialy.
Code: Select all
Sets S 'Scenarios for comparative analysis' /S1*S8/
OptCostSet(S) ' Optimal cost scenario'
;
Table PM(S,t) 'Scenarios of plannend PM'
1 2 3
S1 0 0 0
S2 1 0 0
S3 0 1 0
S4 0 0 1
S5 1 1 0
S6 1 0 1
S7 0 1 1
S8 1 1 1
;
Parameters Output(*,*,*) 'Results'
saveM(t) 'saving M(t) of base scenario'
saveTC(S) 'saving results of each scenario'
OptimalCost 'least cost'
;
saveM(t) = M(t) ;
Loop (S,
M(t) = saveM(t) ;
M(t) = PM(S,t) ;
*Option MINLP = KNITRO ;
Option MIP = CPLEX ;
Solve CSPLSP_BRO using MIP minimizing TC ;
*display TC.l, Xm.l, Xr.l, Xo.l, Xc.l, Xb.l, Is.l, Ir.l, Io.l, Ic.l, W.l, Ym.l, Yr.l, M.l, Z.l, a.l, EN.l ;
saveTC(S) = TC.l ;
) ;
OptimalCost = smin(S,saveTC(S));
OptCostSet(S) = saveTC(S) = OptimalCost ;
Loop (S,
If (saveTC(S) = OptimalCost,
Output("a",S,t) = a.l(t) ;
);
);
Option Output :3:2:1 ;
display Output