$Evallocal

Top  Previous  Next

This evaluates a numerical expression at compile time and places it into a local control variable.  In turn one can use $ife to do numeric testing on the value of this variable.

 

The format is

 $EvalLocal expression

 

The expression must consist of constants, functions or other control variables with numerical values.

Example:

 $set znumber 4

       $EvalLocal anumber %znumber%+10

         $ife %anumber%>14 display "it exceeds 14" "%anumber%"

         $ife %anumber%<14 display "it is less than 14" "%anumber%"

         $ife %anumber%=14 display "it equals 14" "%anumber%"

         $ife %anumber%<>14 display "it does not equal 14" "%anumber%"

Notes:

Related functions are

         $Eval                        that works with local control variables

         $Evalglobal        that works with global control variables

 

Unfortunately GAMS allows one to define scoped local and global variables with the same name but treats them as different under some cases and prioritizes them when using $ife or $if as discussed here.
The calculations can only involve real numbers
Expression evaluation proceeds from left to right
When items are not set off in parentheses the operator precedence us

OR XOR EQV IMP

AND

NOT

< <= = <> >= > LE LE EQ NE GE GT

+ - binary and unary

* /

^ **

The following functions can be uswd in expressions:

abs  ceil  cos  exp   floor  frac  IfThen  log   log2  log10  max

min  mod   PI   power round  sign  sin     sleep sqr   sqrt   tan   trunk