I have a modelling question. I want to model that if my varibale $x$ is in the interval $[a,b]$, where $a,b >0$, my indicator variable $X \in \{0,1\}$ should be 1 (if $x$ is not in $[a,b]$, the indicator variable can attain any value). I'm sure that this kind of problem is quite common in practice, but I couldn't really find anything.
What would be the best way to model this? I guess there are several formulations which model this constraint. Which would be the best regarding computation times? Do you know some papers/publications which cover this topic?
Best regards, ops
The implication $$ x\in[a,b] \Rightarrow y=1 $$ can be stated as $$ y=0 \Rightarrow x<a \text{ or } x >b$$
Traditionally we would formulate this as: $$\begin{align} &x \le a - 0.001 + M\delta + My\\ &x \ge b + 0.001 - M(1-\delta) -My\\ &\delta \in \{0,1\} \end{align}$$
where $M$ is a large enough constant. This was already answered (but not accepted) here conditional constraint: if $x \in [a,b] => z=1$.
Advanced solvers may support indicator constraints, SOS1 variables or even an or functionality directly.
A version without big-$M$'s but with indicator constraints and SOS1 variables can look like:
$$\begin{align} &y=0 \Rightarrow x \le a - 0.001 + s_1\\ &y=0 \Rightarrow x \ge b + 0.001 - s_2 \\ & s_1, s_2 \ge 0\\ & \text{SOS}1(s_1,s_2) \end{align}$$
The SOS1 set will make sure that only one of the slack variables $s_1, s_2$ will be non-zero. In other words,
$$ s_1 \cdot s_2 = 0$$
Note that I typically drop these $0.001$ terms.