I declare the set k as follows:
SET k /1 * 3/ ;
Later in my model I am using the expression
X(i,j,'3') = ....
In this expression '3' denotes the last element of the set k.
My question is: Is it possible to write X(i,j,last element of k) instead of X(i,j,'3') ? How can I do this?
The reason for asking is, that I would like to be able to change the cardinality of k without having to go through the rest of the model.
sets in gams
Re: sets in gams
Hi
You can either use card in the equation
or use a dynamic set:
In both cases, you can change the cardinality of the set and this will be reflected in your assignment of X.
Cheers
Renger
You can either use card in the equation
Code: Select all
X(i,j,k)$(ord(k) = card(k)) = ...
or use a dynamic set:
Code: Select all
SET k /1 * 3/,
klast(k) ;
klast(k)$(ord(k) = card(k))= YES;
X(i,j,klast) = ....
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Enjoy modeling even more: Read my blog on modeling at The lazy economist