1

Express the condition "$x = 0$ if and only if $y = 0$" as a set of linear constraints, where $x,y$ are integers such that $ - 5 \le x \le 8$ and $0 \le y \le 1$

user_777
  • 142
  • 6

2 Answers2

1

Let us instead translate $x=0 \leftrightarrow y=0$ into disjunctive normal form. We would get

$$ (x=0 \wedge y=0 ) \vee (x>0 \wedge y=1) \vee (x<0 \wedge y=1) $$

Each conjunction is a linear constraint.

In your solution you assumed that the constraint $y=1 \vee x=0$ is always true. In fact $y=1 \vee y=0$ is always true, since this is the domain of $y$.

If you kept this constraint, you would have eliminated solutions where $y=0$ and $x \not= 0$.

Another issue is with your interpretation of the constraints. The pair $$ \begin{array}{c} -M < x < 0\\ y=0 \end{array} $$ is a set of two constraints not a single constraint, therefore it is satisfied by the following 19 pairs $(-5,0),...,(8,0),(-5,1),...,(-1,1)$. The first 14 pairs clearly violate the condition $x=0 \leftrightarrow y=0$.

Dima Chubarov
  • 1,429
  • 8
  • 17
1

I have managed to solve this problem:

So we must apply integer programming to satisfy logical condition: $$(x \ne 0 \vee y = 0) \wedge (y \ne 0 \vee x = 0)$$

The encoding i got $${M_1}y \le x \le {M_2}y \cup {M_3}y \le x \le {M_4}y{\text{ }}$$

Now set $${M_1} = - 5,\,{M_2} = - 1,\,{M_3} = 1,\,{M_4} = 8$$

The encoding becomes $$-5y \le x \le -y \cup y \le x \le 8y{\text{ }}$$

The logical condition implies when $y = 0$, the value of $x = 0$. When $y = 1$, the value of $x \in [ - 5, - 1] \cup [1,8]$. If fact, when $y = 1$, integer variable $x$ can take on any value from $( - \infty , - 1] \cup [1,\infty )$. Hence we must provide an encoding that will force $x$ to take all values from its domain excluding $0$.

Case $y = 0$:

The encoding results in $0 \le x \le 0$, which forces $x = 0$

Case $y = 1$:

The encoding results in $$ - 5 \le x \le - 1 \cup 1 \le x \le 8$$

Thus, depending on $y = \{ 0,1\} $ a program can assign $x$ any value from its domain.

user_777
  • 142
  • 6