1
$\begingroup$

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
281k27 gold badges317 silver badges515 bronze badges
asked Apr 1, 2021 at 3:40
$\endgroup$
3
  • $\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$ Commented Apr 1, 2021 at 6:19
  • $\begingroup$ All x1, x2, x3 and x4 are binary variables. $\endgroup$ Commented Apr 1, 2021 at 7:23
  • $\begingroup$ The material implication is enough. $\endgroup$ Commented Apr 1, 2021 at 10:14

1 Answer 1

2
$\begingroup$

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$.

answered Apr 1, 2021 at 8:43
$\endgroup$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.