Module org.chocosolver
Class AbstractStrategy<V extends Variable>
- java.lang.Object
-
- org.chocosolver.solver.search.strategy.strategy.AbstractStrategy<V>
-
- Direct Known Subclasses:
ActivityBased
,BoundSearch
,ConflictOrderingSearch
,DomOverWDeg
,FindAndProve
,GreedyBranching
,ImpactBased
,IntStrategy
,LastConflict
,ObjectiveStrategy
,RealStrategy
,SetStrategy
,StrategiesSequencer
public abstract class AbstractStrategy<V extends Variable> extends Object
A search strategy provides decisions to go down in the search space. The main method iscomputeDecision(Variable)
which returns the next decision to apply.- Since:
- 1 juil. 2010
- Author:
- Charles Prud'homme
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractStrategy(V... variables)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Decision<V>
computeDecision(V var)
Computes a decision to be applied to variable var This method should be implemented in order to use search patternsabstract Decision<V>
getDecision()
Provides access to the current decision in the strategy.V[]
getVariables()
boolean
init()
Preparethis
to be used in a search loop The initialization can detect inconsistency, in that case, it returns falseprotected IntDecision
makeIntDecision(IntVar var, int val)
Creates an assignment decision object for integer variables Just a simple shortcut for : solver.getDecisionPath().makeIntDecision(var,DecisionOperatorFactory.makeIntEq(),val);void
remove()
Remove the current strategy.String
toString()
Creates aString
object containing a pretty print of the current variables.
-
-
-
Constructor Detail
-
AbstractStrategy
@SafeVarargs protected AbstractStrategy(V... variables)
-
-
Method Detail
-
init
public boolean init()
Preparethis
to be used in a search loop The initialization can detect inconsistency, in that case, it returns false
-
remove
public void remove()
Remove the current strategy. This implies unplugging variable or search monitors.
-
getDecision
public abstract Decision<V> getDecision()
Provides access to the current decision in the strategy. If there are no more decision to provide, it returnsnull
.- Returns:
- the current decision
-
toString
public String toString()
Creates aString
object containing a pretty print of the current variables.
-
computeDecision
protected Decision<V> computeDecision(V var)
Computes a decision to be applied to variable var This method should be implemented in order to use search patterns- Parameters:
var
- a variable- Returns:
- a decision to be applied to variable var
-
getVariables
public V[] getVariables()
- Returns:
- array of variables
-
makeIntDecision
protected final IntDecision makeIntDecision(IntVar var, int val)
Creates an assignment decision object for integer variables Just a simple shortcut for : solver.getDecisionPath().makeIntDecision(var,DecisionOperatorFactory.makeIntEq(),val);- Parameters:
var
- variable to branch onval
- value to branch on- Returns:
- an assignment decision object (var = val) for integer variables
-
-