问题
I am creating a GAMS model to solve a simple maximization problem. I have a set J with 3 elements (1,2,3) and a variable x(J) that encompasses all the elements.
I am wondering if there is a way in GAMS to set a lower bound of 0 and upper bound of 3 to each element in the set without having to set each element bound individually and without using the positive variable keyword for the lower bound.
I have tried using x.lo =e= 0 and x.up =e= 3 but none of these are working. I am guessing I am not using the correct syntax but for the life of me cannot seem to find anything on the official documentation about it specifically for sets.
What is the correct way of doing this?
回答1:
Try
x.lo(J)=0;
x.up(J)=3;
See also here: https://www.gams.com/26/docs/UG_Variables.html#UG_Variables_AssigningValuesToVariableAttributes
来源:https://stackoverflow.com/questions/54660002/how-to-set-upper-and-lower-bounds-for-each-element-in-a-set