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?
-
$\begingroup$ If x3 and x4 are not binaries then use comparisons blog.adamfurmanek.pl/2015/09/12/ilp-part-4 Then use material implication and exclusive or blog.adamfurmanek.pl/2015/08/22/ilp-part-1 $\endgroup$user1543037– user15430372021年04月01日 06:19:10 +00:00Commented Apr 1, 2021 at 6:19
-
$\begingroup$ All x1, x2, x3 and x4 are binary variables. $\endgroup$Nishant Jalasutram– Nishant Jalasutram2021年04月01日 07:23:49 +00:00Commented Apr 1, 2021 at 7:23
-
$\begingroup$ The material implication is enough. $\endgroup$user1543037– user15430372021年04月01日 10:14:37 +00:00Commented Apr 1, 2021 at 10:14
1 Answer 1
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$.