Set with dynamic size

Problems with syntax of GAMS
Post Reply
mouad.benbouja
User
User
Posts: 1
Joined: 4 years ago

Set with dynamic size

Post by mouad.benbouja »

Hello,

Please I need support to develop a parameter of 3 sets P(t,c,b).

Set
t /t1 t5/
c /c1 c10/
b / set with dynamic size, it depends on a randomly generated parameter e.g. H(t,c)=uniform(100,200) /

Parameter H(t,c)
Parameter P(t,c,b)


P(t,c,b)= round(uniform(0,1));


Thanks a lot for your support.
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Set with dynamic size

Post by Renger »

Hi

If I understand you correctly, the size can have any number of elements between 100 and 200, e.g. /1*167/.

If that is what you mean, you could do this as follows:

Code: Select all

* Define a maximum set
set n /1*200/;

parameter sizeb Size of dynamic set;

sizeb = uniformInt(100,200)

set b(n) Dynamic set;

b(n)$(n.val < sizeb+1) = yes;

display b;


You can "empty" the set by writing b(n) = NO;
Hope this helps.
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply