I am a newcomer to mixed integer linear programming, and I am having some trouble using the Big M method to linearize some constraints, and was wondering if I implementing it incorrectly.
Here is what I want to do: $$ y_{i-1} + x_{i-1}\cdot Eff==y_i\quad when \;x\ge0$$ $$ y_{i-1} + x_{i-1}\cdot \frac 1{Eff}==y_i\quad when \;x\lt0$$
In order to linearize this constraint, I added a binary indicator variable and used the Big M method, converting this to 6 constraints.
These first two would force $B_i=1$ when $x_{i-1}\ge0$ and $B_i=0$ when $x_{i-1}\lt0$ using a big enough M:
$$ x_{i-1} + M \cdot (1-B_i) \ge 0$$ $$ x_{i-1} + M \cdot B_i \lt 0$$
Then I divided each of the equality constraints into two inequality constraints each, using the big M and the binary variable $B_i$ to remove the constraints that are not applicable. I figured this would force only one of the greater than/less than sets of equations to be a true constraint:
$$ y_{i-1} + x_{i-1}\cdot Eff + M \cdot (1-B_i)\ge y_i$$ $$ y_{i-1} + x_{i-1}\cdot Eff - M \cdot (1-B_i) \le y_i$$
$$ y_{i-1} + x_{i-1}\cdot \frac 1{Eff}+ M \cdot B_i \ge y_i$$ $$ y_{i-1} + x_{i-1}\cdot \frac 1{Eff} - M \cdot B_i \le y_i$$
However, when I run the actual code of this model, the general constraint $y_{i-1} + x_{i-1}\cdot Eff==y_i$ is not being followed, and I think it must be the way I am implementing the big M methodology. Can anyone tell if what I am doing is incorrect? Thanks! (apologies for mistakes, I'm new to all this)