2
$\begingroup$

I have trouble finding a solution to the following problem. I have a decision variable $x$. If the value of $x$ is between 0 and a constant $A$, then the binary variable $y_1$ must be equal to 1. If $x$ is greater than $A$ but lower than another constant $B$, then the binary variable $y_2$ must be equal to 1 while the $y_1$ must be equal to 0. If $x$ goes above $B$, the binary variable $y_3$ must be equal to 1 while $y_1$ and $y_2$ must be equal to 0.

I tried using the Big $M$ method as follows:

$$x \le Ay_1 \tag{1}$$

The problem here is that if $x$ goes above $A$ then $x$ is infeasible. Then I created three new decision variables $x_1$, $x_2$, and $x_3$ that could "follow" $x$ for a certain amount:

$$x = (x_1 y_1)+(x_2 y_2)+(x_3 y_3) \tag{2}$$

$$ x_1 \le A y_1 \tag{1}$$

$$ x_2 \ge A y_2 \tag{3}$$

$$ x_2 \le B y_2 \tag{4}$$

$$ x_3 \ge B y_3 \tag{5} $$

This does not work: the solver tells me it is infeasible. I'm using OpenSolver in Excel. How can I resolve this?

$\endgroup$
7
$\begingroup$

There is some ambiguity about the strictness of above/beneath, but does the following do what you want? $$ 0y_1 + Ay_2 + By_3 \le x \le Ay_1 + By_2 + Cy_3 \\ y_1 + y_2 + y_3 = 1 $$ Checking, we have: \begin{align} y_1 = 1 &\implies x \in [0,A] \\ y_2 = 1 &\implies x \in [A,B] \\ y_3 = 1 &\implies x \in [B,C] \\ \end{align}

$\endgroup$
2
  • $\begingroup$ Hi Rob! many thanks for the quick response. It works great for y1 and y2 but the moment I go above y3 it turns infeasable.. I'm trying to figure out why.. $\endgroup$ – wlans Nov 11 '20 at 18:43
  • $\begingroup$ I've made a cte C and made that the max for when y3 was 1. now it works! $\endgroup$ – wlans Nov 11 '20 at 19:02

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.