This is an old revision of the document!
I need my set to be able to changing depending on the value of a scalar. e.g:
scalar dim /10/; set myset /1*dim/;
In general we do it the other way around:
set myset /1*10/; scalar dim; dim = card(myset);
In the GAMS philosophy sets drive the model. Creating sets based on data (eg scalars) requires the use of dynamic sets, which are a little bit more difficult to use than static sets. Here is a fragment that illustrates how you can use dynamic sets:
set univ the universe /1*1000/; scalar dim /6/; set myset(univ); myset(univ)$(ord(univ) <= dim) = yes; Display myset; * declare equations, variables and parameters over the universe set * but use them over myset parameter p(univ); p(myset) = 1;
You can also pass compile time information through the command line:
gams x.gms –mydim=5 with x.gms''
$if not set mydim $set mydim 5 set myset / 1*%mydim%/