$ifThen set X or Y Topic is solved

Problems with syntax of GAMS
Post Reply
zamry
User
User
Posts: 10
Joined: 2 years ago

$ifThen set X or Y

Post by zamry »

Hello,

Is there a way to execute the following condition when solving a model?

Code: Select all

$ifThen set X or Y
Solve MODEL using nlp minimizing OBJ;
$else
Solve MODEL using lp minimizing OBJ;
$endIf
X and Y are compilation variables, and either one exists at a time.

Thanks,
Zamry
User avatar
bussieck
Moderator
Moderator
Posts: 1043
Joined: 7 years ago

Re: $ifThen set X or Y

Post by bussieck »

No, the "$if set" only works on a single compile time variable name, not an expression. You can work around this by having a parallel set of numerical compile time variables and then use $ifThenE:

Code: Select all

$set xset 0
$if set x $set xset 1
$set yset 0
$if set y $set yset 1
$log %xset%%yset%
$ifThenE (%xset%)or(%yset%)
Solve MODEL using nlp minimizing OBJ;
$else
Solve MODEL using lp minimizing OBJ;
$endIf
-Michael
zamry
User
User
Posts: 10
Joined: 2 years ago

Re: $ifThen set X or Y

Post by zamry »

Thanks Michael!
Post Reply