If Condition Over Binary Variables

Problems with syntax of GAMS
Post Reply
Luqman Hakeem
User
User
Posts: 30
Joined: 4 years ago

If Condition Over Binary Variables

Post by Luqman Hakeem »

Hello everybody,
Hope everyone is fine.
I am currently facing a problem regarding 'if' condition over binary variables. I applied $ condition but it resulted in error.
Mathematically,
" if sum((p,q), Z(p,q,t) <126)
then sum(a, n(a,t)) = 0 "
Thanks in advance.
Manassaldi
User
User
Posts: 118
Joined: 7 years ago
Location: Rosario - Argentina

Re: If Condition Over Binary Variables

Post by Manassaldi »

Hi, you can try a bigM decomposition. You must define a new binary variable y(t).
I assume that Z(p,q,t) and n(a,t) are binary variables.

if y(t)=1 then sum((p,q), Z(p,q,t) <126 (that is, less than or equal to 125)
and
if y(t)=0 then sum((p,q), Z(p,q,t) is not <126 (that is, greater than or equal to 126)

So, if y(t)=1 then sum(a, n(a,t)) = 0

eq1(t).. sum((p,q), Z(p,q,t)) =l= 125 + M1*(1-y(t));
eq2(t).. sum((p,q), Z(p,q,t)) =g= 126 - M1*y(t);
eq3(t).. sum(a, n(a,t)) =l= M2*(1-y(t));

I think M1 = sum((p,q),1) and M2 = sum(a, 1) can work fine.

I did it fast so there may be mistakes. I hope it works for you.
Bye!
Post Reply