|
Right and left hand side conditionals |
Top Previous Next |
|
Conditionals may be used on either the right or left hand side of assignment statements but the operation is very different.
This means that with a conditional on the left hand side of an assignment the previous contents of the parameter will remain unchanged for conditionals that are not satisfied. For example in the GAMS code below (leftright.gms)
Y=2; Z=2; X=0; Y$X=4; Z=4$X;
Y will end with a value of 2 but Z will equal zero since the Y calculation with the left hand side conditional will not be executed since X=0. But the Z calculation is always done and the right hand side conditional 4$X term will be zero since X is zero. Analogous conditions hold for models where
This means that with a left hand side conditional the equation is not entered into the model.
C1$x.. YY=e=4; C2.. YY=e=4$X;
YY will not be constrained by C1 since it has a left hand side conditional and will not be defined as an equation since X=0. But the C2 equation is always defined and the YY will be set equal to zero since the right hand side conditional 4$X term becomes zero since X is zero. |