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.10
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) Storeprotected Function<Integer, Comparator<IntRectangle>> (package private) booleanIt specifies if the constraint should compute and use the profile.(package private) static AtomicIntegerprivate intIt specifies the list of rectangles which are of interest for this diff constraint.(package private) intprotected static final booleanprivate static final booleanFields inherited from class org.jacop.constraints.Constraint
afcWeight, atomicExecution, consistencyPruningEvents, constraintScope, earlyTerminationOK, increaseWeight, numberId, scope, watchedVariableGroundedFields inherited from class org.jacop.constraints.DecomposedConstraint
queueIndex -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDiff()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 voidcomputeNewMaxDuration(IntVar start, int durMin, int excludeMin, int excludeMax) voidconsistency(Store store) It is a (most probably incomplete) consistency function which removes the values from variables domains.(package private) booleancontainsChangedVariable(Rectangle r, Set<IntVar> fdvQueue) private booleanfindRectangles(Rectangle r, List<IntRectangle> UsedRect, List<Rectangle> ProfileCandidates, Set<IntVar> fdvQueue) int(package private) Rectangle[](package private) booleanintervalOverlap(int min1, int max1, int min2, int max2) private Diff.PairminForbiddenInterval(int start, int i, Rectangle r, List<IntRectangle> ConsideredRect) private void(package private) voidnarrowRectangle(Rectangle r, List<IntRectangle> UsedRect, List<Rectangle> ProfileCandidates) (package private) voidnarrowRectangles(Set<IntVar> fdvQueue) private booleannotFit(int i, Rectangle r, List<IntRectangle> ConsideredRect, int barierPosition) private voidprofileCheckInterval(Store store, DiffnProfile Profile, int limit, IntVar Start, IntVar Duration, int iMin, int i_max, IntVar Resources) (package private) voidprofileCheckRectangle(DiffnProfile Profile, Rectangle r, int i, int j) (package private) voidprofileNarrowing(int i, Rectangle r, List<Rectangle> ProfileCandidates) voidqueueVariable(int level, Var V) This is a function called to indicate which variable in a scope of constraint has changed.voidremoveLevel(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.booleanIt 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, watchedVariableGroundedMethods inherited from class org.jacop.constraints.DecomposedConstraint
auxiliaryVariables, checkInput, checkInput, checkInputForDuplication, checkInputForDuplicationSkipSingletons, checkInputForNullness, checkInputForNullness, checkInputForNullness, derivative, getDubletonsSkipSingletons, imposeDecompositionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
rectangles- list of rectangles which can not overlap in at least one dimension.profile- specifies is the profiles are used.
-
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:
rectangles- list of rectangles which can not overlap in at least one dimension.profile- specifies is the profiles are used.
-
-
Method Details
-
removeLevel
public void removeLevel(int level) Description copied from interface:StatefulThis 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:
removeLevelin interfaceStateful- Parameters:
level- the level which is being removed.
-
consistency
Description copied from class:ConstraintIt 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:
consistencyin classConstraint- Parameters:
store- constraint store within which the constraint consistency is being checked.
-
containsChangedVariable
-
findRectangles
-
getDefaultConsistencyPruningEvent
public int getDefaultConsistencyPruningEvent()- Specified by:
getDefaultConsistencyPruningEventin 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:ConstraintThis 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:
queueVariablein 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:SatisfiedPresentIt 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:
satisfiedin interfaceSatisfiedPresent- Returns:
- true if constraint is possible to verify that it is satisfied.
-
toString
Description copied from class:ConstraintIt produces a string representation of a constraint state.- Overrides:
toStringin classConstraint
-