Package org.jacop.constraints
Class Element
- java.lang.Object
-
- org.jacop.constraints.DecomposedConstraint<Constraint>
-
- org.jacop.constraints.Constraint
-
- org.jacop.constraints.Element
-
- All Implemented Interfaces:
UsesQueueVariable
public class Element extends Constraint implements UsesQueueVariable
Element constraint implements the element/4 constraint (both with integer list and variables list). It defines a following relation variables[index + shift] = value. The default shift value is equal to zero. The first index in the variables list is equal to 1.- Version:
- 4.8
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Constraint
c
-
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 Element(IntVar index, int[] values, IntVar value)
Deprecated.Element(IntVar index, int[] values, IntVar value, int shift)
Deprecated.Element(IntVar index, java.util.List<? extends IntVar> variables, IntVar value)
Deprecated.Element(IntVar index, java.util.List<? extends IntVar> variables, IntVar value, int shift)
Deprecated.Element(IntVar index, IntVar[] variables, IntVar value)
Deprecated.Element(IntVar index, IntVar[] variables, IntVar value, int shift)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<Var>
arguments()
It returns the variables in a scope of the constraint.static Constraint
choose(IntVar index, int[] values, IntVar value)
It constructs element constraint based on variables.static Constraint
choose(IntVar index, int[] values, IntVar value, int shift)
It constructs element constraint based on variables.static Constraint
choose(IntVar index, java.util.List<? extends IntVar> variables, IntVar value)
It constructs element constraint based on variables.static Constraint
choose(IntVar index, java.util.List<? extends IntVar> variables, IntVar value, int shift)
It constructs element constraint based on variables.static Constraint
choose(IntVar index, IntVar[] variables, IntVar value)
It constructs element constraint based on variables.static Constraint
choose(IntVar index, IntVar[] variables, IntVar value, int shift)
It constructs element constraint based on variables.void
consistency(Store store)
It is a (most probably incomplete) consistency function which removes the values from variables domains.int
getConsistencyPruningEvent(Var var)
It retrieves the pruning event which causes reevaluation of the constraint.int
getDefaultConsistencyPruningEvent()
java.lang.String
id()
It gives the id string of a constraint.void
impose(Store store)
It imposes the constraint in a given store.void
increaseWeight()
It increases the weight of the variables in the constraint scope.void
queueVariable(int level, Var V)
This is a function called to indicate which variable in a scope of constraint has changed.void
removeConstraint()
It removes the constraint by removing this constraint from all variables.java.lang.String
toString()
It produces a string representation of a constraint state.-
Methods inherited from class org.jacop.constraints.Constraint
afc, cleanAfterFailure, decompose, getGuideConstraint, getGuideValue, getGuideVariable, grounded, grounded, impose, imposeDecomposition, intArrayToString, long2int, numberArgs, 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
-
c
Constraint c
-
-
Constructor Detail
-
Element
@Deprecated public Element(IntVar index, java.util.List<? extends IntVar> variables, IntVar value)
Deprecated.It constructs element constraint based on variables. The default shift value is equal 0.- Parameters:
index
- index variable.variables
- list of variables.value
- variable to which index variable is equal to.
-
Element
@Deprecated public Element(IntVar index, java.util.List<? extends IntVar> variables, IntVar value, int shift)
Deprecated.It constructs element constraint based on variables.- Parameters:
index
- index variable.variables
- variables list.value
- value variable.shift
- shift by which the index value is moved to the left.
-
Element
@Deprecated public Element(IntVar index, int[] values, IntVar value)
Deprecated.It constructs element constraint based on variables. The default shift value is equal 0.- Parameters:
index
- index variable.values
- list of integers.value
- variable to which index variable is equal to.
-
Element
@Deprecated public Element(IntVar index, int[] values, IntVar value, int shift)
Deprecated.It constructs element constraint based on variables.- Parameters:
index
- index variable.values
- integer list.value
- value variable.shift
- shift by which the index value is moved to the left.
-
Element
@Deprecated public Element(IntVar index, IntVar[] variables, IntVar value)
Deprecated.It constructs element constraint based on variables. The default shift value is equal 0.- Parameters:
index
- index variable.variables
- list of integers.value
- variable to which index variable is equal to.
-
Element
@Deprecated public Element(IntVar index, IntVar[] variables, IntVar value, int shift)
Deprecated.It constructs element constraint based on variables.- Parameters:
index
- index variable.variables
- variables list.value
- value variable.shift
- shift by which the index value is moved to the left.
-
-
Method Detail
-
arguments
public java.util.Set<Var> arguments()
Description copied from class:Constraint
It returns the variables in a scope of the constraint.- Overrides:
arguments
in classConstraint
- Returns:
- variables in a scope of the constraint.
-
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.
-
getConsistencyPruningEvent
public int getConsistencyPruningEvent(Var var)
Description copied from class:Constraint
It retrieves the pruning event which causes reevaluation of the constraint.- Overrides:
getConsistencyPruningEvent
in classConstraint
- Parameters:
var
- variable for which pruning event is retrieved- Returns:
- it returns the int code of the pruning event (GROUND, BOUND, ANY, NONE)
-
getDefaultConsistencyPruningEvent
public int getDefaultConsistencyPruningEvent()
- Specified by:
getDefaultConsistencyPruningEvent
in classConstraint
-
id
public java.lang.String id()
Description copied from class:Constraint
It gives the id string of a constraint.- Overrides:
id
in classConstraint
- Returns:
- string id of the constraint.
-
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 V)
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.V
- variable which has changed.
-
removeConstraint
public void removeConstraint()
Description copied from class:Constraint
It removes the constraint by removing this constraint from all variables.- 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
-
increaseWeight
public void increaseWeight()
Description copied from class:Constraint
It increases the weight of the variables in the constraint scope.- Overrides:
increaseWeight
in classConstraint
-
choose
public static Constraint choose(IntVar index, java.util.List<? extends IntVar> variables, IntVar value)
It constructs element constraint based on variables. The default shift value is equal 0.- Parameters:
index
- index variable.variables
- list of variables.value
- variable to which index variable is equal to.- Returns:
- constraint that encodes the desired logic.
-
choose
public static Constraint choose(IntVar index, java.util.List<? extends IntVar> variables, IntVar value, int shift)
It constructs element constraint based on variables.- Parameters:
index
- index variable.variables
- variables list.value
- value variable.shift
- shift by which the index value is moved to the left.- Returns:
- constraint that encodes the desired logic.
-
choose
public static Constraint choose(IntVar index, int[] values, IntVar value)
It constructs element constraint based on variables. The default shift value is equal 0.- Parameters:
index
- index variable.values
- list of integers.value
- variable to which index variable is equal to.- Returns:
- constraint that encodes the desired logic.
-
choose
public static Constraint choose(IntVar index, int[] values, IntVar value, int shift)
It constructs element constraint based on variables.- Parameters:
index
- index variable.values
- integer list.value
- value variable.shift
- shift by which the index value is moved to the left.- Returns:
- constraint that encodes the desired logic.
-
choose
public static Constraint choose(IntVar index, IntVar[] variables, IntVar value)
It constructs element constraint based on variables. The default shift value is equal 0.- Parameters:
index
- index variable.variables
- list of integers.value
- variable to which index variable is equal to.- Returns:
- constraint that encodes the desired logic.
-
choose
public static Constraint choose(IntVar index, IntVar[] variables, IntVar value, int shift)
It constructs element constraint based on variables.- Parameters:
index
- index variable.variables
- variables list.value
- value variable.shift
- shift by which the index value is moved to the left.- Returns:
- constraint that encodes the desired logic.
-
-