Nested $ conditionals

Top  Previous  Next

$ conditions can be nested.  The term $(logicalcondition1$( logicalcondition2)) can also be written as $( logicalcondition1 and logicalcondition2).  For nested $ conditions, all succeeding expressions after the first $ must be enclosed in parentheses.  Consider the following example (complexcond.gms),

 

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

 

The assignment will be made only for those members of k that are also members or associated with data in both s and t.  Note the position of the parenthesis in the $ condition.  The statement above can be rewritten as

 

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

 

To assist with the readability of statements, one should usually employ the operator and instead of nesting dollar operators.