I have following problem:

$c_i = 1$ if $X + \sum_j^N G_j = T$ else $c_i = 0$

Also there is another constraint which upper bounds equation $X + \sum_j^N G_j \le T$.

  • $c_i$ is binary

  • $X, T$ are constant

  • $G_j$ is continuous.

My attempt:

\begin{align}c_i &\ge 1 - M\left(X + \sum_j^N G_j -T\right)\\c_i &\le 1 + M \left(X + \sum_j^N G_j -T\right)\end{align}

This enforces the binary variable to get value $1$. For $0$, I reduced $T$ to $T-\delta$, where $\delta$ is a very small value

$$c_i \le X + \sum_j^N G_j - (T - \delta) \text{ (This is where I need help for $c_i = 0$)}.$$

Since my objective function is $\max\sum_i c_i$, it is necessary for zero condition of $c_i$ to be tight.


1 Answer 1


Let $L$ be a constant lower bound on $X + \sum_j^N G_j$. You want $$X + \sum_j^N G_j \in [L,T-\delta] \cup [T,T]$$ with $c_i=0$ for the first interval and $c_i=1$ for the second (single-point) interval. You can enforce that with the following linear constraints: $$L(1-c_i)+T c_i \le X + \sum_j^N G_j \le (T-\delta)(1-c_i)+T c_i$$


Your Answer

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

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