0
$\begingroup$

I have been trying to enforce the following conditional statement in a MILP:

If $X_1 + 2(X_2 + X_3) = 4$, then $X_4 = 1$.

where $X_1, X_2, X_3, X_4$ are binary. How can I write this in conventional constraints, so that I could use a MILP solver?

Best regards, Hans

$\endgroup$
4
  • $\begingroup$ Are $X_1, X_2, X_3, X_4$ integer variables or continuous variables? $\endgroup$ Commented Dec 13, 2022 at 16:03
  • $\begingroup$ they are binary! $\endgroup$ Commented Dec 13, 2022 at 16:08
  • $\begingroup$ It depends on the objective function and if it has to maximized or minimized. An isolated constraint alone makes it more complicated that it has to be. The constraints and the objective function are not independent from each other. $\endgroup$ Commented Dec 13, 2022 at 17:29
  • $\begingroup$ The objective function is a weighted sum of the 'X_i' 's and needs to be minimized, Something like '\sum_{i=1}^{27}' 'a_i' 'X_i' 's where 'a_i' 's are positive. $\endgroup$ Commented Dec 13, 2022 at 17:41

2 Answers 2

1
$\begingroup$

If they are all binary, the only way $X_1 + 2 (X_2 + X_3) = 4$ is $X_1 = 0$, $X_2 = X_3 = 1$. So your constraint could be $$-X_1 + X_2 + X_3 - X_4 \le 1$$

$\endgroup$
1
$\begingroup$

As @RobertIsrael noted, your proposition is equivalent to $$(\lnot X_1 \land X_2 \land X_3) \implies X_4.$$ Rewriting in conjunctive normal form yields $$ \lnot (\lnot X_1 \land X_2 \land X_3) \lor X_4 \\ X_1 \lor \lnot X_2 \lor \lnot X_3 \lor X_4 \\ X_1 + (1 - X_2) + (1 - X_3) + X_4 \ge 1 \\ X_1 - X_2 - X_3 + X_4 \ge -1 $$

$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.