Skip to main content

## Comments

1 comment

• Gurobi Staff

Yes, you can model logic like this using indicator constraints. For example, consider the conditional statement

\begin{align*}x + y \geq 1 &\implies z \geq 1.\end{align*}

First, we create a new binary variable $$w$$. Then, the above is equivalent to

\begin{align*} x + y \geq 1 &\implies w = 1 \\ w = 1 &\implies z \geq 1.\end{align*}

Indicator constraints must be of the form

\begin{align*}\textrm{binary variable equals } 0 \textrm{ or } 1 &\implies \textrm{some constraint.}\end{align*}

So, we can re-write the first conditional statement $$x + y \geq 1 \implies w = 1$$ with its logically equivalent contrapositive: $$w = 0 \implies x + y < 1$$. Strict inequalities aren't allowed in a math programming framework, but we can closely approximate this constraint with $$x + y \leq 1 - \epsilon$$ for some small $$\epsilon > 0$$. Note that we can use $$\epsilon = 1$$ if $$x$$ and $$y$$ are both integer variables.

Altogether, we add the following two indicator constraints:

\begin{align*} w = 0 &\implies x + y \leq 1 - \epsilon \\ w = 1 &\implies z \geq 1.\end{align*}

Alternatively, you can model this logic yourself without using indicator constraints. E.g., if $$z \geq 0$$, then the conditional statement $$w = 1 \implies z \geq 1$$ is equivalent to $$z \geq w$$.

Please sign in to leave a comment.