Consider the following set and parameter in GAMS:
set i / 1,3 /
j / j1,j2,j3 /;
parameter stock(i,j);
Consider I want to put a specific value in the parameter:
stock("1","j1") = 10;
stock("3","j3") = 10;
Instead of writing that in two lines, can I use macro, $setGlobal, loop (or similar) to first (1) specify which set it should do it for, and (2) secondly only writing the equation in one line?
I can create a subset:
set subset_i(i) / 1,3/
subset_j(j) / j1,j3 /;
And then loop through these subset:
loop(subset_i,
loop(subset_j,
stock(i,j) = 10;
);
);
But then I get the value for each combination:
1 j1 10
1 j2 10
1 j3 10
3 j1 10
3 j2 10
3 j3 10
I only want:
1 j1 10
3 j3 10
How do I do that?
Is it exactly the diagonal (1-j1; 2-j2), you want to set? Or was that just a random example, and the mapping could also be another one? If it is the diagonal, you can do it like this:
EDIT (based on the comments/the edited question):
One can also define a more general mapping explicitly, if it is not just about the diagonal. This could be done like this: