2
$\begingroup$

I have a set of variables: $x_1,x_2,x_3,x_4$

$x_1$ is a binary integer variable while the rest are real numbers all between $0$ and $1$.

I want a constraint such that:

if $x_2+x_3+x_4>0$ then $x_1=1$,

and

if $x_2+x_3+x_4=0$ then $x_1=0$.

$\endgroup$

5 Answers 5

1
$\begingroup$

You can write $$x_1=-\left\lfloor -{x_2+x_3+x_4\over 3}\right\rfloor$$which is equivalent to the following linear constraints:$$-x_1\le -{x_2+x_3+x_4\over 3}<-x_1+1$$or equivalently$$-3x_1+x_2+x_3+x_4\le 0\\-3x_1+x_2+x_3+x_4>-3$$

$\endgroup$
0
$\begingroup$

This looks like a fixed cost problem, and it is easy to model if you have an objective function such as $$ Min \quad x_1 $$ If so, all you have to do is add the following constraint: $$ x_2+x_3+x_4\le x_1 \\ x_1 \in \{0,1\} $$

Indeed, if $x_2+x_3+x_4>0$, then necessarily you will have $x_1=1$. Otherwise, the objective function will "pull down" $x_1$ to $0$.

$\endgroup$
1
  • $\begingroup$ What about my answer? Also, what's up with the last line? I think your constraint applies only to the first statement ($x_2+x_3+x_4 > 0 \to x_1=1$)? $\endgroup$
    – BCLC
    May 11, 2016 at 17:45
0
$\begingroup$

You can think about it logically:

If $x_2 + x_3 + x_4 > 0$, then $x_1 = 1$

$\iff$

$x_2 + x_3 + x_4 = 0$ if $x_1 = 0$

$\iff$

$x_2 + x_3 + x_4 = 0$ or $x_1 = 1$

$\iff$

$x_2 = x_3 = x_4 = 0$ or $x_1 = 1$

$\iff$

$x_2 = x_3 = x_4 = 0$ or $x_1 = 1$

$\iff$

$[x_2 = 0 \ and \ x_3 = 0 \ and \ x_4 = 0]$ or $x_1 = 1$

$\iff$

$x_2 = 0 \ or \ x_1 = 1$

and

$x_3 = 0 \ or \ x_1 = 1$

and

$x_4 = 0 \ or \ x_1 = 1$

$\iff$

$1-x_2 = 1 \ or \ x_1 = 1$

and

$1-x_3 = 1 \ or \ x_1 = 1$

and

$1-x_4 = 1 \ or \ x_1 = 1$

$\iff$

$1-x_2 + x_1 \ge 1$

and

$1-x_3 + x_1 \ge 1$

and

$1-x_4 + x_1 \ge 1$

Alternative:

$$x_2+x_3+x_4 \le M(x_1)$$

Alternative:

What Kuifje said.


If $x_2 + x_3 + x_4 = 0$, then $x_1 = 0$

$\iff$

$x_2 + x_3 + x_4 > 0$ if $x_1 = 1$

$\iff$

$x_2 > 0 \ or \ x_3 > 0 \ or \ x_4 > 0$ if $x_1 = 1$

$\iff$

$x_2 > 0 \ or \ x_3 > 0 \ or \ x_4 > 0 \ or \ 1 - x_1 = 1$

$\iff$

$x_2 > 0 \ or \ x_3 > 0 \ or \ x_4 > 0 \ or \ 1 - x_1 > 0$

$\iff$

$x_2 + x_3 + x_4 + 1 - x_1 > 0$

$\iff$

$x_2 + x_3 + x_4 > x_1 - 1$

Alternative:

$$-(x_2+x_3+x_4) < M(1-x_1)$$


Don't forget

$$x_1 \in \{0,1\}$$

$$1 \ge x_2, x_3, x_4 \ge 0$$

$\endgroup$
0
$\begingroup$

According to you $x_1$ is a binary decision variable. So the constraints will look like this

[ $x_1$= \begin{cases} 1,& \text{if } x_2+x_3+x_4>0\\ 0, & \text{if } x_2+x_3+x_4 =0 \end{cases} ]

I think this constraint suitable for MILP.

$\endgroup$
0
$\begingroup$

Here is my suggestion. Let $0<a<1$ be a constant $$ \begin{align} x_2+x_3+x_4 \leq 3 x_1\\ x_2+x_3+x_4 \geq a x_1 \end{align} $$

This will work because:

  • if $x_2+x_3+x_4=0$ then $a x_1 \leq 0$. For $x_1 =1$, we have $a<0$ (contradiction due to $0<a<1$), thus $x_1 =0$.

  • if $x_2+x_3+x_4 \geq 1$ then $x_2 + x_3 + x_4\leq 3 x_1$. For $x_1 =0$, $x_2 +x_3 + x_4 \leq 0$, (contradiction due to $x_2+x_3+x_4 \geq 1$), thus $x_1=1$

$\endgroup$
4
  • 1
    $\begingroup$ What about my answer? Also, your answer seems to exclude certain possibilities like $x_2 = x_3 = x_4 = 0.0000000001$? $\endgroup$
    – BCLC
    May 11, 2016 at 17:48
  • $\begingroup$ which part is wrong? $\endgroup$
    – BCLC
    May 12, 2016 at 13:45
  • $\begingroup$ you've gotta be kidding me. Contrapositive? I triple checked $\endgroup$
    – BCLC
    May 12, 2016 at 15:00
  • $\begingroup$ why did you delete your comments? $\endgroup$
    – BCLC
    May 18, 2016 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .