Note of caution

Top  Previous  Next

It is always advisable to use parentheses rather than relying on the precedence order of operators.  It prevents errors and makes the intention clear.  It is especially important to encapsulate not operators in parentheses to limit their scope.

Examples:

(complexcond.gms)

u(k)$(s(k) and {u(k) xor t(k)}) = a(k);

u(k)$(s(k) and {u(k) or t(k)}) = a(k);

u(k)$([not s(k)] and {u(k) or  t(k)}) = a(k);

u(k)$(s(k) xor {u(k) and t(k){) = a(k);

u(k)$(s(k) xor [not {u(k) and t(k)}]) = a(k);

Notes:

You can use (),[] and {} in pairs interchangeably.
When the not operator is mixed with other and, or, not, xor, nested $ in a complex logical condition it is virtually imperative that you set the not off in parentheses to insure the meaning of the statement.
When more than one and, or, not, xor, nested $ operator are used in a complex logical condition GAMS will execute the various statement components according to a predefined operator precedence.