Package org.jacop.constraints
Class Diff
java.lang.Object
org.jacop.constraints.DecomposedConstraint<Constraint>
org.jacop.constraints.Constraint
org.jacop.constraints.Diff
- All Implemented Interfaces:
SatisfiedPresent
,Stateful
,UsesQueueVariable
- Direct Known Subclasses:
Diff2
,Disjoint
,DisjointConditional
Diff constraint assures that any two rectangles from a vector of rectangles
does not overlap in at least one direction. It is a simple implementation which
does not use sophisticated techniques for efficient backtracking.
- Version:
- 4.8
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) Store
protected Function<Integer,
Comparator<IntRectangle>> (package private) boolean
It specifies if the constraint should compute and use the profile.(package private) static AtomicInteger
private int
It specifies the list of rectangles which are of interest for this diff constraint.(package private) int
protected static final boolean
private static final boolean
Fields inherited from class org.jacop.constraints.Constraint
afcWeight, atomicExecution, consistencyPruningEvents, constraintScope, earlyTerminationOK, increaseWeight, numberId, scope, watchedVariableGrounded
Fields inherited from class org.jacop.constraints.DecomposedConstraint
queueIndex
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Diff()
It specifies a diffn constraint.It specifies a diff constraint.Diff
(List<? extends IntVar> o1, List<? extends IntVar> o2, List<? extends IntVar> l1, List<? extends IntVar> l2) It constructs a diff constraint.Diff
(List<? extends IntVar> o1, List<? extends IntVar> o2, List<? extends IntVar> l1, List<? extends IntVar> l2, boolean profile) It constructs a diff constraint.It specifies a diff constraint.It specifies a diff constraint.It specifies a diff constraint.It constructs a diff constraint.It constructs a diff constraint. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
computeNewMaxDuration
(IntVar start, int durMin, int excludeMin, int excludeMax) void
consistency
(Store store) It is a (most probably incomplete) consistency function which removes the values from variables domains.(package private) boolean
containsChangedVariable
(Rectangle r, Set<IntVar> fdvQueue) private boolean
findRectangles
(Rectangle r, List<IntRectangle> UsedRect, List<Rectangle> ProfileCandidates, Set<IntVar> fdvQueue) int
(package private) Rectangle[]
(package private) boolean
intervalOverlap
(int min1, int max1, int min2, int max2) private Diff.Pair
minForbiddenInterval
(int start, int i, Rectangle r, List<IntRectangle> ConsideredRect) private void
(package private) void
narrowRectangle
(Rectangle r, List<IntRectangle> UsedRect, List<Rectangle> ProfileCandidates) (package private) void
narrowRectangles
(Set<IntVar> fdvQueue) private boolean
notFit
(int i, Rectangle r, List<IntRectangle> ConsideredRect, int barierPosition) private void
profileCheckInterval
(Store store, DiffnProfile Profile, int limit, IntVar Start, IntVar Duration, int iMin, int i_max, IntVar Resources) (package private) void
profileCheckRectangle
(DiffnProfile Profile, Rectangle r, int i, int j) (package private) void
profileNarrowing
(int i, Rectangle r, List<Rectangle> ProfileCandidates) void
queueVariable
(int level, Var V) This is a function called to indicate which variable in a scope of constraint has changed.void
removeLevel
(int level) This function is called in case of the backtrack, so a constraint can clear the queue of changed variables which is no longer valid.boolean
It checks if the constraint is satisfied.toString()
It produces a string representation of a constraint state.Methods inherited from class org.jacop.constraints.Constraint
afc, arguments, cleanAfterFailure, decompose, getConsistencyPruningEvent, getGuideConstraint, getGuideValue, getGuideVariable, grounded, grounded, id, impose, impose, imposeDecomposition, increaseWeight, intArrayToString, long2int, numberArgs, removeConstraint, requiresMonotonicity, setConsistencyPruningEvent, setConstraintScope, setScope, setScope, setScope, setScope, setScope, setWatchedVariableGrounded, supplyGuideFeedback, toInt, toInt, updateAFC, watchedVariableGrounded
Methods inherited from class org.jacop.constraints.DecomposedConstraint
auxiliaryVariables, checkInput, checkInput, checkInputForDuplication, checkInputForDuplicationSkipSingletons, checkInputForNullness, checkInputForNullness, checkInputForNullness, derivative, getDubletonsSkipSingletons, imposeDecomposition
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jacop.api.Stateful
isStateful
-
Field Details
-
idNumber
-
trace
protected static final boolean trace- See Also:
-
traceNarr
private static final boolean traceNarr- See Also:
-
currentStore
Store currentStore -
minPosition
private int minPosition -
stamp
int stamp -
durMax
-
variableQueue
-
rectangles
It specifies the list of rectangles which are of interest for this diff constraint. -
doProfile
boolean doProfileIt specifies if the constraint should compute and use the profile. -
dimIthMinComparator
-
-
Constructor Details
-
Diff
protected Diff() -
Diff
It specifies a diff constraint.- Parameters:
rectangles
- list of rectangles which can not overlap in at least one dimension.doProfile
- should the constraint compute and use the profile functionality.
-
Diff
It specifies a diff constraint.- Parameters:
rectangles
- list of rectangles which can not overlap in at least one dimension.
-
Diff
It constructs a diff constraint.- Parameters:
o1
- list of variables denoting origin of the rectangle in the first dimension.o2
- list of variables denoting origin of the rectangle in the second dimension.l1
- list of variables denoting length of the rectangle in the first dimension.l2
- list of variables denoting length of the rectangle in the second dimension.profile
- it specifies if the profile should be computed and used.
-
Diff
It constructs a diff constraint.- Parameters:
origin1
- list of variables denoting origin of the rectangle in the first dimension.origin2
- list of variables denoting origin of the rectangle in the second dimension.length1
- list of variables denoting length of the rectangle in the first dimension.length2
- list of variables denoting length of the rectangle in the second dimension.
-
Diff
It specifies a diffn constraint.- Parameters:
rectangles
- list of rectangles which can not overlap in at least one dimension.
-
Diff
It specifies a diff constraint.- Parameters:
profile
- specifies is the profiles are used.rectangles
- list of rectangles which can not overlap in at least one dimension.
-
Diff
public Diff(List<? extends IntVar> o1, List<? extends IntVar> o2, List<? extends IntVar> l1, List<? extends IntVar> l2) It constructs a diff constraint.- Parameters:
o1
- list of variables denoting origin of the rectangle in the first dimension.o2
- list of variables denoting origin of the rectangle in the second dimension.l1
- list of variables denoting length of the rectangle in the first dimension.l2
- list of variables denoting length of the rectangle in the second dimension.
-
Diff
public Diff(List<? extends IntVar> o1, List<? extends IntVar> o2, List<? extends IntVar> l1, List<? extends IntVar> l2, boolean profile) It constructs a diff constraint.- Parameters:
o1
- list of variables denoting origin of the rectangle in the first dimension.o2
- list of variables denoting origin of the rectangle in the second dimension.l1
- list of variables denoting length of the rectangle in the first dimension.l2
- list of variables denoting length of the rectangle in the second dimension.profile
- it specifies if the profile should be computed and used.
-
Diff
It specifies a diff constraint.- Parameters:
profile
- specifies is the profiles are used.rectangles
- list of rectangles which can not overlap in at least one dimension.
-
-
Method Details
-
removeLevel
public void removeLevel(int level) Description copied from interface:Stateful
This function is called in case of the backtrack, so a constraint can clear the queue of changed variables which is no longer valid. This function is called *before* all timestamps, variables, mutablevariables have reverted to their previous value.- Specified by:
removeLevel
in interfaceStateful
- Parameters:
level
- the level which is being removed.
-
consistency
Description copied from class:Constraint
It is a (most probably incomplete) consistency function which removes the values from variables domains. Only values which do not have any support in a solution space are removed.- Specified by:
consistency
in classConstraint
- Parameters:
store
- constraint store within which the constraint consistency is being checked.
-
containsChangedVariable
-
findRectangles
-
getDefaultConsistencyPruningEvent
public int getDefaultConsistencyPruningEvent()- Specified by:
getDefaultConsistencyPruningEvent
in classConstraint
-
getRectangles
Rectangle[] getRectangles() -
intervalOverlap
boolean intervalOverlap(int min1, int max1, int min2, int max2) -
minForbiddenInterval
private Diff.Pair minForbiddenInterval(int start, int i, Rectangle r, List<IntRectangle> ConsideredRect) -
narrowIth
private void narrowIth(int i, Rectangle r, List<IntRectangle> UsedRect, List<Rectangle> ProfileCandidates) -
computeNewMaxDuration
-
narrowRectangle
-
narrowRectangles
-
notFit
-
profileCheckInterval
private void profileCheckInterval(Store store, DiffnProfile Profile, int limit, IntVar Start, IntVar Duration, int iMin, int i_max, IntVar Resources) -
profileCheckRectangle
-
profileNarrowing
-
queueVariable
Description copied from class:Constraint
This is a function called to indicate which variable in a scope of constraint has changed. It also indicates a store level at which the change has occurred.- Overrides:
queueVariable
in classConstraint
- Parameters:
level
- the level of the store at which the change has occurred.V
- variable which has changed.
-
satisfied
public boolean satisfied()Description copied from interface:SatisfiedPresent
It checks if the constraint is satisfied. It can return false even if constraint is satisfied but not all variables in its scope are grounded. It needs to return true if all variables in its scope are grounded and constraint is satisfied.Implementations of this interface for constraints that are not PrimitiveConstraint may require constraint imposition and consistency check as a requirement to work correctly.
- Specified by:
satisfied
in interfaceSatisfiedPresent
- Returns:
- true if constraint is possible to verify that it is satisfied.
-
toString
Description copied from class:Constraint
It produces a string representation of a constraint state.- Overrides:
toString
in classConstraint
-