Class IntStepFunction
- Namespace
- OptalCP
- Assembly
- OptalCP.dll
Piecewise-constant function mapping time to integers, used for costs and availability windows.
public class IntStepFunction : ModelElement
- Inheritance
-
IntStepFunction
- Inherited Members
Remarks
Integer step function.
Integer step function is a piecewise constant function defined on integer values in range Model.IntVarMin to Model.IntVarMax. The function can be created by Model.StepFunction.
Step functions can be used in the following ways:
- Function Model.Eval evaluates the function at the given point (given as IntExpr).
- Function Model.Integral computes a sum (integral) of the function over an IntervalVar.
- Constraints Model.ForbidStart and Model.ForbidEnd forbid the start/end of an IntervalVar to be in a zero-value interval of the function.
- Constraint Model.ForbidExtent forbids the extent of an IntervalVar to be in a zero-value interval of the function.
Methods
Eval(IntExpr)
Evaluates the step function at a given point.
public IntExpr Eval(IntExpr arg)
Parameters
argIntExprThe point at which to evaluate the step function.
Returns
- IntExpr
The resulting integer expression
Remarks
The result is the value of the step function at the point arg. If the value of arg is absent, then the result is also absent.
By constraining the returned value, it is possible to limit arg to be only within certain segments of the segmented function. In particular, functions Model.ForbidStart and Model.ForbidEnd work that way.
See also:
- Model.Eval — for the equivalent function on Model.
- Model.ForbidStart — are convenience functions built on top of
eval. - Model.ForbidEnd — are convenience functions built on top of
eval.
Eval(int)
Evaluates the step function at a given point.
public IntExpr Eval(int arg)
Parameters
argintThe point at which to evaluate the step function.
Returns
- IntExpr
The resulting integer expression
Remarks
The result is the value of the step function at the point arg. If the value of arg is absent, then the result is also absent.
By constraining the returned value, it is possible to limit arg to be only within certain segments of the segmented function. In particular, functions Model.ForbidStart and Model.ForbidEnd work that way.
See also:
- Model.Eval — for the equivalent function on Model.
- Model.ForbidStart — are convenience functions built on top of
eval. - Model.ForbidEnd — are convenience functions built on top of
eval.
Integral(IntervalVar)
Computes sum of values of the step function over the interval interval.
public IntExpr Integral(IntervalVar interval)
Parameters
intervalIntervalVarThe interval variable.
Returns
- IntExpr
The resulting integer expression
Remarks
The sum is computed over all integer time points from interval.start() to interval.end()-1 inclusive. In other words, the sum includes the function value at the start time but excludes the value at the end time (half-open interval). If the interval variable has zero length, then the result is 0. If the interval variable is absent, then the result is absent.
Requirement: The step function func must be non-negative.
See also:
- Model.Integral — for the equivalent function on Model.