startOfPrev
Returns an integer expression that represents the start of the interval variable that is previous.
Syntax
intExpr startOfPrev(sequenceVar seq, intervalVar interval, int lastValue = 0, int absentValue = 0)
Parameters
-
seq: sequence variable. -
interval: interval variable. -
firstValue: value to return if interval variableintervalis the first one inseq. -
absentValue: value to return if interval variableintervalbecomes absent.
Description
This function returns an integer expression that represents the start of the interval variable
that is previous to interval in sequence variable seq. When interval is present and is
the first interval of seq, it returns the constant integer value firstValue (zero by default).
When interval is absent, it returns the constant integer value absentValue (zero by default).
Example
a = intervalVar(size=5);
b = intervalVar(size=6);
c = intervalVar(optional, 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 a is not the first one, the start value of the interval previous to a should be at least 10
startOfPrev(seq, a, 10) >= 10;
// If interval variable c is present and is not the first interval variable in the sequence,
// the start value of the interval previous to c should be greater than 20.
// Note that interval variable c can be absent (20 >= 20) and can be first (30 >= 20).
startOfPrev(seq, c, 30, 20) >= 20;
Requirements
-
intervalshould be an interval variable of sequence variableseq.