Page 1 of 1

Stochastic Programming with multiple stochastic parameters

Posted: Fri Mar 16, 2018 9:34 pm
by GabrielYin
Hi dudes,

I have one problem with the SP in GAMS. When I run a simple code with multiple stochastic terms, denoted by n, such as d(n), the output returns "System Failure", which I could not identify what happened. Here is my part of stochastic definition:

File emp / '%emp.info%' /;
put emp '* problem %gams.i%'/;
$onput
randvar d(n) discrete 0.25 70 0.5 100 0.25 130
stage 1 y(n)
stage 2 u(n) v(n) d(n) w(m)
stage 2 row1 row2
$offput
putclose emp;

Set scen "scenarios" / s1*s9 /;
Parameter
s_d(scen,n) "demand realization by scenario"
s_u(scen,n) "units bought by scenario"
s_v(scen,n) "units sold by scenario"
s_w(scen,m) "units substituted by scenario"
s_rep(scen,*) "scenario probability" / #scen.prob 0/;

Set dict / scen .scenario.''
d .randvar .s_d
w .level .s_w
v .level .s_v
u .level .s_u
'' .opt .s_rep /;

Since I have two sets, it is impossible to eliminate (n) and (m) in the definition, which would trigger "domain violation".

I have checked the output, and it returned System Failure, and it had a hint:

*** emp.info line 2: Unknown uel: n
Hint: EMP keys like Chance, Stage, VaR, ... are not allowed as symbol names

So does it mean I could not use inside set identifier like d(n) in the stochastic definition? Then how could I establsih a multi-randomness model? In my case, I have two variables which both obey the discrete distribution.

Thank you guys!

Cheers!

Re: Stochastic Programming with multiple stochastic parameters

Posted: Tue Mar 20, 2018 2:35 pm
by Lutz
GabrielYin wrote: 6 years ago ...
randvar d(n) discrete 0.25 70 0.5 100 0.25 130
...
Then how could I establsih a multi-randomness model? In my case, I have two variables which both obey the discrete distribution.
...
Hi,

First to make sure, that I understand what you want to do: You mention two variables which follow the discrete distribution. Do they follow it "together" or independent of each other? So do you want to have 3 scenarios in the end or 9 scenarios (3*3)?

Best regards,
Lutz

Re: Stochastic Programming with multiple stochastic parameters

Posted: Wed Mar 28, 2018 9:45 am
by GabrielYin
Hi Lutz,

I had them obey the same discrete distribution. And I have found a solution, that GAMS can only recognize variables in all notations instead of set. So, I should write the codes as:

$onput
stage 1 y(’n1’) y(’n2’)
stage 2 u(’n1’) u(’n2’) v(’n1’) v(’n2’) d(’n1’) d(’n2’) w(’m1’) w(’m2’) w (’m3’)
stage 2 row1 row2
$offput
putclose emp;

instead of

$onput
stage 1 y(n)
stage 2 u(n) v(n) d(n) w(m)
stage 2 row1 row2
$offput
putclose emp;

Thank you for answering and sorry for replying so late.

Cheers!