previous

Constrains an interval variable to be previous to another interval variable in a sequence.

Syntax


constraint previous(sequenceVar seq, intervalVar interval1, intervalVar interval2)

Parameters

  • seq: sequence variable.
  • interval1: interval variable.
  • interval2: interval variable.

Description

This function returns a constraint that states that whenever both interval variables interval1 and interval2 are present, interval1 must be the interval variable that is previous to interval2 in the sequence variable seq.

Example


a = intervalVar(size=5);
b = intervalVar(optional, size=6);
c = intervalVar(size=7);
// A sequence variable defined on {a, b, c}
seq = sequenceVar([a, b, c]);
// The interval variables of the sequence cannot overlap
noOverlap(seq);
// If interval variable b is present, it must be previous to c in the sequence
previous(seq, b, c);

Requirements

  • Interval variables interval1 and interval2 should both belong to sequence variable seq.