|
Suppressing calculation of items (left hand side) |
Top Previous Next |
|
GAMS replacement statements involve an item to change in value on the left hand side and a set of terms that constitute the new value on the right hand side. One may cause the items to be changed only if certain conditions are met. This is controlled with conditionals. $conditionals are used to do this and may control whether the replacement calculation is done alt all or whether selected cases of it are done (only if the left hand side is defined over set elements) on a case by case basis. The general format for such a case is
namedparameter$logical condition=term; or namedparameter(setelementdependency)$logical condition=term;
and specifies that the namedparameter is set equal to the term only if the logical condition is true. Examples: X$(qq gt 0)=3; qq $(sum(I,q(i)) gt 0)=4; qq $ (sum(i,abs(a(i))) gt 0)=1/sum(i,a(i)); a(i) $(qq gt 0) = q(i)+a(i); a(i) $a(i) = q(i)/a(i);
All say implement this replacement statement changing the value of this parameter or its specific case only if the logical condition is true. Thus after the first statement above if X started with a value of 7 and qq was negative causing a false evaluation of the logical condition then X would finish that statement with a value of 7. On the other hand, if qq was positive then X would finish that statement with a value of 3. Notes:
|