cumulFunction

OPL keyword (CP, scheduling) to create a cumulative function.

Purpose

OPL keyword (CP, scheduling) to create a cumulative function.

context type
Model files (.mod)
int

Syntax

cumulFunction f = pulse(u,v, h);
cumulFunction f = pulse(a, h);
cumulFunction f = pulse(a, hmin, hmax);
cumulFunction f = step(u, h);
cumulFunction f = stepAtStart(a, h);
cumulFunction f = stepAtStart(a, hmin, hmax);
cumulFunction f = stepAtEnd(a, h);
cumulFunction f = stepAtEnd(a, hmin, hmax);


Where:

int u;
int v;
int h;
int hmin;
int hmax;
int dval;
cumulFunction f;
dvar interval a;

Description

A cumulative function expression can be used to model a quantity that varies over time and whose value depends on other decision variables of the problem. For example a given capacity or physical resource may be described by several parameters that change over time and thus, by several functions. For instance a truck can be described using two functions that model the variation over time of the volume and the weight of the truck content. Note however that a function is not always associated with a physical resource, thus providing a level of abstraction that may be necessary in your model.

An activity usually increases the function at the start of usage of these cumulative or renewable resources, and decreases the function when the resource is released at its end time (pulse function). Some resources, such as inventories or tanks, can be produced and consumed by activities; production activities increase the resource level and consuming activities decrease it (step function). The cumulated contribution of activities on the resource is represented by a function of time, and constraints (such as maximal or minimal levels) can be modeled on this function. Contrast this incremental effect with the stateFunction, where interval variables have an absolute effect (as the function must be in a particular state).

A cumulFunction is restricted to being non-negative when involved with the constraints <= (scheduling) and alwaysIn; also, those constraints cannot be used in meta-constraints.

cumulFunction is a CP keyword and is still accepted as a CPLEX identifier.

Example

A basic program to show the effects of using pulse with cumulFunction:

using CP;

dvar interval it;
cumulFunction c=pulse(it,10);

subject to
{
 startOf(it)==2;
 endOf(it)==4;
}

int v[i in 0..5]=cumulFunctionValue(c,i);
execute
{
  writeln(v);
}

assert forall(i in 2..3) v[i]==10;
assert forall(i in 0..5: i!=2 && i!=3) v[i]==0;

A composite cumulative function expression defined as a sum of cumulFunction expressions, with a minus (-) operator:

cumulFunction h = sum(i in ...) F[i] - sum(j in ...) G[j];

A set of producing and consuming activities on a tank with a given capacity and safety level.

int SafetyLevel = ...;
int Capacity = ...;
int StartLevel = ...;
int QProd[p in 1..NProd] ...;
int QCons[c in 1..NCons] ...;

dvar interval AProd[p in 1..NProd] ...;
dvar interval ACons[c in 1..NCons] ...;

cumulFunction level =
    step(0, StartLevel)
  + sum (p in 1..NProd) stepAtEnd(AProd[p], QProd[p])
  - sum (c in 1..NCons) stepAtStart(ACons[c], QCons[c]);

subject to {
  alwaysIn(level, 0, maxint, SafetyLevel, Capacity);
};