Package org.jacop.constraints
Class ExtensionalSupportVA
- java.lang.Object
-
- org.jacop.constraints.DecomposedConstraint<Constraint>
-
- org.jacop.constraints.Constraint
-
- org.jacop.constraints.ExtensionalSupportVA
-
- All Implemented Interfaces:
Stateful
,UsesQueueVariable
public class ExtensionalSupportVA extends Constraint implements UsesQueueVariable, Stateful
Extensional constraint assures that one of the tuples is enforced in the relation.This implementation tries to balance the usage of memory versus time efficiency.
- Version:
- 4.7
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static boolean
debugAll
(package private) static boolean
debugPruning
(package private) boolean
firstConsistencyCheck
(package private) static java.util.concurrent.atomic.AtomicInteger
idNumber
It specifies the id of the constraint.(package private) int
levelOfFirstConsistencyCheck
IntVar[]
list
It stores variables within this extensional constraint, order does matter.(package private) int[][][][]
tuples
It represents tuples which are supports for each of the variables.private int[][]
tuplesFromConstructor
(package private) int[][]
values
It represents values which are supported for a variable.(package private) java.util.LinkedHashSet<IntVar>
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 ExtensionalSupportVA(java.util.List<? extends IntVar> variables, int[][] tuples)
The constructor does not create local copy of tuples array.ExtensionalSupportVA(IntVar[] list)
Partial constructor which stores variables involved in a constraint but does not get information about tuples yet.ExtensionalSupportVA(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 void
consistency(Store store)
It is a (most probably incomplete) consistency function which removes the values from variables domains.(package private) boolean
equal(int[] tuple1, int[] tuple2)
int[]
findFirstAllowed(int varPosition, int value, int[] t)
It finds the first allowed tuple from the given tuple.protected int
findPosition(int value, int[] values)
int
getDefaultConsistencyPruningEvent()
void
impose(Store store)
It imposes the constraint in a given store.void
queueVariable(int level, Var var)
This is a function called to indicate which variable in a scope of constraint has changed.void
removeLevel(int level)
It puts back tuples which have lost their support status at the level which is being removed.int
seekInvalidPosition(int[] t)
It gives the position of the variable for which current domain of this variable does not hold the used value.int[]
seekSupportVA(int varPosition, int value)
It seeks support for a given variable-value pair.int[]
setFirstValid(int varPosition, int value)
It computes the first valid tuple for a given variable-value pair.(package private) boolean
smaller(int[] tuple1, int[] tuple2)
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, 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
It specifies the id of the constraint.
-
firstConsistencyCheck
boolean firstConsistencyCheck
-
levelOfFirstConsistencyCheck
int levelOfFirstConsistencyCheck
-
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
private int[][] tuplesFromConstructor
-
values
int[][] values
It represents values which are supported for a variable.
-
variableQueue
java.util.LinkedHashSet<IntVar> variableQueue
-
list
public IntVar[] list
It stores variables within this extensional constraint, order does matter.
-
-
Constructor Detail
-
ExtensionalSupportVA
public ExtensionalSupportVA(IntVar[] list)
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 the constraint
-
ExtensionalSupportVA
public ExtensionalSupportVA(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 constraint scope.tuples
- the tuples which are supports for the constraint.
-
ExtensionalSupportVA
public ExtensionalSupportVA(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
- the constraint scope.tuples
- the tuples which are supports for the constraint.
-
-
Method Detail
-
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:
removeLevel
in interfaceStateful
- Parameters:
level
- the level which is being removed.
-
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.
-
findPosition
protected int findPosition(int value, int[] values)
-
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.
-
queueVariable
public void queueVariable(int level, Var var)
Description copied from class:Constraint
This 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:
queueVariable
in 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:Constraint
It produces a string representation of a constraint state.- Overrides:
toString
in classConstraint
-
seekSupportVA
public int[] seekSupportVA(int varPosition, int value)
It seeks support for a given variable-value pair.- Parameters:
varPosition
- position of the variable for which the support is seek.value
- value for which the support is seek.- Returns:
- support tuple.
-
setFirstValid
public int[] setFirstValid(int varPosition, int value)
It computes the first valid tuple for a given variable-value pair.- Parameters:
varPosition
- position of the variable.value
- value for which the fist valid tuple is seek.- Returns:
- first valid tuple.
-
findFirstAllowed
public int[] findFirstAllowed(int varPosition, int value, int[] t)
It finds the first allowed tuple from the given tuple.- Parameters:
varPosition
- position of the variable.value
- value for which first allowed tuple is seek.t
- tuple from which the search commences.- Returns:
- first allowed tuple for a given variable-value pair.
-
seekInvalidPosition
public int seekInvalidPosition(int[] t)
It gives the position of the variable for which current domain of this variable does not hold the used value. It is variable because of which allowed tuple does not become a support tuple.- Parameters:
t
- tuple being checked.- Returns:
- -1 if tuple is both valid and allowed (support), otherwise the position.
-
-