7
$\begingroup$

How to express a chain of boolean If-then as MIP such as:

If $(x_{10} \ge b_1$ and $x_{11} \le b_1)$ AND $(x_{20} \ge b_2$ and $x_{21} \le b_2)$... AND... then $y_1 = 1$ else $y_1 = 0$.

So basically, if constants are between values of different $x_0$ and $x_1$ (lower and upper bounds for every constant) then $y = 1$, if at least one constant is out of bound then $y = 0$. I need to maximize sum of all $y$.

$\endgroup$
1
  • $\begingroup$ AFAIK, some commercial solvers like CPLEX or GUROBI have had such capability to write such constraints directly in the static model. Would you see this link? $\endgroup$
    – A.Omidi
    Jan 21, 2020 at 5:40

1 Answer 1

7
$\begingroup$

Because you are maximizing the sum of $y$, as long as each $y$ appears in no other constraints, you can get by with enforcing only one direction of the implication, namely $$y_1=1\implies (x_{10}\ge b_1 \land x_{11}\le b_1 \land \dots).$$ You can do this with one big-M constraint for each inequality, where $\ell$ and $u$ are (constant) lower and upper bounds on $x$: \begin{align} b_1-x_{10}&\le (b_1-\ell_{10})(1-y_1)\\ x_{11}-b_1&\le (u_{11}-b_1)(1-y_1)\\ b_2-x_{20}&\le (b_2-\ell_{20})(1-y_1)\\ x_{21}-b_2&\le (u_{21}-b_2)(1-y_1)\\ &\dots \end{align}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.