- All Implemented Interfaces:
CPConstraint,ConcreteConstraint<ConcreteCPModel>
NoOverlapWithPositionDecomposition.
Model
Each interval i is assigned a position posOfInterval[i] in 0..n-1
(all positions distinct via an InversePerm channeling to intervalInPos).
A global NoOverlap enforces that intervals do not overlap.
Set-based position reasoning
For each interval i, a set variable befores[i] represents the set of
intervals that precede i in the sequence. Its cardinality is channeled to the
position: |befores[i]| = posOfInterval[i]. The following equivalences are posted
for every ordered pair (i, j), i ≠ j:
i ∈ befores[j]⇔posOfInterval[i] < posOfInterval[j](viaIsIncluded+isLt)befores[i] ⊆ befores[j]⇔i ∈ befores[j](viaIsSubset— enforces transitivity: if i precedes j, every interval before i is also before j)i ∈ befores[j]⇔end(i) + trans[i][j] ≤ start(j)(viaIsEndBeforeStartWithTransition— channels temporal ordering)isIncludedVars[i][j] ≠ isIncludedVars[j][i](exactly one of the two orderings holds — redundant but helps propagation)
Global sweep propagation
The propagate() method, triggered on any domain change of the position
variables, set variables, or interval bounds, runs a sweep algorithm for each interval i:
- Collect the mandatory and possible predecessors of
ifrombefores[i]. - Compute an earliest completion time profile
ect[0..k]by scheduling all predecessors using a variant of Jackson's rule (SR-ECT sweep, implemented with two priority queues).ect[p]is the earliest time at which the p-th predecessor can complete. - Compute a latest completion time profile
lct[0..k]symmetrically, scheduling predecessors backward from their latest end times. - For each candidate position
pof intervali:- Earliest start:
est = max(ect[p] + transitionAdjustment, startMin(i)), wheretransitionAdjustmentaccounts for the minimum transition times between the p predecessors and between the last predecessor and i. - Latest start:
lst = min(lct[p] - transitionAdjustment - lengthMin(i), startMax(i)). - If
est > startMax(i)orlst < startMin(i), position p is removed fromposOfInterval[i]. - Otherwise, update
startMin(i) := min(est)andstartMax(i) := max(lst).
- Earliest start:
The transition time adjustment uses the global minimum transition minTransition
(minimum over all distinct pairs) as a lower bound for inter-predecessor gaps, and
minTransToI (minimum transition from any possible predecessor to i) for the
gap between the last predecessor and i. This is a conservative relaxation that never
removes feasible solutions while still providing useful pruning.
Complexity
Each propagation call is O(n² log n): for each of the n intervals, the sweep
algorithm runs in O(k log k) where k is the number of predecessors, and the position
check is O(n). The O(n²) IsEndBeforeStartWithTransition constraints provide
event-driven pairwise channeling and are only woken up when the relevant variables change.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal CPIntVar[]intervalInPos[p]is the interval at position p in the sequence.final CPIntervalVar[]Intervals to be sequenced.final intNumber of intervals.final CPIntVar[]posOfInterval[i]is the position of interval i in the sequence. -
Constructor Summary
ConstructorsConstructorDescriptionNoOverlapWithPosition(CPIntervalVar[] intervals, CPIntVar[] posOfInterval, CPIntVar[] intervalInPos) Creates a global permutation constraint with zero transition times.NoOverlapWithPosition(CPIntervalVar[] intervals, CPIntVar[] posOfInterval, CPIntVar[] intervalInPos, int[][] minTransition) Creates a global permutation constraint with minimum transition times between intervals. -
Method Summary
Methods inherited from class org.maxicp.cp.engine.core.AbstractCPConstraint
getSolver, isActive, isScheduled, priority, registerDelta, setActive, setScheduled, updateDeltas
-
Field Details
-
n
public final int nNumber of intervals. -
intervals
Intervals to be sequenced. -
posOfInterval
posOfInterval[i]is the position of interval i in the sequence. -
intervalInPos
intervalInPos[p]is the interval at position p in the sequence.
-
-
Constructor Details
-
NoOverlapWithPosition
public NoOverlapWithPosition(CPIntervalVar[] intervals, CPIntVar[] posOfInterval, CPIntVar[] intervalInPos) Creates a global permutation constraint with zero transition times.- Parameters:
intervals- the interval variables to be sequenced (all must be present and share the same solver)posOfInterval- position variables:posOfInterval[i]is the position of interval i (domain 0..n-1)intervalInPos- inverse position variables:intervalInPos[p]is the interval at position p (domain 0..n-1)
-
NoOverlapWithPosition
public NoOverlapWithPosition(CPIntervalVar[] intervals, CPIntVar[] posOfInterval, CPIntVar[] intervalInPos, int[][] minTransition) Creates a global permutation constraint with minimum transition times between intervals.The transition time matrix must satisfy the triangular inequality property, i.e., for all i, j, k:
minTransition[i][j] <= minTransition[i][k] + minTransition[k][j].- Parameters:
intervals- the interval variables to be sequenced (all must be present, same solver)posOfInterval- position variables:posOfInterval[i]is the position of interval i (domain 0..n-1)intervalInPos- inverse position variables:intervalInPos[p]is the interval at position p (domain 0..n-1)minTransition- n×n matrix whereminTransition[i][j]is the minimum transition time from interval i to interval j- Throws:
AssertionError- if the matrix dimensions don't match or triangular inequality is violated
-
-
Method Details
-
post
public void post()Description copied from interface:CPConstraintInitializes the constraint when it is posted to the solver.- Specified by:
postin interfaceCPConstraint- Overrides:
postin classAbstractCPConstraint
-
propagate
public void propagate()Description copied from interface:CPConstraintPropagates the constraint.- Specified by:
propagatein interfaceCPConstraint- Overrides:
propagatein classAbstractCPConstraint
-