Package org.jacop.constraints
Class Alldiff
- java.lang.Object
-
- org.jacop.constraints.DecomposedConstraint<Constraint>
-
- org.jacop.constraints.Constraint
-
- org.jacop.constraints.Alldifferent
-
- org.jacop.constraints.Alldiff
-
- All Implemented Interfaces:
SatisfiedPresent,UsesQueueVariable
- Direct Known Subclasses:
Circuit,Subcircuit
public class Alldiff extends Alldifferent
Alldiff constraint assures that all FDVs has different values. It uses bounds consistency technique as described in the paper by Alejandro Lopez-Ortiz, Claude-Guy Quimper, John Tromp, Peter van Beek, "A fast and simple algorithm for bounds consistency of the alldifferent constraint", Proceedings of the 18th international joint conference on Artificial intelligence (IJCAI'03), Pages 245-250. Before using bounds consistency it calls consistency method for ground variables.It extends basic functionality of Alldifferent constraint.
- Version:
- 4.8
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAlldiff.Element
-
Field Summary
Fields Modifier and Type Field Description private int[]boundsprivate int[]dprivate int[]h(package private) static java.util.concurrent.atomic.AtomicIntegeridNumberprivate Alldiff.Element[]maxsortedprivate java.util.Comparator<Alldiff.Element>maxVariableprivate Alldiff.Element[]minsortedprivate java.util.Comparator<Alldiff.Element>minVariableprivate intnb(package private) Storestoreprivate int[]t-
Fields inherited from class org.jacop.constraints.Alldifferent
grounded, list, positionMapping, variableQueue
-
Fields inherited from class org.jacop.constraints.Constraint
afcWeight, atomicExecution, consistencyPruningEvents, constraintScope, earlyTerminationOK, increaseWeight, numberId, scope, trace, watchedVariableGrounded
-
Fields inherited from class org.jacop.constraints.DecomposedConstraint
queueIndex
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconsistency(Store store)It is a (most probably incomplete) consistency function which removes the values from variables domains.intgetDefaultConsistencyPruningEvent()voidimpose(Store store)It imposes the constraint in a given store.private voidinit()private intpathmax(int[] v, int i)private intpathmin(int[] v, int i)private voidpathset(int[] v, int start, int end, int to)voidqueueVariable(int level, Var var)This is a function called to indicate which variable in a scope of constraint has changed.java.lang.StringtoString()It produces a string representation of a constraint state.private voidupdateLB()private voidupdateUB()-
Methods inherited from class org.jacop.constraints.Alldifferent
notSatisfied, satisfied
-
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
-
-
-
-
Field Detail
-
idNumber
static java.util.concurrent.atomic.AtomicInteger idNumber
-
store
Store store
-
maxVariable
private java.util.Comparator<Alldiff.Element> maxVariable
-
minVariable
private java.util.Comparator<Alldiff.Element> minVariable
-
t
private int[] t
-
d
private int[] d
-
h
private int[] h
-
bounds
private int[] bounds
-
nb
private int nb
-
minsorted
private Alldiff.Element[] minsorted
-
maxsorted
private Alldiff.Element[] maxsorted
-
-
Constructor Detail
-
Alldiff
protected Alldiff()
-
Alldiff
public Alldiff(IntVar[] variables)
It constructs the alldiff constraint for the supplied variable.- Parameters:
variables- variables which are constrained to take different values.
-
Alldiff
public Alldiff(java.util.List<? extends IntVar> variables)
It constructs the alldiff constraint for the supplied variable.- Parameters:
variables- variables which are constrained to take different values.
-
-
Method Detail
-
getDefaultConsistencyPruningEvent
public int getDefaultConsistencyPruningEvent()
- Overrides:
getDefaultConsistencyPruningEventin classAlldifferent
-
impose
public void impose(Store store)
Description copied from class:ConstraintIt imposes the constraint in a given store.- Overrides:
imposein classAlldifferent- Parameters:
store- the constraint store to which the constraint is imposed to.
-
consistency
public void consistency(Store store)
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.- Overrides:
consistencyin classAlldifferent- Parameters:
store- constraint store within which the constraint consistency is being checked.
-
init
private void init()
-
updateLB
private void updateLB()
-
updateUB
private void updateUB()
-
pathset
private void pathset(int[] v, int start, int end, int to)
-
pathmin
private int pathmin(int[] v, int i)
-
pathmax
private int pathmax(int[] v, int i)
-
toString
public java.lang.String toString()
Description copied from class:ConstraintIt produces a string representation of a constraint state.- Overrides:
toStringin classAlldifferent
-
queueVariable
public void queueVariable(int level, Var var)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 classAlldifferent- Parameters:
level- the level of the store at which the change has occurred.var- variable which has changed.
-
-