The .fx variable attribute: Dumb question

Problems with syntax of GAMS
Post Reply
ALe
User
User
Posts: 4
Joined: 6 years ago

The .fx variable attribute: Dumb question

Post by ALe »

The description for the .fx variable attribute is given as follows:
-------
Gams UsersGuide:
.fx : The fixed value for the variable.
GAMS allows the user to set variables through the .fx variable suffix. This is equivalent to the lower bound and upper bound
being equal to the fixed value. Fixed variables can subsequently be freed by changing the lower and upper bounds.

The .fx suffix is really just a shorthand for .lo and .up and can therefore only be used only on the left-hand side of an assignment statement.
-------
McCarl guide:
The upper and lower bound are changed when the Fx attribute for a variable is set to the value of the Fx attribute.
A fixed value for the variable which if set results in the variable up and lo bounds being set to the value of the fx attribute.
-------

Both guides thus essentially say that setting var_x.fx(…) = <value> should be equivalent to setting the .lo and .up bounds. However, my experience with it is quite different, as I am seeing an unexpected side-effect of the variable level var_x.l(…) also being set, i.e. as if I had also been setting var_x.l(…) = <value> when I am setting the .fx attribute. But if I set the .up/.lo bounds using two separate assignments, there is no such side-effect.

Q1: Is the documentation correct in saying that "the .fx suffix is really just a shorthand for .lo and .up"? And if yes, why I am seeing the level being set as well?
Q2: If the documentation is inaccurate, is there any way of setting the .up and .lo bounds simultaneously, while preserving the .level values (as the documentation would imply)? Or should one just resort to setting .up and .lo separately, in order to preserve the .level values when necessary?
Lutz
User
User
Posts: 59
Joined: 7 years ago

Re: The .fx variable attribute: Dumb question

Post by Lutz »

Hi,

About q1: It is correct, that .fx also sets .l (in contrast to setting .lo and .up separately).
About q2: I don't know where exactly you found the things you quoted here from the documentation, but I just searched for the fx attribute and found this (https://www.gams.com/latest/docs/UG_Var ... gVariables):

"Fixing Variables: GAMS allows the user to fix variables through the .fx variable suffix. This is almost equivalent to setting the lower bound and upper bound equal to the fixed value. The attribute .fx also resets the activity level .l to the fixed value. When setting .lo and .up the activity level remains unchanged. A solve statement will project the activity level within the active bounds. Fixed variables can subsequently be freed by changing the lower and upper bounds."

So if you want to keep the level outside of the bounds, you need to set .lo and .up separately.

Best regards,
Lutz

ps: Why do you actually need to keep .l outside of the bounds?
Post Reply