Or

Top  Previous  Next

When one wishes to perform an action if at least one of two or more conditionals apply one can join them with an or operator.  This involves using syntax like

 

Action$(logicalcondition1 or logicalcondition2 or

                             logicalcondition3)

or

If(logicalcondition1 or logicalcondition2 or

                        logicalcondition3), Action);

or

While(logicalcondition1 or logicalcondition2 or

                           logicalcondition3), Action);

Examples:

(complexcond.gms)

u(k)$(s(k) or t(k)) = a(k);

u(k)$(s(k) or u(k) or t(k)) = a(k);

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

Notes:

Any one or more than one of the logical conditions must be simultaneously true for the total logical condition to be true.
The or 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 advisable to be cautious and use parentheses to carefully control the meaning of the condition.