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?
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} $$