Page 1 of 1

uniformInt function

Posted: Thu May 27, 2021 9:39 pm
by Sandrina
Hello!
One of the parameters I want to include in a model I'm working on is associated with four distinct indices, whose sets I have already defined.
These are:

Code: Select all

P products /p1*p32/
D donor locations /d1*d4/
T planning periods /t1*t7/
S scenarios /s1*s3/
The BS(P,D,T,S) parameter will take values generated by the uniform probability distribution, whose high and low are different depending on p. That is, from p1 to p8, the function will be uniformInt(15,20), from p9 to p16 it will be uniformInt(10,15), from p17 to p24 it will be uniformInt(5,10) and from p25 to p 32 it will be uniformInt(0,5).
How can I define the BS parameter?

Translated with www.DeepL.com/Translator (free version)

Re: uniformInt function

Posted: Fri May 28, 2021 7:11 am
by bussieck
GAMS is all about data driven compact programming, while you could program bs(p,d,t,s)$(ord(p)>=1 and ord(p)<=8) = uniformInt(15,20); ... it is much nicer and cleaner to define the bounds on the uniformInt as data and have one compact statement:

Code: Select all

sets
P products /p1*p32/
D donor locations /d1*d4/
T planning periods /t1*t7/
S scenarios /s1*s3/;
parameter bs(p,d,t,s);
Table uniformIntBnd(p,*)
        lo  up
p1*p8   15  20
p9*p16  10  15
p17*p24  5  10
p25*p32  0   5;

bs(p,d,t,s) = uniformInt(uniformIntBnd(p,'lo'),uniformIntBnd(p,'up')); 
-Michael

Re: uniformInt function

Posted: Fri May 28, 2021 1:57 pm
by Sandrina
I understood it now. Thank you very much!