Let’s suppose i have a set X = \y1 y2 y3 … z1 z2\ and a variable w(X) = \y1 10, y2 20, y3 30, … , z1 40, z2 50
Is there an easy way of summing the values for all the elements of w(X) that have the string “y” in their name?
Doing set member ship based on the name of a label is not what you should do in GAMS. We make this difficult on purpose, because that is a fragile thing. Better be explicit about it:
set Tid /2000*2020/;
singleton set FinalYear /2017/;
singleton set StatBank /2017/;
if (FinalYear < StatBank,
loop( ...);
);
I have an error when starting “if” condition.
I would like to “compare” the years (elements) of these two singleton sets, and if they are the same I want to do the loop statement.
Hi, to be able to compare them I think they should be defined as parameters.
Another possibility is to use auxiliary parameters.
To search for a string in a set, I usually use the “sameas” command.
Bye!