NO FRAMES

Class IloNumToNumSegmentFunction

Definition file: ilconcert/ilosegfunc.h
Piecewise linear function over a segment.

An instance of IloNumToNumSegmentFunction represents a piecewise linear function that is defined everywhere on an interval [xMin, xMax). Each interval [x1, x2) on which the function is linear is called a segment.

Note that if n is the number of segments of the function, the random access to a given segment (see the member functions IloNumToNumSegmentFunction::addValue, IloNumToNumSegmentFunction::getArea, IloNumToNumSegmentFunction::getValue, IloNumToNumSegmentFunction::setValue) has a worst-case complexity in O(log(n)).

Furthermore, when two consecutive segments of the function are co-linear, these segments are merged so that the function is always represented with the minimal number of segments.

See Also:

Constructor Summary
public IloNumToNumSegmentFunction(const IloEnv env, IloNum xmin=-IloInfinity, IloNum xmax=IloInfinity, IloNum dval=0.0, const char * name=0)
public IloNumToNumSegmentFunction(const IloEnv env, const IloNumArray x, const IloNumArray v, IloNum xmin=-IloInfinity, IloNum xmax=IloInfinity, const char * name=0)
public IloNumToNumSegmentFunction(const IloNumToNumStepFunction & numFunction)
Method Summary
public voidaddValue(IloNum x1, IloNum x2, IloNum v) const
public IloNumToNumSegmentFunctioncopy() const
public voiddilate(IloNum k) const
public IloNumgetArea(IloNum x1, IloNum x2) const
public IloNumgetDefinitionIntervalMax() const
public IloNumgetDefinitionIntervalMin() const
public IloNumgetMax(IloNum x1, IloNum x2) const
public IloNumgetMin(IloNum x1, IloNum x2) const
public IloNumgetValue(IloNum x) const
public voidoperator *=(IloNum k) const
public voidoperator+=(const IloNumToNumSegmentFunction fct) const
public voidoperator-=(const IloNumToNumSegmentFunction fct) const
public voidsetMax(const IloNumToNumSegmentFunction fct) const
public voidsetMax(IloNum x1, IloNum v1, IloNum x2, IloNum v2) const
public voidsetMax(IloNum x1, IloNum x2, IloNum v) const
public voidsetMin(const IloNumToNumSegmentFunction fct) const
public voidsetMin(IloNum x1, IloNum v1, IloNum x2, IloNum v2) const
public voidsetMin(IloNum x1, IloNum x2, IloNum v) const
public voidsetPeriodic(const IloNumToNumSegmentFunction f, IloNum x0, IloNum n=IloInfinity, IloNum dval=0) const
public voidsetPeriodicValue(IloNum x1, IloNum x2, const IloNumToNumSegmentFunction f, IloNum offset=0) const
public voidsetPoints(const IloNumArray x, const IloNumArray v) const
public voidsetSlope(IloNum x1, IloNum x2, IloNum v, IloNum slope) const
public voidsetValue(IloNum x1, IloNum x2, IloNum v) const
public voidshift(IloNum dx, IloNum dval=0) const
Constructor Detail

IloNumToNumSegmentFunction

public IloNumToNumSegmentFunction(const IloEnv env, IloNum xmin=-IloInfinity, IloNum xmax=IloInfinity, IloNum dval=0.0, const char * name=0)

This constructor creates a piecewise linear function that is constant. It is defined everywhere on the interval [xmin,xmax) with the same value dval.


IloNumToNumSegmentFunction

public IloNumToNumSegmentFunction(const IloEnv env, const IloNumArray x, const IloNumArray v, IloNum xmin=-IloInfinity, IloNum xmax=IloInfinity, const char * name=0)

This constructor creates a piecewise linear function defined everywhere on the interval [xmin, xmax) whose segments are defined by the two argument arrays x and v. More precisely, the size n of array x must be equal to the size of array v and, if the created function is defined on the interval [xmin,xmax), its values will be:


IloNumToNumSegmentFunction

public IloNumToNumSegmentFunction(const IloNumToNumStepFunction & numFunction)

This copy constructor creates a new piecewise linear function. The new piecewise linear function is a copy of the step function numFunction. They point to different implementation objects.


Method Detail

addValue

public void addValue(IloNum x1, IloNum x2, IloNum v) const

This member function adds v to the value of the invoking piecewise linear function everywhere on the interval [x1,x2).


copy

public IloNumToNumSegmentFunction copy() const

This member function creates and returns a new function that is a copy of the invoking function.


dilate

public void dilate(IloNum k) const

This member function multiplies by k the scale of x for the invoking piecewise linear function. k must be a nonnegative numeric value. More precisely, if the invoking function was defined over an interval [xMin,xMax), it will be redefined over the interval [k*xMin,k*xMax) and the value at x will be the former value at x/k.


getArea

public IloNum getArea(IloNum x1, IloNum x2) const

This member function returns the area of the invoking piecewise linear function on the interval [x1,x2). An instance of IloException is thrown if the interval [x1,x2) is not included in the definition interval of the invoking function.


