Package org.jacop.constraints
Class NoGood
java.lang.Object
org.jacop.constraints.DecomposedConstraint<Constraint>
org.jacop.constraints.Constraint
org.jacop.constraints.NoGood
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.10
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final booleanprivate intprivate IntVar(package private) static AtomicIntegerprotected int[]It specifies a list of values in no-good constraint.protected IntVar[]It specifies a list of variables in no-good constraint.private intprivate IntVarFields inherited from class org.jacop.constraints.Constraint
afcWeight, atomicExecution, consistencyPruningEvents, constraintScope, earlyTerminationOK, increaseWeight, numberId, scope, trace, watchedVariableGroundedFields inherited from class org.jacop.constraints.DecomposedConstraint
queueIndex -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcommonInitialization(IntVar[] listOfVars, int[] listOfValues) voidconsistency(Store store) It is a (most probably incomplete) consistency function which removes the values from variables domains.intvoidIt imposes the constraint in a given store.voidThis function does nothing as constraints can not be removed for a given level.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, watchedVariableGroundedMethods inherited from class org.jacop.constraints.DecomposedConstraint
auxiliaryVariables, checkInput, checkInput, checkInputForDuplication, checkInputForDuplicationSkipSingletons, checkInputForNullness, checkInputForNullness, checkInputForNullness, derivative, getDubletonsSkipSingletons, imposeDecomposition
-
Field Details
-
idNumber
-
listOfVars
It specifies a list of variables in no-good constraint. -
listOfValues
protected int[] listOfValuesIt specifies a list of values in no-good constraint. -
firstWatch
-
firstValue
private int firstValue -
secondWatch
-
secondValue
private int secondValue -
debug
private static final boolean debug- See Also:
-
-
Constructor Details
-
NoGood
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
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 Details
-
commonInitialization
-
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.
-
getDefaultConsistencyPruningEvent
public int getDefaultConsistencyPruningEvent()- Specified by:
getDefaultConsistencyPruningEventin classConstraint
-
impose
Description copied from class:ConstraintIt imposes the constraint in a given store.- Overrides:
imposein 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:
removeConstraintin classConstraint
-
toString
Description copied from class:ConstraintIt produces a string representation of a constraint state.- Overrides:
toStringin classConstraint
-