# Best way to model piecewise linear constraint for LP?

 0 I'm working on the LP model for a hydro power generation problem, one constraint is piecewise linear, for example, xi - xi-1 <= xi-1 - 951 if xi-1 >= 951 and xi-1 <= 953 xi - xi-1 <= 2 if xi-1 > 953 and xi-1 <= 955 xi - xi-1 <= xi-1 - 953 if xi-1 > 955 and xi-1 <= 956 ... 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? Thanks, Enzhou asked 22 Aug '13, 19:21 Enzhou 1●1●1●1 accept rate: 0% fbahr ♦ 4.6k●7●16

 4 I'd start with these two blog posts by Paul Rubin Piecewise-linear Functions in Math Programs Piecewise-linear Functions Redux answered 23 Aug '13, 04:23 jfpuget 2.5k●3●10 accept rate: 8% Thanks! That's very helpful. Enzhou (23 Aug '13, 11:42) Enzhou Thanks for the plug! :-) (23 Aug '13, 15:29) Paul Rubin ♦♦
 0 Have you tried with GAMS? answered 09 Nov '16, 00:41 patrijuvet 11●1 accept rate: 0%
 0 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 answered 09 Nov '16, 02:19 Mark L Stone 447●3●10 accept rate: 15%
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags: