Skip to main content
FRAMES NO FRAMES

Interval variable sequencing in CP Optimizer
PREVIOUS NEXT
Interval sequence variables
No overlap constraint
Same-sequence and same-common-subsequence constraints
Expressions for getting the type of a next/prev interval
Expressions for getting the bounds of next/previous interval
Interval sequence variables

An interval sequence variable is defined on a set of interval variables A. Informally speaking, the value of an interval sequence variable represents a total ordering of the interval variables of A. Note that any absent interval variables are not considered in the ordering.

More formally, an interval sequence variable  p on a set interval variables A represents a decision variable whose possible values are all the permutations of the intervals of A. Let k_A_underscore.png be a set of fixed intervals and n denote the cardinality of k_A_underscore.png. A permutation π of k_A_underscore.png is a function π : k_A_underscore.pngrarr2.png { perp.png } cup.png [1, n] such that if we denote length(π) = |{a_underscore.pngisin.pngk_A_underscore.png, x(a_underscore.png)}| the number of present intervals:

sequence2.png

Note that the sequence alone does not enforce any constraint on the relative position of interval end-points. For instance, an interval variable a could be sequenced before an interval variable b in a sequence p without any impact on the relative position between the start/end points of a and b (a could still be fixed to start after the end of b). This is because different semantics can be used to define how a sequence constrains the positions of intervals. We will see later how the noOverlap constraint implements one of these possible semantics.

The following constraints are available on sequence variables:

  • first(p, a) states that if interval a is present, it will be the first interval of the sequence p.
  • last(p, a) states that if interval a is present, it will be the last interval of the sequence p.
  • before(p, a, b) states that if both intervals a and b are present, a will appear before b in the sequence p.
  • prev(p, a, b) states that if both intervals a and b are present then a will be just before b in the sequence p. In other words, it will appear before b and no other interval will be sequenced between a and b in the sequence.

The formal semantics of these basic constraints are given in Table 3.

interval_sequence1.png

The sequence variable also allows the association of a fixed integer type with each interval variable in the sequence. In particular, these integers are used by the noOverlap constraint (see below) and the typeOfNext/Prev integer expressions (see below). T(p, a) denotes the fixed integer type of interval variable a in the sequence variable p.

The constraints involving interval variables and interval sequence variables cannot be used in logical constraints of CP Optimizer (see operator!, operator||). The reason is that any logical constraint involving interval variables must be captured via the presence Boolean value on the interval handled by the presenceOf constraint. The constraints having this limitation are the ordering constraints on a sequence (first, last, previous and before) and the noOverlap constraint.

No overlap constraint

The noOverlap constraint on an interval sequence variable p states that the sequence defines a chain of non-overlapping intervals, and any interval in the chain is constrained to end before the start of the next interval in the chain. This constraint is typically useful for modeling disjunctive resources.

More formally, the condition for a permutation value π for sequence p to satisfy the noOverlap constraint is defined as:

no_overlap.png

A sequence variable together with a no-overlap constraint using it are illustrated in Figure 4.

sequence.png

If a transition distance matrix M is specified, it defines the minimal distance that must separate two consecutive intervals in the sequence. Two versions of the constraint are available: one that enforces the transition distance between each interval and its next interval in the sequence (Next), and the other that enforces the transition distance between each interval and all its successors in the sequence (After).

More formally, if T(p,a) denotes the integer type of interval a in the sequence variable p:

no_overlap2.png

Note that if the transition matrix M satisfies the triangular inequality, the semantics of the two versions of the constraint no_overlap_next.png and no_overlap_after.png are the same. If M does not satisfy the triangular inequality, constraint no_overlap_after.png is stronger than no_overlap_next.png.

Same-sequence and same-common-subsequence constraints

The sameSequence and sameCommonSubsequence constraints are binary constraints on a pair of sequence variables p1.png and p2.png. These constraints state that the relative position of some related subsets of interval variables is the same in both sequences: typically, if a is before b in sequence p1.png then the interval related to a is before the interval related to b in sequence p2.png. Here are two examples of use-cases where these constraints are useful:

  • First in/first out and no-bypass constraints. In some physical systems like trains on a single line railway or items on a conveyor belt, bypassing is not possible and items must enter and exit a given section of the system in the same order. If entering and exiting the sections or the junctions of the system is modeled by two related interval variables, those constraints can be modeled by sameSequence constraints (or sameCommonSubsequence constraints if the items do not follow the same path) on the sequences of entering and exiting intervals. A classical example of such a constraint is the permutation flow-shop scheduling problem.
  • Scenario-Based approaches for scheduling with uncertainties. In presence of uncertainties (for instance, uncertain activity durations) one may be interested in building sequences of activities on unary resources that optimize some robustness or statistical criterion (for instance the expected makespan). A scenario is a sub-model that defines a particular realization of the uncertainties in the environment. As one must find robust sequences that optimize some criterion over all scenarios, the different sequences of a given unary resource across all scenarios are linked with sameSequence constraints.

