MIP binary variable value based on value of continuous variable

768 Views Asked by At

I would like to model the following constraint: $$ b = \begin{cases} 1 \quad \text{if } c=0 \\ 0 \quad \text{if } c>0 \\ \end{cases}, $$ where $b\in\{0,1\}$ and $c\in\mathbb{R}_{\geq0}$.

The context of this problem: $c$ represents the idle time between two successive operations on a machine. Instead of capturing the duration of this idle time, I would only like to know whether there was idle time ($b=1$) or not ($b=0$).

So far, I only found related posts that assume that $c$ is a binary variable as well, see e.g. here.

Edit:

In case I know that $c\leq C$ and given that I maximize over $b$, I can express this by the single constraint $$ b\leq (1-\frac{c}{C}). $$ To see this:

  • In case $c=0$, we get $b\leq 1$. Since we maximize, this will lead to $b=1$.
  • In case $c>0$, we get that $0\leq b<1$, which is only satisfied for $b=0$.

Question:

However, is there also a way to model this constraint without implicitly using the fact that we maximize over $b$ and without using an upperbound $C$ on $c$?

2

There are 2 best solutions below

1
On BEST ANSWER

As noted, the strict inequality causes problems, meaning you cannot model what you want exactly (using linear constraints and binary variables). There are two approaches that may come close enough, depending on context. Both require a valid upper bound $C$ for $c$.

First, $0\le c \le C(1-b)$. If $c>0$, this forces $b=0$ as desired. If $c=0$, though, both $b=0$ and $b=1$ satisfy the constraint.

Alternatively, $\epsilon (1-b) \le c \le C(1-b)$ with $\epsilon > 0$ a small constant enforces $c = 0 \implies b=1$ and $c\ge \epsilon \implies b=0$. Unfortunately, it renders $0 < c < \epsilon$ infeasible. When using this approach, it is tempting to pick a really, really tiny positive value for $\epsilon$, but that will not work due to rounding problems (it will look like 0 to the solver and put you back in the first case).

1
On

The set $$ \{(b,c) \mid b \in \{0,1\} \land \text{"your condition"}\}$$ is not closed. Hence, it is not possible to model it as a 'nice' constraint.