Syntax of piecewise linear functions
Describes the syntax to represent a piecewise linear function.
To define a piecewise linear function in Concert Technology, you need these components:
the independent 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. For example, the breakpoints
of the function f(x) as it appears in Figure 1 are specified
in this way, where the first argument, env ,
specifies the environment, the second argument specifies the number
of breakpoints under consideration, and the remaining arguments specify
the x-coordinate of the breakpoints:
IloNumArray (env, 3, 4., 5., 7.)
The slopes of its segments are indicated as an array
of numeric values as well. For example, the slopes of f(x)
are specified in this way, where the first argument again specifies
the environment, the second argument specifies the number of slopes
given, and the remaining arguments specify the slope of the segments:
IloNumArray (env, 4, -0.5, 1., -1., 2.)
The geometric coordinates of at least one point of the
function, (x, f(x)) must also be
specified; for example, (4, 2) . Then
in Concert Technology, those elements are brought together in an instance
of the class IloPiecewiseLinear in this
way:
IloPiecewiseLinear(x,
IloNumArray(env, 3, 4., 5., 7.),
IloNumArray(env, 4, -0.5, 1., -1., 2.),
4, 2)
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. In this approach,
the example f(x) from Figure 1 looks like
this:
IloPiecewiseLinear(x, -0.5, IloNumArray(env, 3, 4., 5., 7.),
IloNumArray(env, 3, 2., 3., 1.), 2);
It may help you understand the signatures of these functions to recall the familiar Cartesian representation of a line or segment in two dimensions, x and y:
y = ax + b
where a represents the slope of the line or segment and b represents the height at which the line theoretically crosses the y-axis at the point (0, b).