Page 1 of 1

$ifThen set X or Y

Posted: Mon Apr 01, 2024 7:38 pm
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

Re: $ifThen set X or Y

Posted: Tue Apr 02, 2024 7:57 am
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

Re: $ifThen set X or Y

Posted: Tue Apr 02, 2024 4:00 pm
by zamry
Thanks Michael!