This question is to query the solution provided by Erwin Kalvelagen to the post
and
(Sorry for not adding comments under the original posts since I don't have enough reputations to do so ...)
In Erwin Kalvelagen's solution, we can observe that $z = 0$ does guarantee that either $x<a$ or $x>b$. However, it does not guarantee that $z = 1$ leads to $x \in [a, b]$.
For example, considering when $x<a$, $z=1$, $\delta = 1$, the first inequality is $$x \leq a - 0.001 + M + M $$ which is correct.
The second inequality : $$ x \geq b + 0.001 - 0 - M $$
which is also correct (since $b - M$ is a very big negative number)
However, now the $x$ does NOT belong to the interval $[a, b]$, hence $z = 1$ is NOT an indicator to its belongingness.
Could someone help to address it? Or let me know where I am wrong?
Thank you very much!
You seem to additionally want $z=1 \Rightarrow x \in [a,b]$. This can be linearized as: $$\begin{align} & x \ge a - M(1-z)\\ & x \le b + M(1-z) \end{align} $$