pulse

OPL expression (scheduling) of a cumulative function

Purpose

OPL expression (scheduling) of a cumulative function.

context type
Model files (.mod)
cumulFunction

Syntax

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


Where:

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

Description

Pulse is an elementary cumulative function expression representing the contribution of an individual interval variable or fixed interval of time. Pulse covers the usage of a cumulative or renewable resource when an activity increases the resource usage function at its start and decreases usage when it releases the resource at its end time.

The pulse function interval is represented by a, or by the start point u and end point v. The height of the function is represented by h, or bounded by hmin and hmax.

Note that a cumulfunction is constrained to be non-negative if it is involved in a <= or alwaysIn constraint. Also, <= and alwaysIn constraints on cumulfunction expressions cannot be used in meta-constraints.

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;

The complete model of the classical Resource-Constrained Project Scheduling problem:

tuple Prec {
  int task1;
  int task2;
};
tuple Req {
  int task;
  int rsrc;
  int qtty;
};

int nbTasks = ...;
int nbRsrcs = ...;
int dur[i in 1..nbTasks] = ...;
int cap[j in 1..nbRsrcs] = ...;
{ Prec } precs = ...;
{ Req } reqs = ...;

dvar interval tasks[i in 1..nbTasks] size dur[i];

minimize max(i in 1..nbTasks) endOf(tasks[i]);
subject to {
  forall(p in precs)
    endBeforeStart(tasks[p.task1],tasks[p.task2]);
  forall(j in 1..nbRsrcs)
    sum (r in reqs: r.rsrc==j) pulse(tasks[r.task],r.qtty) <= cap[j];
}