A constraint sameCommonSubsequence(p1p2B1B2.png) is defined on two sequence variables p1.png (defined on a set of interval variables A1.png) and p2.png (defined on a set of interval variables A2.png) with two arrays of interval variables B1.png and B2.png of identical size and such that B1inA1.png. The constraint states that the sub-sequences defined by p1.png and p2.png by only considering the pairs of present intervals (B1iB2i.png) are identical modulo the mapping between intervals B1i.png and B2i.png.

For instance, let's suppose sequence variable p1.png defined on interval variables {a,b,c,d,e,f} and sequence variable p2.png defined on interval variables {u,v,w,x,y,z} with a constraint sameCommonSubsequence(p1.png, p2.png,[a,c,d,e,f],[u,w,v,x,y]). Assuming in a solution, interval variables d and y are absent while all the other interval variables are present. The pair of permutations pi1.png=(c,f,a,e,b) and pi2.png=(w,v,u,x) satisfies the sameCommonSubsequence constraints. Indeed if one only considers pairs of present intervals, the mapping B1B2.png maps [a,c,e] with [u,w,x]. Subsequence of pi1.png over {a,c,e} is (c,a,e), subsequence of pi2.png over {u,w,x} is (w,u,x) and one can see that the two subsequences are the same modulo the mapping.

More formally, let n denote the size of both interval variable arrays B1.png and B2.png. The condition for permutations pi1.png and pi2.png of sequencing variables p1.png and p2.png to satisfy constraint sameCommonSubsequence(pi1pi2B1B2.png) is defined as:

sameSeq1.png

A constraint sameSequence(p1p2B1B2.png) is defined on two sequence variables of identical size p1.png (defined on a set of interval variables A1.png) and p2.png (defined on a set of interval variables A2.png) with two arrays of interval variables B1.png and B2.png that are an ordering of sets A1.png and A2.png. The constraint states that sequences p1.png and p2.png are identical modulo a mapping between intervals B1i.png and B2i.png. A sameSequence constraint is stronger than a sameCommonSubsequence constraint; it additionally imposes that arrays B1.png and B2.png contain all the definition intervals of their relative sequence variables and that the presence status of mapped interval variables B1i.png and B2i.png is the same.

More formally, let n denote the size of both sequence variables. The condition for permutations pi1.png and pi2.png of the sequence variables p1.png and p2.png to satisfy constraint sameSequence(pi1pi2B1B2.png) is defined as:

sameSeq2.png

when parameters B1.png and B2.png are omitted in the definition of the above constraints, we assume B1.png and B2.png are the definition intervals of p1.png and p2.png, following the order of definition of interval variables in the sequence.

Expressions for getting the type of a next/prev interval

Two integer expressions are available to get the type of the interval that is next (resp. previous) to a given interval variable a in a sequence p. When interval a is absent or is the last (resp. first) interval of the sequence, specific values can be provided for these integer expressions.

More formally, let π be the permutation value of a fixed sequence variable p, and a_underscore.png be the value of a fixed interval variable a in the fixed sequence variable p.

If a_underscore.png is present and is not the last interval in π, we denote next_func.png the unique interval that is next to a_underscore.png in π.

next_func2.png

If a_underscore.png is present and is not the first interval in π, we denote prev_func.png the unique interval that is previous to a_underscore.png in π.

prev_func2.png

Expressions for getting the bounds of next/previous interval

Integer expressions startOfNext, endOfNext, lengthOfNext, sizeOfNext, startOfPrev, endOfPrev, lengthOfPrev, and sizeOfPrev provide access to the different attributes of the interval that is next (resp. previous) to a given interval variable a in a sequence p. When interval a is absent or is the last (resp. first) interval of the sequence, specific values can be provided for these integer expressions.

The semantics of these expressions are given in the table below.

nextprev_table.png

PREVIOUS NEXT