endBeforeStart

Constrains minimum delay between the end of one interval variable and start of another one.

Syntax


constraint endBeforeStart(intervalVar predecessor, intervalVar successor, intExpr minDelay = 0)

Parameters

  • predecessor: interval variable which ends before.
  • successor: interval variable which starts after.
  • minDelay: the minimal delay between end of predecessor and start of successor. If not specified then zero is used.

Description

the function endBeforeStart constrains interval variables predecessor and successor in the following way. If both interval variables predecessor and successor are present then successor cannot start before endOf(predecessor)+minDelay. If predecessor or successor is absent then the constraint is automatically satisfied.

The default value for minDelay is zero. It is possible to specify even negative minDelay, in this case successor can actually start before the end of predecessor but still not sooner than endOf(predecessor)+minDelay.

Example

Task production creates a product. Once the product is finished it can be optionally painted to green by task painting. In this case there is a minimum delay of 3 time units between production and painting because the product must cool down first.


production = intervalVar(length=5);
painting = intervalVar(optional, length=1);
endBeforeStart(production, painting, 3);

Notes

Interval variables can be also constrained in a similar way using expressions startOf and endOf:


endOf(predecessor, intmin) + minDelay <= startOf(successor, intmax);

CP Optimizer automatically converts the constraint above into endBeforeStart whenever possible. It is preferred to use endBeforeStart because it is clearer and requires less preprocessing.