FRAMES NO FRAMES

IlcPiecewiseLinear

public IlcFloatExp IlcPiecewiseLinear(IlcFloatVar x, IlcFloatArray point, IlcFloatArray slope, IlcFloat a, IlcFloat fa)
Definition file: ilsolver/ilcsegfn.h
Include file: <ilsolver/ilosolver.h>

The function IlcPiecewiseLinear creates a floating point expression to represent a continuous or discontinuous piecewise linear function f of the variable x. The array point contains the n breakpoints of the function such that point [i-1] point [i] for i = 1, . . ., n-1. The array slope contains the n+1 slopes of the n+1 segments of the function. The values a and fa must be coordinates of a point such that fa = f(a).

When point[i-1] = point[i], there is a step at the x-coordinate point [i-1], and its height is slope [i-1].

When appearing in a constraint posted to Solver, this expression always has the smallest possible interval with respect to the interval of x and conversely.

Example

The expression

 IlcPiecewiseLinear(x, IlcFloatArray(solver, 2, 10., 20.),
                       IlcFloatArray(solver, 3, 0.3, 1., 2.),
                       0, 0);
 

defines a piecewise linear function f having two breakpoints at x = 10 and x = 20, and three segments with slopes 0.3, 1, and 2. The first segment has infinite length and ends at the point x = 10, f(x) = 3 since f(0) = 0. The second segment starts at the point x = 10, f(x) = 3 and ends at the point x = 20, f(x) = 13 where the third segment starts.