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.


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}

  • $\begingroup$ 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 ? $\endgroup$
    – S_Scouse
    Mar 17 '20 at 21:30
  • $\begingroup$ By "parameter" do you mean a decision variable or a constant? $\endgroup$
    – RobPratt
    Mar 17 '20 at 21:41
  • $\begingroup$ Constant (a set of constant values), not a decision variable. Also, b is a single constant. $\endgroup$
    – S_Scouse
    Mar 17 '20 at 22:05
  • $\begingroup$ 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$. $\endgroup$
    – RobPratt
    Mar 17 '20 at 22:24

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.