5

I have an if else condition as follows: If $g \ge 0$ then $e=1$, else $e=b$.

I formulated MIP constraints using big-M as follows where I am setting $\delta=1$ if $g \ge 0$:

\begin{alignat}2g &\ge -M(1-\delta)\tag1\\g &\le M\delta\tag2\\1-M(1-\delta) &\le e \le 1+M(1-\delta)\tag3\\b-M\delta &\le e \le b+M\delta\tag4\end{alignat}

My question is if the formulation is correct, especially the first equation.

S_Scouse
  • 803
  • 3
  • 11

1 Answers1

6

Looks correct, but there is the usual ambiguity at the boundary: $g=0$ allows either $e$ value. Also, if $b$ is a constant, you can simplify by replacing (3) and (4) with a single equality: $$e=1\delta+b(1-\delta)$$ Note that the best values of $M$ in (3) and (4) yield this equality. Explicitly: \begin{align} 1-(1-b)(1-\delta) &\le e \le 1+(b-1)(1-\delta) \tag3\\ b-(b-1)\delta &\le e \le b+(1-b)\delta &&\tag4 \end{align}

RobPratt
  • 32,006
  • 1
  • 44
  • 84
  • Follow up question, if g is a parameter with set of values in this case, does big M formulation apply? If not, what can be done to convert the if else to constraints ? – S_Scouse Mar 17 '20 at 21:30
  • By "parameter" do you mean a decision variable or a constant? – RobPratt Mar 17 '20 at 21:41
  • Constant (a set of constant values), not a decision variable. Also, b is a single constant. – S_Scouse Mar 17 '20 at 22:05
  • If $g$ and $b$ are constants, you do not need to introduce $\delta$, impose big-M constraints, or call any solver. The value of $e$ is already completely determined once you know $g$ and $b$. – RobPratt Mar 17 '20 at 22:24