Answers to: How to linearise variable2=Max(0,variable1) ?http://www.or-exchange.com/questions/12520/how-to-linearise-variable2max0variable1<p>Hello,</p>
<p>I am trying to linearise this equation :</p>
<p>variable2=Max(0,variable1)</p>
<p>but when I try to do this introducing a binary variable I always end with BinaryVariable*variable1 that is not linear...</p>
<p>Do you have any solution ?</p>
<p>Thanks,</p>enTue, 23 Jun 2015 16:27:12 -0400Answer by Slavkohttp://www.or-exchange.com/questions/12520/how-to-linearise-variable2max0variable1/12524<p>If \(y_1,y_2\) are binary and \(M\) is enough big then linear constraints are as follows.</p>
<p>\[
\begin{cases}
& -M\cdot y_1 \leq variable2 \leq M\cdot y_1 \\
& -M\cdot y_2 \leq variable2 - variable1 \leq M\cdot y_2 \\
& -M(1-y_1) \leq variable1 \leq M(1-y_2) \\
& y_1+y_2 =1
\end{cases}
\]</p>SlavkoTue, 23 Jun 2015 16:27:12 -0400http://www.or-exchange.com/questions/12520/how-to-linearise-variable2max0variable1/12524Answer by youkierhttp://www.or-exchange.com/questions/12520/how-to-linearise-variable2max0variable1/12521<p>Humm... sorry I don't know why I ended with a non linear model...</p>
<p>The solution is quite a classic one :</p>
<p>A=max(0,B)
<=> </p>
<p>A>=0;
A>=B ; A <= B + yM ; A<= (1-y)M with y a bineary variable and M big enough...</p>youkierTue, 23 Jun 2015 10:46:22 -0400http://www.or-exchange.com/questions/12520/how-to-linearise-variable2max0variable1/12521