I have $3$ parameters $a_1,a_2,a_3$ and a variable $d$ and $3$ binary variables $b_1,b_2,b_3$ and a "result" variable $s$. How do I model constraints so that:
- If $d$ is between $0$ and $a_1$, then $s=1$
- If $d$ is between $a_1$ and $a_2$, then $s =$ ... complex calculation ...
- If $d$ is between $a_2$ and $a_3$, then $s = 0$
I have found a formulation that is as follows: \begin{align} a_1b_1 + a_2b_2 - d \le 0 \\ -a_1b_1 - a_2b_2 - a_3b_3 + d \le 0 \\ b_1 + b_2 + b_3 = 1 \end{align}
But if use this formulation in my model, the b-variables get calculated incorrectly. Does anyone see the reason why and/or has a better idea?