Adding a combination of and + or operator constraint in Linear Programming

192 Views Asked by At

I have a list of paired variables(paired_list) like below and a resultant variable(my_res). paired_list = [[a,b],[c,d],[e,f],...].

Here a,b,c,d,e,f are also binary decision variables.

I have to set a constraint which is a combination of and and or operator as below

my_res = [(a and b) or (c and d) or (e and f)...].

How can I translate this into a ILP constraint?

1

There are 1 best solutions below

0
On

Assume $x$, $y$ and $z$ are binary variables.

  • For $z$ to be $x$ OR $y$ (inclusive or): $z\le x + y$; $z\ge x$; $z\ge y$.
  • For $z$ to be $x$ XOR $y$ (exclusive or): $z\le x + y$; $z\le 2 - (x + y)$; $z\ge x - y$; $z\ge y - x$.
  • For $z$ to be $x$ AND $y$: $z\ge x + y - 1$; $z\le x$; $z\le y$.