Zamry,
You need to understand the difference between GAMS
compile and
execution time (see
https://www.gams.com/latest/docs/UG_Gam ... ll_TwoPass). All compile time commands are performed
before any execution time. So the "$ifThenE postsolve>0" is checked before you calculate "postsolve = card(devices);". If devices is a set determined at compile time via e.g. "set deviced / d1*d10 /", then you can do the check via ""$ifThenE card(devices)>0". If devices is a set determined at execution time, then you can't do any $ifthen. In such cases a regular "if" might help:
Code: Select all
Scalar postsolve / 0 /;
postsolve = card(devices);
if(postsolve>0
...(build model and solve it)
);
You can't do any declaration inside the if(), but that's usually not a problem, you just do them before the if.
-Michael