Not

Top  Previous  Next

When one wishes to do something when a conditional is not true one can prefix it a not operator.  This involves using syntax like

 

Action$( not logical condition 1)

or

If(not logical condition 1, Action);

or

While(not logical condition 1), Action);

Examples:

(complexcond.gms)

u(k)$(not s(k)) = a(k);

loop(k,if(not (s(k) lt 0), u(k) = a(k)) );

Notes:

When a logical condition is preceded by a not then the logical condition must be false for the not of it to be true.
The not operator can be mixed with other and , or , not, xor , nested $ in a complex logical condition.  When this is done GAMS will execute the various statement components according to a predefined operator precedence.  However it is virtually imperative that you set the not off in parentheses to insure the meaning of the statement.