getDefinitionIntervalMax

public IloNum getDefinitionIntervalMax() const

This member function returns the right-most point of the definition interval of the invoking piecewise linear function.


getDefinitionIntervalMin

public IloNum getDefinitionIntervalMin() const

This member function returns the left-most point of the definition interval of the invoking piecewise linear function.


getMax

public IloNum getMax(IloNum x1, IloNum x2) const

This member function returns the maximal value of the invoking piecewise linear function on the interval [x1,x2). An instance of IloException is thrown if the interval [x1,x2) is not included in the definition interval of the invoking function.


getMin

public IloNum getMin(IloNum x1, IloNum x2) const

This member function returns the minimal value of the invoking piecewise linear function on the interval [x1,x2). An instance of IloException is thrown if the interval [x1,x2) is not included in the definition interval of the invoking function.


getValue

public IloNum getValue(IloNum x) const

This member function returns the value of the function at point x.


operator *=

public void operator *=(IloNum k) const

This operator multiplies by a factor k the value of the invoking piecewise linear function everywhere on the definition interval.


operator+=

public void operator+=(const IloNumToNumSegmentFunction fct) const

This operator adds the argument function fct to the invoking piecewise linear function.


operator-=

public void operator-=(const IloNumToNumSegmentFunction fct) const

This operator subtracts the argument function fct from the invoking piecewise linear function.


setMax

public void setMax(const IloNumToNumSegmentFunction fct) const

This member function sets the value of the invoking piecewise linear function to be the maximum between the current value and the value of fct everywhere on the definition interval of the invoking function. The interval of definition of fct must be the same as that of the invoking piecewise linear function.


setMax

public void setMax(IloNum x1, IloNum v1, IloNum x2, IloNum v2) const

This member function sets the value of the invoking piecewise linear function to be the maximum between the current value and the value of the linear function:

x --> v1 + (x-x1)*(v2-v1)/(x2-x1) everywhere on the interval [x1, x2).


setMax

public void setMax(IloNum x1, IloNum x2, IloNum v) const

This member function sets the value of the invoking piecewise linear function to be the maximum between the current value and v everywhere on the interval [x1,x2).


setMin

public void setMin(const IloNumToNumSegmentFunction fct) const

This member function sets the value of the invoking piecewise linear function to be the minimum between the current value and the value of fct everywhere on the definition interval of the invoking function. The definition interval of fct must be the same as the one of the invoking piecewise linear function.


setMin

public void setMin(IloNum x1, IloNum v1, IloNum x2, IloNum v2) const

This member function sets the value of the invoking piecewise linear function to be the minimum between the current value and the value of the linear function:

x --> v1 + (x-x1)*(v2-v1)/(x2-x1) everywhere on the interval [x1,x2).


setMin

public void setMin(IloNum x1, IloNum x2, IloNum v) const

This member function sets the value of the invoking piecewise linear function to be the minimum between the current value and v everywhere on the interval [x1,x2).


setPeriodic

public void setPeriodic(const IloNumToNumSegmentFunction f, IloNum x0, IloNum n=IloInfinity, IloNum dval=0) const

This member function initializes the invoking function as a piecewise linear function that repeats the piecewise linear function f, n times after x0. More precisely, if f is defined on [xfpMin,xfpMax) and if the invoking function is defined on [xMin,xMax), the value of the invoking function will be:


setPeriodicValue

public void setPeriodicValue(IloNum x1, IloNum x2, const IloNumToNumSegmentFunction f, IloNum offset=0) const

This member function changes the value of the invoking function on the interval [x1,x2). On this interval, the invoking function is set to equal a repetition of the pattern function f with an initial offset of offset. The invoking function is not modified outside the interval [x1,x2). More precisely, if [min,max) denotes the definition interval of f, for all t in [x1,x2), the invoking function at t is set to equal f(min + (offset+t-x1)%(max-min))) where % denotes the modulo operator. By default, the offset is equal to 0.


setPoints

public void setPoints(const IloNumArray x, const IloNumArray v) const

This member function initializes the invoking function as a piecewise linear function whose segments are defined by the two argument arrays x and v.

More precisely, the size n of array x must be equal to the size of array v, and if the created function is defined on the interval [xmin,xmax), its values will be:


setSlope

public void setSlope(IloNum x1, IloNum x2, IloNum v, IloNum slope) const

This member function sets the value of the invoking piecewise linear function equal to f, associating for each x in [x1,x2) -> f(x) = v + slope * (x-x1).


setValue

public void setValue(IloNum x1, IloNum x2, IloNum v) const

This member function sets the value of the invoking piecewise linear function to be constant and equal to v on the interval [x1,x2).


shift

public void shift(IloNum dx, IloNum dval=0) const

This member function shifts the invoking function from dx to the right if dx > 0 or -dx to the left if dx < 0. It has no effect if dx = 0. More precisely, if the invoking function is defined on [xMin,xMax) and dx > 0, the new value of the invoking function is:

If dx < 0, the new value of the invoking function is: