1

In this case:

sets
m /m1*m5/
v /v1*v4/

I want to use just elements from "v1" to "v3" for a particular variable:

positive variables
Q(m,v)
R(m,v)

And in the following objective function or equations, these variables are calculated as just excluded elements.

I mean Q(m,v) include "v1", "v2" and "v3"; and R(m,v) include "v4".

obj .. Q(m,v) + R(m,v)

eq1(m) .. sum(v, Q(m,v))
eq2(v) .. sum(m, Q(m,v) + R(m,v))

How can I exclude the element "v4" in variables for obj and eq1?

Alexander
  • 39
  • 6
  • Have a look here: https://stackoverflow.com/questions/69865630/removing-specific-equation-from-gams – Lutz Dec 27 '21 at 21:21

1 Answers1

1

There are several ways to achieve that, but this is good:

1- You can exclude the variables by defining a sub-set of allowed elements, like:

sets v2(v) /v1*v3/

2- Then, when defining equations, you can define those for example as follow in order to only include the elements in the sub-set previously defined.

Equations R1(m,v); R1(m,v)$v2(v)..#equation

In this way, the varaible v4 is not going to be included never in any of the variables. You can use that conditional format also inside a equation or a sum or in the objective function. You can also fix to 0 the oppossite variables like Q.fx(m,v)$(not v2(v))=0;

Of course, you can check the correct functioning of this in the .LST file.