0
$\begingroup$

I have an optimization problem in which a constraint should hold if the variable $x$ is inside the interval $[a,b]$. I assume you can model it by introducing a binary variable $z$ with $z=1$ if $x \in [a,b]$. So I would like to have something like

$$ x \in [a,b] \Rightarrow z=1 $$

Is there a way to model this with linear constraints or how would you model this in general?

$\endgroup$
2
$\begingroup$

The condition $$x \in [a,b] \Rightarrow z=1$$ can be reformulated as: $$z=0 \Rightarrow x<a \text{ or } x>b$$ This can be linearized using standard tools: $$\begin{align} & x \le a - 0.001 + M\delta + Mz\\ & x \ge b + 0.001 - M(1-\delta) - Mz\\ &\delta \in \{0,1\} \end{align} $$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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