user3554599
user3554599

Reputation: 81

How to set upper and lower bounds for each element in a set?

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?

Upvotes: 1

Views: 279

Answers (1)

Lutz
Lutz

Reputation: 2292

Try

x.lo(J)=0;
x.up(J)=3;

See also here: https://www.gams.com/26/docs/UG_Variables.html#UG_Variables_AssigningValuesToVariableAttributes

Upvotes: 0

Related Questions