for loop - How to improve my AMPL SP model with more dimensions -
i have problem ampl stochastic programming,
currently have 3 scenarios , assign probabilities before each solution.
for { t in 1..size-1 2} { allow demand := demandseq[t]; allow resources := resourcesseq[t]; # alter probability of each stage if statesequence[t] = 1 # n { allow p[1]:= 0.7; allow p[2]:= 0.2; allow p[3]:= 0.1; } else if statesequence[t] = 2 # { allow p[1]:= 0.6; allow p[2]:= 0.3; allow p[3]:= 0.1; } else if statesequence[t] = 3 # m { allow p[1]:= 0.5; allow p[2]:= 0.4; allow p[3]:= 0.1; }; solve; ... }
now if alter 3 scenarios problem 10 scenarios problem. have 10*10 probability matrix, don't know how assign prob.
as replied on ampl google group, can define two-dimensional parameter store probabilities:
param probs{1..10, 1..10};
define in info in compact form (or read database or spreadsheet), example:
data; param probs : 1 2 3 ... 10 := 1 0.1 0.2 0.05 ... 0.1 ...
and utilize iterated form of let
assign info p:
let {i in 1..10} p[i] := prob[statesequence[t], i];
for-loop matrix ampl sp
No comments:
Post a Comment