Package org.jacop.constraints
Class ExtensionalConflictVA
- java.lang.Object
-
- org.jacop.constraints.DecomposedConstraint<Constraint>
-
- org.jacop.constraints.Constraint
-
- org.jacop.constraints.ExtensionalConflictVA
-
- All Implemented Interfaces:
Stateful,UsesQueueVariable
public class ExtensionalConflictVA extends Constraint implements UsesQueueVariable, Stateful
Extensional constraint assures that none of the tuples explicitly given is enforced in the relation.This implementation tries to balance the usage of memory versus time efficiency.
- Version:
- 4.8
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static booleandebugAll(package private) static booleandebugPruning(package private) static java.util.concurrent.atomic.AtomicIntegeridNumber(package private) int[][][]lastofsequenceIntVar[]listIt stores variables within this extensional constraint, order does matter.(package private) intnumberTuplesprivate booleansatisfiedAlreadyAtImposition(package private) Storestore(package private) int[][][]supports(package private) int[]tuple(package private) int[][][][]tuplesIt represents tuples which are supports for each of the variables.int[][]tuplesFromConstructorIt specifies the tuples given in the constructor.(package private) int[][]valuesIt represents values which are supported for a variable.(package private) java.util.LinkedHashSet<Var>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
-
-
Constructor Summary
Constructors Constructor Description ExtensionalConflictVA(java.util.List<? extends IntVar> variables, int[][] tuples)The constructor does not create local copy of tuples array.ExtensionalConflictVA(IntVar[] list)Deprecated.ExtensionalConflictVA(IntVar[] list, int[][] tuples)Constructor stores reference to tuples until imposition, any changes to tuples parameter will be reflected in the constraint behavior.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private intcomputeLastOfSequence(int[][] is, int posVar, int l)voidconsistency(Store store)It is a (most probably incomplete) consistency function which removes the values from variables domains.(package private) booleanequal(int[] tuple1, int[] tuple2)protected intfindPosition(int value, int[] values)intgetDefaultConsistencyPruningEvent()voidimpose(Store store)It imposes the constraint in a given store.intisDisallowed(int varPosition, int value, int[] t)It returns the position of disallowed tuple in the array of tuples for a given variable-value pair.voidqueueVariable(int level, Var var)This is a function called to indicate which variable in a scope of constraint has changed.private voidrecordSupport(int varPosition, int value, int[] t)voidremoveLevel(int level)It puts back tuples which have lost their support status at the level which is being removed.intseekInvalidPosition(int[] t)It finds the position at which the tuple is invalid.int[]seekSupportVA(int varPosition, int value)It seeks support tuple for a given variable and its value.int[]setFirstValid(int varPosition, int value)It computes the first valid tuple given restriction that a variable will be equal to a given value.(package private) booleansmaller(int[] tuple1, int[] tuple2)java.lang.StringtoString()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, 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
-
debugAll
static final boolean debugAll
- See Also:
- Constant Field Values
-
debugPruning
static final boolean debugPruning
- See Also:
- Constant Field Values
-
idNumber
static java.util.concurrent.atomic.AtomicInteger idNumber
-
numberTuples
int numberTuples
-
store
Store store
-
tuples
int[][][][] tuples
It represents tuples which are supports for each of the variables. The first index denotes variable index. The second index denotes value index. The third index denotes tuple.
-
tuplesFromConstructor
public int[][] tuplesFromConstructor
It specifies the tuples given in the constructor.
-
values
int[][] values
It represents values which are supported for a variable.
-
variableQueue
java.util.LinkedHashSet<Var> variableQueue
-
list
public IntVar[] list
It stores variables within this extensional constraint, order does matter.
-
satisfiedAlreadyAtImposition
private boolean satisfiedAlreadyAtImposition
-
tuple
int[] tuple
-
lastofsequence
int[][][] lastofsequence
-
supports
int[][][] supports
-
-
Constructor Detail
-
ExtensionalConflictVA
@Deprecated public ExtensionalConflictVA(IntVar[] list)
Deprecated.Partial constructor which stores variables involved in a constraint but does not get information about tuples yet. The tuples must set separately.- Parameters:
list- list of variables for constraint
-
ExtensionalConflictVA
public ExtensionalConflictVA(IntVar[] list, int[][] tuples)
Constructor stores reference to tuples until imposition, any changes to tuples parameter will be reflected in the constraint behavior. Changes to tuples should not performed under any circumstances. The tuples array is not copied to save memory and time.- Parameters:
list- list of variables for the conflict constrainttuples- list of forbidden tuples
-
ExtensionalConflictVA
public ExtensionalConflictVA(java.util.List<? extends IntVar> variables, int[][] tuples)
The constructor does not create local copy of tuples array. Any changes to this array will reflect on constraint behavior. Most probably incorrect as other data structures will not change accordingly.- Parameters:
variables- the scope of the extensional conflict constraint.tuples- the conflict (forbidden) tuples for that constraint.
-
-
Method Detail
-
seekSupportVA
public int[] seekSupportVA(int varPosition, int value)It seeks support tuple for a given variable and its value.- Parameters:
varPosition- variable for which the support is seeked.value- value of the variable for which support is seeked.- Returns:
- support tuple supporting varPosition-value pair.
-
recordSupport
private void recordSupport(int varPosition, int value, int[] t)
-
setFirstValid
public int[] setFirstValid(int varPosition, int value)It computes the first valid tuple given restriction that a variable will be equal to a given value.- Parameters:
varPosition- the position of the variable.value- the value of the variable.- Returns:
- the smallest valid tuple supporting varPosition-value pair.
-
isDisallowed
public int isDisallowed(int varPosition, int value, int[] t)It returns the position of disallowed tuple in the array of tuples for a given variable-value pair.- Parameters:
varPosition- variable for which we search for the forbidden tuple.value- value for which we search for the forbidden tuple.t- tuple which we check for forbidness.- Returns:
- position of the forbidden tuple, -1 if it is not forbidden.
-
seekInvalidPosition
public int seekInvalidPosition(int[] t)
It finds the position at which the tuple is invalid. The value is not in the domain of the corresponding variable.- Parameters:
t- tuple being check for in-validity- Returns:
- the position in the tuple at which the corresponding variable does not contain the value used by tuple, -1 if no invalid position exists.
-
removeLevel
public void removeLevel(int level)
It puts back tuples which have lost their support status at the level which is being removed.- Specified by:
removeLevelin interfaceStateful- Parameters:
level- the level which is being removed.
-
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.- Specified by:
consistencyin classConstraint- Parameters:
store- constraint store within which the constraint consistency is being checked.
-
findPosition
protected int findPosition(int value, int[] values)
-
getDefaultConsistencyPruningEvent
public int getDefaultConsistencyPruningEvent()
- Specified by:
getDefaultConsistencyPruningEventin classConstraint
-
impose
public void impose(Store store)
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.
-
computeLastOfSequence
private int computeLastOfSequence(int[][] is, int posVar, int l)
-
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 classConstraint- Parameters:
level- the level of the store at which the change has occurred.var- variable which has changed.
-
smaller
boolean smaller(int[] tuple1, int[] tuple2)
-
equal
boolean equal(int[] tuple1, int[] tuple2)
-
toString
public java.lang.String toString()
Description copied from class:ConstraintIt produces a string representation of a constraint state.- Overrides:
toStringin classConstraint
-
-