Package org.jacop.constraints
Class NoGood
- java.lang.Object
-
- org.jacop.constraints.DecomposedConstraint<Constraint>
-
- org.jacop.constraints.Constraint
-
- org.jacop.constraints.NoGood
-
public class NoGood extends Constraint
NoGood constraints implements a constraint which disallows given combination of values for given variables. NoGoods are special constraints as they can be only triggered only when all variables except one are grounded and equal to disallow values. This allows efficient implementation based on watched literals idea from SAT community.Do not be fooled by watched literals, if you add thousands of no-goods then traversing even 1/10 of them if they are watched by variable which has been grounded can slow down search considerably.
NoGoods constraints are imposed at all levels once added. Do not use in subsearches, as it will not take into account the assignments performed in master search.
- Version:
- 4.8
-
-
Field Summary
Fields Modifier and Type Field Description private static boolean
debug
private int
firstValue
private IntVar
firstWatch
(package private) static java.util.concurrent.atomic.AtomicInteger
idNumber
protected int[]
listOfValues
It specifies a list of values in no-good constraint.protected IntVar[]
listOfVars
It specifies a list of variables in no-good constraint.private int
secondValue
private IntVar
secondWatch
-
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 private void
commonInitialization(IntVar[] listOfVars, int[] listOfValues)
void
consistency(Store store)
It is a (most probably incomplete) consistency function which removes the values from variables domains.int
getDefaultConsistencyPruningEvent()
void
impose(Store store)
It imposes the constraint in a given store.void
removeConstraint()
This function does nothing as constraints can not be removed for a given level.java.lang.String
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, imposeDecomposition, increaseWeight, intArrayToString, long2int, numberArgs, queueVariable, 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
-
listOfVars
protected IntVar[] listOfVars
It specifies a list of variables in no-good constraint.
-
listOfValues
protected int[] listOfValues
It specifies a list of values in no-good constraint.
-
firstWatch
private IntVar firstWatch
-
firstValue
private int firstValue
-
secondWatch
private IntVar secondWatch
-
secondValue
private int secondValue
-
debug
private static final boolean debug
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NoGood
public NoGood(IntVar[] listOfVars, int[] listOfValues)
It creates a no-good constraint.- Parameters:
listOfVars
- the scope of the constraint.listOfValues
- no-good values which all-together assignment to variables within constraint scope is a no-good.
-
NoGood
public NoGood(java.util.List<? extends IntVar> listOfVars, java.util.List<java.lang.Integer> listOfValues)
It creates a no-good constraint.- Parameters:
listOfVars
- the scope of the constraint.listOfValues
- no-good values which all-together assignment to variables within constraint scope is a no-good.
-
-
Method Detail
-
commonInitialization
private void commonInitialization(IntVar[] listOfVars, int[] listOfValues)
-
consistency
public void consistency(Store store)
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.
-
getDefaultConsistencyPruningEvent
public int getDefaultConsistencyPruningEvent()
- Specified by:
getDefaultConsistencyPruningEvent
in classConstraint
-
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.
-
removeConstraint
public void removeConstraint()
This function does nothing as constraints can not be removed for a given level. In addition, watched literals mechanism makes sure that constraint is not put in the queue when it can not propagate.- Overrides:
removeConstraint
in classConstraint
-
toString
public java.lang.String toString()
Description copied from class:Constraint
It produces a string representation of a constraint state.- Overrides:
toString
in classConstraint
-
-