span
OPL constraint (scheduling) used to span intervals
Purpose
OPL constraint (scheduling) used to span the start and end of a group of intervals.
context | type |
---|---|
Model files (.mod) |
boolean |
Syntax
span(a, B); Where: dvar interval a; dvar interval B[];
Description
The constraint span(a, {b1, .., bn}) states that the interval a (if present) spans over all present intervals from the set {b1, .., bn}. In other words, interval a starts together with the first present interval from {b1, .., bn} and ends together with the last present interval. If a is not present, then no b interval is present.
The array B must be a one-dimensional array; for greater complexity, use the keyword all.
Note: This constraint cannot be used in a meta-constraint.
Example
using CP;
dvar interval a in 0..4;
dvar interval b[1..2] in 0..4;
subject to
{
startOf(a)==2;
endOf(a)==4;
endOf(b[1])<=startOf(b[2]);
span(a,b);
}
assert startOf(b[1])==2;
assert endOf(b[2])==4;