Skip to main content
FRAMES NO FRAMES

IloPiecewiseLinearFunction

public IloNumToNumSegmentFunction IloPiecewiseLinearFunction(const IloEnv env, const IloNumArray point, const IloNumArray slope, IloNum a, IloNum fa, const char * name=0)
Definition file: ilconcert/ilosegfunc.h
Returns a piecewise linear function.

This member function builds an instance of piecewise linear function defined everywhere on the interval [-IloInfinity, IloInfinity). 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] to reach the y-coordinate of point[i].

Example

   IloPiecewiseLinearFunction(env, IloNumArray(env, 2, 10., 20.),
                                   IloNumArray(env, 3, 0.3, 1., 2.),
                                   0, 0);
 

That expression defines a piecewise linear function f having two breakpoints at x = 10 and x = 20, and three segments; their slopes are 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.