Can anyone help me code this problem in GAMS?

x, y, z are variable

if x>0 and y>0;

y=x+y;

Such a condition does not make sense in an optimization problem as an optimization problem is solved as a whole and not as sequential set of commands. Therefore, y = x + y is an incorrect way to think if you are talking about variable values before solving optimization. However, if you want to set solved value of y to x.l + y.l, it is easy.

On the other hand, if you want some other variable z = x + y when x and y > 0 then this can be achieved by introducing binary variables and big-M constraints.

- Atharv

Can you help me to code it in GAMS with binary variables and BigM?

Let’s say you want z = x + y when x > 0 and y > 0 and you would want z = 0 otherwise.

You can do this using following logic. Define x1 which is 0 when x is negative and x when x is non-negative. Similarly, we define y1.

x1= max(0, x)

y1 = max(0, y)

To do this, you write constraints x1 =g= 0 and x1 =g= x

similarly, y1 =g= 0 and y1 =g= y

You can then use x1 and y1 to define z

z =e= x1 + y1

Hope this helps.

- Atharv

thank you very much