| Overview | Group | Tree | Graph | Deprecated | Index | Concepts |
| How to Define a Piecewise Linear Function |
| Discontinuous Piecewise Linear Functions |
| Using IloPiecewiseLinear |
Some problems are most naturally represented by constraints over functions that are not purely linear but consist of linear segments. Such functions are sometimes known as piecewise linear.
To define a piecewise linear function in CPLEX, you need these components:
In other words, for a piecewise linear function of n breakpoints,
you need to know n+1 slopes. Typically, the breakpoints of a
piecewise linear function are specified as an array of numeric values.
The slopes of its segments are indicated as an array of numeric values as well.
The geometric coordinates of at least one point of the function must also
be specified. Then in CPLEX, those details are brought together
by the global function IloPiecewiseLinear.
Another way to specify a piecewise linear function is to give the slope of the first segment, two arrays for the coordinates of the breakpoints, and the slope of the last segment.
For examples of these ways of defining a piecewise linear function, see this topic in the CPLEX User's Manual.
Intuitively, in a continuous piecewise linear function, the endpoint of one segment has the same coordinates as the initial point of the next segment. There are piecewise linear functions, however, where two consecutive breakpoints may have the same x coordinate but differ in the value of f(x). Such a difference is known as a step in the piecewise linear function, and such a function is known as discontinuous.
Syntactically, a step is represented in this way:
By convention, a breakpoint belongs to the segment that starts at that breakpoint.
In CPLEX, a discontinuous piecewise linear function is also
represented as an instance of the class created by the global function
IloPiecewiseLinear.
For examples of discontinuous piecewise linear functions, see this topic in the CPLEX User's Manual.
Whether it represents a continuous or a discontinuous
piecewise linear function, an instance of the class created by the global
function IloPiecewiseLinear behaves like a
floating-point expression. That is, you may use it in a term
of a linear expression or in a constraint added to a model
(an instance of IloModel).