User Tools

Site Tools


How do I define a static set from 1 to N+1, where N is some integer provided by the user at the beginning?

You will have to use the eval feature, which has been added to GAMS in distribution 147. I also include an example to compute N+1 from N:

If you want to do something like
 $setglobal N 10
 set i /1*(%N%+1)/
here's how.

* force a compilation error if we don't run GAMS Rev 147 or higher
$version 147

* if we get here we're new enough to use the $eval feature
$setglobal N 10
$eval NP1 %N%+1
set I / 1 * %NP1% /;
display I;

Finally, some details about what GAMS systems will support: the $eval call is mentioned in our release notes for distribution 22.6 (GAMS Base Rev 149), but it is actually available in some form in Distribution 22.4 (GAMS Base Rev 147).

IMPRESSUM / LEGAL NOTICEPRIVACY POLICY gams/define_a_static_set_from_1_to_n_1_where_n_is_some_integer_provided_by_the_user_at_the_beginning.txt · Last modified: 2017/09/02 19:06 by support