Skip to main content
FRAMES NO FRAMES

Piecewise Linearity in CPLEX
PREVIOUS NEXT
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.

How to Define a Piecewise Linear Function

To define a piecewise linear function in CPLEX, you need these components:

  • the variable of the piecewise linear function;
  • the breakpoints of the piecewise linear function;
  • the slope of each segment (that is, the rate of increase or decrease of the function between two breakpoints);
  • the geometric coordinates of at least one point of the function.

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.

Discontinuous Piecewise Linear Functions

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:

  • The value of the first point of a step in the array of slopes is the height of the step.
  • The value of the second point of the step in the array of slopes is the slope of the function after the step.

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.

Using IloPiecewiseLinear

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).

PREVIOUS NEXT