Answers to: Best way to model piecewise linear constraint for LP?http://www.or-exchange.com/questions/8406/best-way-to-model-piecewise-linear-constraint-for-lp<p>I'm working on the LP model for a hydro power generation problem, one constraint is piecewise linear, for example,<br>
x<sub>i</sub> - x<sub>i-1</sub> <= x<sub>i-1</sub> - 951 if x<sub>i-1</sub> >= 951 and x<sub>i-1</sub> <= 953 <br>
x<sub>i</sub> - x<sub>i-1</sub> <= 2 if x<sub>i-1</sub> > 953 and x<sub>i-1</sub> <= 955 <br>
x<sub>i</sub> - x<sub>i-1</sub> <= x<sub>i-1</sub> - 953 if x<sub>i-1</sub> > 955 and x<sub>i-1</sub> <= 956 <br>
...<br>
One way I can think of is to solve the problem multiple times with each piece of the piecewise linear constraint and pick the optimal one. But the model is big and needs to be solved as fast as possible every hour, so I can't really do that. Currently I'm doing a linear approximation, but is there a better way to model it?</p>
<p>Thanks,<br>
Enzhou</p>enWed, 09 Nov 2016 02:19:34 -0500Answer by Mark L Stonehttp://www.or-exchange.com/questions/8406/best-way-to-model-piecewise-linear-constraint-for-lp/14380<p>Piecewise linear functions falls under "etc"
https://www.or-exchange.org/questions/14268/half-the-questions-on-this-board-could-be-eliminated-if-there-were-an-faq-directing-people-to-automated-software-for-linearizing-constraints-conditional-constraints-big-m-etc</p>Mark L StoneWed, 09 Nov 2016 02:19:34 -0500http://www.or-exchange.com/questions/8406/best-way-to-model-piecewise-linear-constraint-for-lp/14380Answer by patrijuvethttp://www.or-exchange.com/questions/8406/best-way-to-model-piecewise-linear-constraint-for-lp/14379<p>Have you tried with GAMS?</p>patrijuvetWed, 09 Nov 2016 00:41:23 -0500http://www.or-exchange.com/questions/8406/best-way-to-model-piecewise-linear-constraint-for-lp/14379Comment by Paul Rubin on jfpuget's answerhttp://www.or-exchange.com/questions/8406/best-way-to-model-piecewise-linear-constraint-for-lp#8418<p>Thanks for the plug! :-)</p>Paul RubinFri, 23 Aug 2013 15:29:21 -0400http://www.or-exchange.com/questions/8406/best-way-to-model-piecewise-linear-constraint-for-lp#8418Comment by Enzhou on jfpuget's answerhttp://www.or-exchange.com/questions/8406/best-way-to-model-piecewise-linear-constraint-for-lp#8416<p>Thanks! That's very helpful.</p>
<p>Enzhou</p>EnzhouFri, 23 Aug 2013 11:42:10 -0400http://www.or-exchange.com/questions/8406/best-way-to-model-piecewise-linear-constraint-for-lp#8416Answer by jfpugethttp://www.or-exchange.com/questions/8406/best-way-to-model-piecewise-linear-constraint-for-lp/8410<p>I'd start with these two blog posts by Paul Rubin
<a href="http://orinanobworld.blogspot.fr/2010/10/piecewise-linear-functions-in-math.html">Piecewise-linear Functions in Math Programs</a>
<a href="http://orinanobworld.blogspot.fr/2011/08/piecewise-linear-functions-redux.html">Piecewise-linear Functions Redux</a></p>jfpugetFri, 23 Aug 2013 04:23:53 -0400http://www.or-exchange.com/questions/8406/best-way-to-model-piecewise-linear-constraint-for-lp/8410