pulse

Returns an elementary cumul function of constant value between the start and the end of an interval.

Syntax


cumulAtom pulse(intervalVar interval, uint h)
cumulAtom pulse(intervalVar interval, uint heightMin, uint heightMax)
cumulAtom pulse(sint start, sint end, uint h)

Parameters

  • interval: interval variable contributing to the cumul function.
  • h: non-negative integer representing the height of the contribution.
  • heightMin: non-negative integer representing the minimum of the range of possible values for the height of the contribution.
  • heightMax: non-negative integer representing the maximum of the range of possible values for the height of the contribution.
  • start: start of the fixed interval [start,end) contributing to the cumul function.
  • end: end of the fixed interval [start,end) contributing to the cumul function.

Description

This function returns an elementary cumul function expression that is equal to a value h everywhere between the start and the end of an interval variable interval or a fixed interval [start,end). The function is equal to 0 outside of the interval. When interval variable interval is absent, the function is the constant zero function. When a range [heightMin, heightMax) is specified it means that the height value h of the pulse is part of the decisions of the problem and will be fixed by the engine within this specified range.

Example


a1 = intervalVar(size=5);
a2 = intervalVar(size=4);
a3 = intervalVar(size=8);
a4 = intervalVar(size=3);
// Cumul function resourceUse represents the level of a discrete resource.
// Activities a1,a2,a3,a4 respectively require 2,3,3,2 units of resource during their execution.
resourceUse = pulse(a1,2) + pulse(a2,3) + pulse(a3,3) + pulse(a4,2);
// The resource has a limited capacity equal to 4 over the schedule horizon.
resourceUse <= 4;

A possible solution to this problem is the following assignment of interval variables: a1=[0,5), a2=[5,9), a3=[9,17), a4=[0,3). Indeed a1 and a4 can execute in parallel as their total resource usage 2+2=4 does not exceed the resource capacity.

Example


a1 = intervalVar(optional, size=2, end=0..4);
a2 = intervalVar(optional, size=3, end=0..4);
a3 = intervalVar(optional, size=2, end=0..4);
a4 = intervalVar(optional, size=2, end=0..4);
// There is a schedule horizon equal to 4.
// Cumul function resourceUse represents the level of a discrete resource.
// Optional activities a1,a2,a3,a4 respectively require 3,1,2,2 units of resource during their execution.
resourceUse = pulse(a1,3) + pulse(a2,1) + pulse(a3,2) + pulse(a4,2);
// The resource has a limited capacity equal to 4 over the schedule horizon.
resourceUse <= 4;
// The objective is to schedule the maximal amount of energy (duration*quantity) on the resource.
energy = 6*presenceOf(a1) + 3*presenceOf(a2) + 4*presenceOf(a3) + 4*presenceOf(a4);
maximize(energy);

The optimal solution of this problem consists of not executing activity a2.

Example


a1 = intervalVar(size=1..10, end=0..14);
a2 = intervalVar(size=1..10, end=0..14);
a3 = intervalVar(size=1..10, end=0..14);
a4 = intervalVar(size=1..10, end=0..14);
// Horizon of the schedule is 14
// Cumul function resourceUse represents the level of a discrete resource.
// Activities a1,a2,a3,a4 require between 1 and 10 units of resource
resourceUse = pulse(a1,1,10) + pulse(a2,1,10) + pulse(a3,1,10) + pulse(a4,1,10);
// Activities have variable duration. The total amount of work performed by each activity 
// (product of the activity size by the resource consumption) should be greater than 22
sizeOf(a1)*heightAtStart(a1,resourceUse) >= 22;
sizeOf(a2)*heightAtStart(a2,resourceUse) >= 22;
sizeOf(a3)*heightAtStart(a3,resourceUse) >= 22;
sizeOf(a4)*heightAtStart(a4,resourceUse) >= 22;
// The resource has a limited capacity equal to 7 over the schedule horizon.
resourceUse <= 7;

A possible solution to this problem is the following assignment of interval variables: a1=[0,6) (with resource use 4), a2=[0,8) (with resource use 3), a3=[6,14) (with resource use 3), a4=[8,14) (with resource use 4).

Requirements

  • For the function using a constant interval, end should be greater than start.
  • For the function specifying a range for height, heightMax should be greater than heightMin.