Package org.jacop.constraints
Class Diff2
- java.lang.Object
-
- org.jacop.constraints.DecomposedConstraint<Constraint>
-
- org.jacop.constraints.Constraint
-
- org.jacop.constraints.Diff
-
- org.jacop.constraints.Diff2
-
- All Implemented Interfaces:
SatisfiedPresent
,Stateful
,UsesQueueVariable
public class Diff2 extends Diff
Diff2 constraint assures that any two rectangles from a vector of rectangles does not overlap in at least one direction.Zero-width rectangles can be packed anywhere.
- Version:
- 4.7
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Diff2Var[]
EvalRects
(package private) boolean
exceptionListPresent
int[]
exclusiveList
It specifies a list of pairs of rectangles which can overlap.(package private) static java.util.concurrent.atomic.AtomicInteger
idNumber
-
Fields inherited from class org.jacop.constraints.Diff
currentStore, dimIthMinComparator, doProfile, rectangles, stamp, trace, variableQueue
-
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
Constructors Constructor Description Diff2(java.util.List<? extends java.util.List<? extends IntVar>> rectangles)
It creates a diff2 constraint.Diff2(java.util.List<? extends java.util.List<? extends IntVar>> rectangles, boolean profile)
It creates a diff2 constraint.Diff2(java.util.List<? extends IntVar> o1, java.util.List<? extends IntVar> o2, java.util.List<? extends IntVar> l1, java.util.List<? extends IntVar> l2)
It creates a diff2 constraint.Diff2(java.util.List<java.util.List<IntVar>> rectangles, java.util.List<java.util.List<java.lang.Integer>> exclusiveList)
Conditional Diff2.Diff2(java.util.List<IntVar> o1, java.util.List<IntVar> o2, java.util.List<IntVar> l1, java.util.List<IntVar> l2, boolean profile)
It creates a diff2 constraint.Diff2(Rectangle[] rectangles, int[] exclusiveList, boolean doProfile)
Conditional Diff2.Diff2(IntVar[][] rectangles)
It creates a diff2 constraint.Diff2(IntVar[][] rectangles, boolean profile)
It creates a diff2 constraint.Diff2(IntVar[][] rect, java.util.List<java.util.List<java.lang.Integer>> exclusive)
Conditional Diff2.Diff2(IntVar[] origin1, IntVar[] origin2, IntVar[] length1, IntVar[] length2)
It creates a diff2 constraint.Diff2(IntVar[] o1, IntVar[] o2, IntVar[] l1, IntVar[] l2, boolean profile)
It creates a diff2 constraint.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) boolean
findRectangles(Rectangle r, int index, java.util.List<IntRectangle> UsedRect, java.util.List<Rectangle> ProfileCandidates, java.util.List<Rectangle> OverlappingRects, java.util.Set<IntVar> fdvQueue)
void
impose(Store store)
It imposes the constraint in a given store.(package private) void
narrowRectangles(java.util.Set<IntVar> fdvQueue)
(package private) boolean
notOverlapping(int i, int j, int[] exclusiveList)
private Rectangle[]
onList(int index, int[] exclusiveList)
boolean
satisfied()
It checks if the constraint is satisfied.java.lang.String
toString()
It produces a string representation of a constraint state.-
Methods inherited from class org.jacop.constraints.Diff
consistency, containsChangedVariable, getDefaultConsistencyPruningEvent, getRectangles, intervalOverlap, narrowRectangle, profileCheckRectangle, profileNarrowing, queueVariable, removeLevel
-
Methods inherited from class org.jacop.constraints.Constraint
afc, arguments, cleanAfterFailure, decompose, getConsistencyPruningEvent, getGuideConstraint, getGuideValue, getGuideVariable, grounded, grounded, id, 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 Detail
-
idNumber
static java.util.concurrent.atomic.AtomicInteger idNumber
-
EvalRects
Diff2Var[] EvalRects
-
exceptionListPresent
boolean exceptionListPresent
-
exclusiveList
public int[] exclusiveList
It specifies a list of pairs of rectangles which can overlap.
-
-
Constructor Detail
-
Diff2
public Diff2(Rectangle[] rectangles, int[] exclusiveList, boolean doProfile)
Conditional Diff2. The rectangles that are specified on the list Exclusive list is specified contains pairs of rectangles that are excluded from checking that they must be non-overlapping. The rectangles are numbered from 1, for example list [1, 3, 3, 4] specifies that rectangles 1 and 3 as well as 3 and 4 can overlap each other.- Parameters:
rectangles
- a list of rectangles.exclusiveList
- a list denoting the pair of rectangles, which can overlapdoProfile
- should profile be computed and used.
-
Diff2
public Diff2(java.util.List<IntVar> o1, java.util.List<IntVar> o2, java.util.List<IntVar> l1, java.util.List<IntVar> l2, boolean profile)
It creates a diff2 constraint.- Parameters:
o1
- list of variables denoting the origin in the first dimension.o2
- list of variables denoting the origin in the second dimension.l1
- list of variables denoting the length in the first dimension.l2
- list of variables denoting the length in the second dimension.profile
- specifies if the profile should be computed.
-
Diff2
public Diff2(java.util.List<? extends java.util.List<? extends IntVar>> rectangles)
It creates a diff2 constraint.- Parameters:
rectangles
- list of rectangles with origins and lengths in both dimensions.
-
Diff2
public Diff2(java.util.List<? extends java.util.List<? extends IntVar>> rectangles, boolean profile)
It creates a diff2 constraint.- Parameters:
rectangles
- list of rectangles with origins and lengths in both dimensions.profile
- specifies if the profile is computed and used.
-
Diff2
public Diff2(java.util.List<? extends IntVar> o1, java.util.List<? extends IntVar> o2, java.util.List<? extends IntVar> l1, java.util.List<? extends IntVar> l2)
It creates a diff2 constraint.- Parameters:
o1
- list of variables denoting the origin in the first dimension.o2
- list of variables denoting the origin in the second dimension.l1
- list of variables denoting the length in the first dimension.l2
- list of variables denoting the length in the second dimension.
-
Diff2
public Diff2(IntVar[] origin1, IntVar[] origin2, IntVar[] length1, IntVar[] length2)
It creates a diff2 constraint.- Parameters:
origin1
- list of variables denoting the origin in the first dimension.origin2
- list of variables denoting the origin in the second dimension.length1
- list of variables denoting the length in the first dimension.length2
- list of variables denoting the length in the second dimension.
-
Diff2
public Diff2(IntVar[] o1, IntVar[] o2, IntVar[] l1, IntVar[] l2, boolean profile)
It creates a diff2 constraint.- Parameters:
o1
- list of variables denoting the origin in the first dimension.o2
- list of variables denoting the origin in the second dimension.l1
- list of variables denoting the length in the first dimension.l2
- list of variables denoting the length in the second dimension.profile
- specifies if the profile should be computed.
-
Diff2
public Diff2(IntVar[][] rectangles)
It creates a diff2 constraint.- Parameters:
rectangles
- list of rectangles with origins and lengths in both dimensions.
-
Diff2
public Diff2(IntVar[][] rectangles, boolean profile)
It creates a diff2 constraint.- Parameters:
rectangles
- list of rectangles with origins and lengths in both dimensions.profile
- specifies if the profile is computed and used.
-
Diff2
public Diff2(java.util.List<java.util.List<IntVar>> rectangles, java.util.List<java.util.List<java.lang.Integer>> exclusiveList)
Conditional Diff2. The rectangles that are specified on the list Exclusive are excluded from checking that they must be non-overlapping. The rectangles are numbered from 1, for example list [[1,3], [3,4]] specifies that rectangles 1 and 3 as well as 3 and 4 can overlap each other.- Parameters:
rectangles
- - list of rectangles, each rectangle represented by a list of variables.exclusiveList
- - list of rectangles pairs which can overlap.
-
Diff2
public Diff2(IntVar[][] rect, java.util.List<java.util.List<java.lang.Integer>> exclusive)
Conditional Diff2. The rectangles that are specified on the list Exclusive are excluded from checking that they must be non-overlapping. The rectangles are numbered from 1, for example list [[1,3], [3,4]] specifies that rectangles 1 and 3 as well as 3 and 4 can overlap each other.- Parameters:
rect
- - list of rectangles, each rectangle represented by a list of variables.exclusive
- - list of rectangles pairs which can overlap.
-
-
Method Detail
-
onList
private Rectangle[] onList(int index, int[] exclusiveList)
-
notOverlapping
boolean notOverlapping(int i, int j, int[] exclusiveList)
-
impose
public void impose(Store store)
Description copied from class:Constraint
It imposes the constraint in a given store.- Overrides:
impose
in classConstraint
- Parameters:
store
- the constraint store to which the constraint is imposed to.
-
narrowRectangles
void narrowRectangles(java.util.Set<IntVar> fdvQueue)
- Overrides:
narrowRectangles
in classDiff
-
findRectangles
boolean findRectangles(Rectangle r, int index, java.util.List<IntRectangle> UsedRect, java.util.List<Rectangle> ProfileCandidates, java.util.List<Rectangle> OverlappingRects, java.util.Set<IntVar> fdvQueue)
-
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
- Overrides:
satisfied
in classDiff
- Returns:
- true if constraint is possible to verify that it is satisfied.
-
toString
public java.lang.String toString()
Description copied from class:Constraint
It produces a string representation of a constraint state.
-
-