1

There are four variables: $x_1, x_2, x_3, x_4$.

If you choose either $x_3$ or $x_4$ or both — then you should choose exactly one of $x_1$ or $x_2$.

If you choose neither $x_3$ or $x_4$ — then there is no restriction in choosing $x_1$ or $x_2$.

I have come up with the following if else logic for this, but cannot proceed from there.

If $x_3+x_4 = 0$ then $x_1 + x_2 \ge 0$

If $x_3 + x_4 \ge 1$ then $x_1 + x_2 = 1$

Can you let me know how to come up with an integer linear program with this understanding?

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503

1 Answers1

2

Every logical formula can be converted to conjunctive normal form (CNF), that is, into a conjunction (AND) of clauses (OR). In turn, a clause $\ell_1 \lor \cdots \lor \ell_m$ can be expressed as the constraint $\ell_1 + \cdots + \ell_m \geq 1$. In this way, you can express any logical condition in an integer program.

As an example, consider the logical formula $x \oplus y$, that is, exactly one of $x,y$ is true. While it can be expressed directly as $x + y = 1$, let's see how to do it using CNF. Putting it into CNF, we get $(x \lor y) \land (\lnot x \lor \lnot y)$. Therefore we add the following constraints: $x + y \geq 1$ and $(1-x) + (1-y) \geq 1$, i.e., $-x-y \geq -1$.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503