Piecewise-Linear Functions via SOS Variables
Model a piecewise-linear function in a mixed-integer program by introducing a weight per breakpoint and forcing the weights to form a Special Ordered Set of Type 2 (SOS2). The SOS2 condition is encoded with binary segment indicators and disjunctive Big-M-style linking inequalities.
Tutorial
Piecewise-Linear Functions and the Lambda Representation
A piecewise-linear (PWL) function is specified by a sequence of breakpoints with , connected by straight line segments. On the segment , the graph is the line through and .
Any point on the graph lies on exactly one segment and can be written as a convex combination of its two endpoints. If , then for ,
To prepare for a MIP encoding, introduce nonnegative weights — one per breakpoint — and write
Setting , , and all other recovers the segment formula.
For example, with breakpoints and : since , , so , , and .