Piecewise linear and stepwise functions

Describes piecewise linear and stepwise functions as related to scheduling.

In CP Optimizer, piecewise linear functions are typically used to model a known function of time, for instance the cost incurred for completing an activity after a known date t. Stepwise functions are typically used to model the efficiency of a resource over time.

A piecewise linear function F(t) is defined by a tuple F = piecewise(S, T, t0, v0) where:

pwl_func

For a complete description of the OPL syntax of a piecewise linear function, see piecewise and pwlFunction in the OPL Language Quick Reference.

A stepwise function is a special case of the piecewise linear function, where all slopes are equal to 0 and the domain and image of F are integer. A stepwise function F(t) is defined by a tuple F = stepwise(V, T) where:

sw_func

For a complete description of the OPL syntax of a stepwise linear function, see stepwise and stepFunction in the OPL Language Quick Reference.

Examples

  • A V-shape function with value 0 at x = 10, slope −1 before x = 10 and slope s afterwards:

    pwlFunction F1 = piecewise{ -1->10; s } (10, 0);

  • An array of V-shaped functions indexed by i in [1..n] with value 0 at T[i], slope −U[i] before T[i] and slope V [i] afterwards (T, U and V are data integer arrays):

    pwlFunction F[i in 1..n] = piecewise{ -U[i]->T[i]; V[i] } (T[i],0);

  • A stepwise function with value 0 before 0, 100 on [0, 20), value 60 on [20, 30), and value 100 later on:

    stepFunction F2 = stepwise{ 0->0; 100->20; 60->30; 100 };

  • A stepwise function with value 0 everywhere except on intervals [7i, 7i+5) for i in [0, 51] where the value is 100:

    stepFunction F3 = stepwise(i in 0..51, p in 0..1) { 100*p -> (7*i)+(5*p) ; 0 };

The previous piecewise and stepwise function are depicted in the following diagram.

functions