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.

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!