typeOfPrev

Returns an integer expression that represents the type of the interval variable that is previous.

Syntax


intExpr typeOfPrev(sequenceVar seq, intervalVar interval, int firstValue = 0, int absentValue = 0)

Parameters

  • seq: sequence variable.
  • interval: interval variable.
  • firstValue: value to return if interval variable interval is the first one in seq.
  • absentValue: value to return if interval variable interval becomes absent.

Description

This function returns an integer expression that represents the type 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);
bx = intervalVar(size=6);
by = intervalVar(size=6);
c  = intervalVar(optional, size=7);
// A sequence variable defined on {a, bx, by, c} with types {0, 1, 1, 2}
seq = sequenceVar([a, bx, by, c], [0, 1, 1, 2]);
// The interval variables of the sequence cannot overlap
noOverlap(seq);
// If interval variable a is not the first one, the type of the interval previous to a should not be 1
// Note that a cannot be first (1 == 1)
typeOfPrev(seq, a, 1) != 1;
// If interval variable c is not the first one, the type value of the interval previous 
// to c should be 1. Note that interval variable c must be present (0 != 1) and can be first (1 == 1).
typeOfPrev(seq, c, 1, 0) == 1;

A possible value for the sequence variable in this problem is (bx -> c -> a -> by).

Requirements

  • interval should be an interval variable of sequence variable seq.