Package org.jacop.search
Class SimpleSelect<T extends Var>
- java.lang.Object
-
- org.jacop.search.SimpleSelect<T>
-
- All Implemented Interfaces:
SelectChoicePoint<T>
- Direct Known Subclasses:
SplitRandomSelect
,SplitRandomSelectFloat
,SplitSelect
,SplitSelectFloat
public class SimpleSelect<T extends Var> extends java.lang.Object implements SelectChoicePoint<T>
It is simple and customizable selector of decisions (constraints) which will be enforced by search.- Version:
- 4.8
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
currentIndex
(package private) static boolean
debugAll
boolean
inputOrderTieBreaking
It chooses if input order tie breaking is used.java.util.Map<T,java.lang.Integer>
position
It stores the original positions of variables to be used for input order tie-breaking.T[]
searchVariables
ComparatorVariable<T>
tieBreakingComparator
(package private) Indomain<T>
valueOrdering
ComparatorVariable<T>
variableOrdering
-
Constructor Summary
Constructors Constructor Description SimpleSelect(T[] variables, ComparatorVariable<T> varSelect, ComparatorVariable<T> tieBreakerVarSelect, Indomain<T> indomain)
It constructs a simple selection mechanism for choice points.SimpleSelect(T[] variables, ComparatorVariable<T> varSelect, Indomain<T> indomain)
The constructor to create a simple choice select mechanism.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PrimitiveConstraint
getChoiceConstraint(int index)
It always returns null as choice point is obtained by getChoiceVariable and getChoiceValue.int
getChoiceValue()
It returns a value which is the base of the next choice point.T
getChoiceVariable(int index)
It returns the variable which is the base on the next choice point.int
getIndex()
It returns the current index.java.util.Map<T,java.lang.Integer>
getVariablesMapping()
It returns the variables for which assignment in the solution is given.T
placeSearchVariable(int searchPosition, int variablePosition)
It gets as input the index of the variable which is chosen by search to be instantiated at this stage.java.lang.String
toString()
-
-
-
Field Detail
-
debugAll
static final boolean debugAll
- See Also:
- Constant Field Values
-
inputOrderTieBreaking
public boolean inputOrderTieBreaking
It chooses if input order tie breaking is used.
-
variableOrdering
public ComparatorVariable<T extends Var> variableOrdering
-
tieBreakingComparator
public ComparatorVariable<T extends Var> tieBreakingComparator
-
position
public java.util.Map<T extends Var,java.lang.Integer> position
It stores the original positions of variables to be used for input order tie-breaking.
-
currentIndex
int currentIndex
-
-
Constructor Detail
-
SimpleSelect
public SimpleSelect(T[] variables, ComparatorVariable<T> varSelect, Indomain<T> indomain)
The constructor to create a simple choice select mechanism.- Parameters:
variables
- variables upon which the choice points are created.varSelect
- the variable comparator to choose the variable.indomain
- the value heuristic to choose a value for a given variable.
-
SimpleSelect
public SimpleSelect(T[] variables, ComparatorVariable<T> varSelect, ComparatorVariable<T> tieBreakerVarSelect, Indomain<T> indomain)
It constructs a simple selection mechanism for choice points.- Parameters:
variables
- variables used as basis of the choice point.varSelect
- the main variable comparator.tieBreakerVarSelect
- secondary variable comparator employed if the first one gives the same metric.indomain
- the heuristic to choose value assigned to a chosen variable.
-
-
Method Detail
-
getChoiceVariable
public T getChoiceVariable(int index)
It returns the variable which is the base on the next choice point. Only if choice is of an X = C type. This function returns null if all variables have a value assigned or a choice point based on other type of constraint is being selected. The parameter index is the last value which have been return by this SelectChoicePoint object which has not been backtracked upon yet.- Specified by:
getChoiceVariable
in interfaceSelectChoicePoint<T extends Var>
- Parameters:
index
- the position of the last variable in selection choice point heuristic.- Returns:
- variable based on which the choice needs to be created.
-
getChoiceValue
public int getChoiceValue()
It returns a value which is the base of the next choice point. Only if choice is of an X = C type.- Specified by:
getChoiceValue
in interfaceSelectChoicePoint<T extends Var>
- Returns:
- value used in the choice point (value).
-
getChoiceConstraint
public PrimitiveConstraint getChoiceConstraint(int index)
It always returns null as choice point is obtained by getChoiceVariable and getChoiceValue.- Specified by:
getChoiceConstraint
in interfaceSelectChoicePoint<T extends Var>
- Parameters:
index
- the position of the last variable returned by selection choice point heuristic.- Returns:
- primitive constraint which is a base of a choice point.
-
getVariablesMapping
public java.util.Map<T,java.lang.Integer> getVariablesMapping()
It returns the variables for which assignment in the solution is given.- Specified by:
getVariablesMapping
in interfaceSelectChoicePoint<T extends Var>
- Returns:
- mapping of variables to the positions in the variables array.
-
getIndex
public int getIndex()
It returns the current index. Supplying this value in the next invocation of select will make search for next variable faster without comprimising efficiency.- Specified by:
getIndex
in interfaceSelectChoicePoint<T extends Var>
- Returns:
- internal position of the last variable chosen to be the base of the choice point.
-
placeSearchVariable
public T placeSearchVariable(int searchPosition, int variablePosition)
It gets as input the index of the variable which is chosen by search to be instantiated at this stage. The variable is positioned at search position.- Parameters:
searchPosition
- position at which search store currently choosen variable.variablePosition
- current position of the variable choosen by search.- Returns:
- variable choosen to be a base of the choice point.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-