- java.lang.Object
-
- org.chocosolver.solver.search.strategy.strategy.AbstractStrategy<IntVar>
-
- org.chocosolver.solver.search.strategy.strategy.IntStrategy
-
- Direct Known Subclasses:
FullyRandom
public class IntStrategy extends AbstractStrategy<IntVar>
Class to perform branching decisions over integer variables- Since:
- 2 juil. 2010
- Author:
- Charles Prud'homme, Jean-Guillaume Fages
-
-
Field Summary
Fields Modifier and Type Field Description protected IntValueSelector
valueSelector
How a value is selected-
Fields inherited from class org.chocosolver.solver.search.strategy.strategy.AbstractStrategy
vars
-
-
Constructor Summary
Constructors Constructor Description IntStrategy(IntVar[] scope, VariableSelector<IntVar> varSelector, IntValueSelector valSelector)
Creates a search strategy which selects a variable X and a value V to perform the decision X = V BEWARE: if the variable domain is not enumerated, the value V should be a domain bound.IntStrategy(IntVar[] scope, VariableSelector<IntVar> varSelector, IntValueSelector valSelector, DecisionOperator<IntVar> decOperator)
Creates a search strategy which selects a variable X and a value V to perform the decision X decOperator V This can be X <= V for instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Decision<IntVar>
computeDecision(IntVar variable)
Computes a decision to be applied to variable var This method should be implemented in order to use search patternsDecision<IntVar>
getDecision()
Provides access to the current decision in the strategy.DecisionOperator<IntVar>
getDecisionOperator()
IntValueSelector
getValSelector()
VariableSelector<IntVar>
getVarSelector()
boolean
init()
Preparethis
to be used in a search loop The initialization can detect inconsistency, in that case, it returns false-
Methods inherited from class org.chocosolver.solver.search.strategy.strategy.AbstractStrategy
getVariables, makeIntDecision, remove, toString
-
-
-
-
Field Detail
-
valueSelector
protected IntValueSelector valueSelector
How a value is selected
-
-
Constructor Detail
-
IntStrategy
public IntStrategy(IntVar[] scope, VariableSelector<IntVar> varSelector, IntValueSelector valSelector)
Creates a search strategy which selects a variable X and a value V to perform the decision X = V BEWARE: if the variable domain is not enumerated, the value V should be a domain bound. Otherwise, the decision cannot be negated, and the search may loop infinitely.- Parameters:
scope
- defines which variables to branch onvarSelector
- defines how to select the next variable to branch onvalSelector
- defines how to select the value involved in the branching decision
-
IntStrategy
public IntStrategy(IntVar[] scope, VariableSelector<IntVar> varSelector, IntValueSelector valSelector, DecisionOperator<IntVar> decOperator)
Creates a search strategy which selects a variable X and a value V to perform the decision X decOperator V This can be X <= V for instance. BEWARE: if the variable domain is not enumerated, and if the operator is either "=" or "!=", then the value V should be a domain bound. Otherwise, the decision cannot be negated, and the search may loop infinitely.- Parameters:
scope
- defines which variables to branch onvarSelector
- defines how to select the next variable to branch onvalSelector
- defines how to select the value involved in the branching decisiondecOperator
- defines what to do in a branching decision
-
-
Method Detail
-
init
public boolean init()
Description copied from class:AbstractStrategy
Preparethis
to be used in a search loop The initialization can detect inconsistency, in that case, it returns false- Overrides:
init
in classAbstractStrategy<IntVar>
-
computeDecision
public Decision<IntVar> computeDecision(IntVar variable)
Description copied from class:AbstractStrategy
Computes a decision to be applied to variable var This method should be implemented in order to use search patterns- Overrides:
computeDecision
in classAbstractStrategy<IntVar>
- Parameters:
variable
- a variable- Returns:
- a decision to be applied to variable var
-
getDecision
public Decision<IntVar> getDecision()
Description copied from class:AbstractStrategy
Provides access to the current decision in the strategy. If there are no more decision to provide, it returnsnull
.- Specified by:
getDecision
in classAbstractStrategy<IntVar>
- Returns:
- the current decision
-
getVarSelector
public VariableSelector<IntVar> getVarSelector()
-
getValSelector
public IntValueSelector getValSelector()
-
getDecisionOperator
public DecisionOperator<IntVar> getDecisionOperator()
-
-