Class ImpactBased
- java.lang.Object
-
- org.chocosolver.solver.search.strategy.strategy.AbstractStrategy<IntVar>
-
- org.chocosolver.solver.search.strategy.selectors.variables.ImpactBased
-
- All Implemented Interfaces:
ICause,IMonitorContradiction,IMonitorDownBranch,ISearchMonitor
public class ImpactBased extends AbstractStrategy<IntVar> implements IMonitorDownBranch, IMonitorContradiction, ICause
Implementation of the search described in: "Impact-Based Search Strategies for Constraint Programming", Philippe Refalo, CP2004.
Impacts of variables are first computed on initialisation, (only 3 values are tested for bounded variables); Ties are broken randomly.- Since:
- 21/09/12
- Author:
- Charles Prud'homme
-
-
Field Summary
-
Fields inherited from class org.chocosolver.solver.search.strategy.strategy.AbstractStrategy
vars
-
-
Constructor Summary
Constructors Constructor Description ImpactBased(IntVar[] vars, boolean initOnly)ImpactBased(IntVar[] ivariables, int alpha, int split, int nodeImpact, long seed, boolean initOnly)Create an Impact-based search strategy with Node Impact strategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterDownBranch(boolean left)Action to perform after going down in the tree searchDecision<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.booleaninit()Preparethisto be used in a search loop The initialization can detect inconsistency, in that case, it returns falsevoidonContradiction(ContradictionException cex)voidsetInitialisationTimeLimit(long timeLimit)Define a time limit on initialisation phase.voidsetReevaluationTimeLimit(long timeLimit)Define a time limit on reevaluation phase (done everynodeImpactnodes).-
Methods inherited from class org.chocosolver.solver.search.strategy.strategy.AbstractStrategy
getVariables, makeIntDecision, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.chocosolver.solver.search.loop.monitors.IMonitorDownBranch
beforeDownBranch
-
-
-
-
Constructor Detail
-
ImpactBased
public ImpactBased(IntVar[] ivariables, int alpha, int split, int nodeImpact, long seed, boolean initOnly)
Create an Impact-based search strategy with Node Impact strategy. "Impact-Based Search Strategies for Constraint Programming", Philippe Refalo, CP2004.- Parameters:
ivariables- variables of the problem (should be integers)alpha- aging parametersplit- split parameter for subdomains computationnodeImpact- force update of impacts everynodeImpactnodes. Set value to 0 to avoid using it.seed- a seed for randominitOnly- only apply the initialisation phase, do not update impact thereafter
-
ImpactBased
public ImpactBased(IntVar[] vars, boolean initOnly)
-
-
Method Detail
-
computeDecision
public Decision<IntVar> computeDecision(IntVar variable)
Description copied from class:AbstractStrategyComputes a decision to be applied to variable var This method should be implemented in order to use search patterns- Overrides:
computeDecisionin classAbstractStrategy<IntVar>- Parameters:
variable- a variable- Returns:
- a decision to be applied to variable var
-
getDecision
public Decision<IntVar> getDecision()
Description copied from class:AbstractStrategyProvides access to the current decision in the strategy. If there are no more decision to provide, it returnsnull.- Specified by:
getDecisionin classAbstractStrategy<IntVar>- Returns:
- the current decision
-
setInitialisationTimeLimit
public void setInitialisationTimeLimit(long timeLimit)
Define a time limit on initialisation phase. When the limit is reached, computing impacts on ROOT node stops and the search can start.- Parameters:
timeLimit- in milliseconds
-
setReevaluationTimeLimit
public void setReevaluationTimeLimit(long timeLimit)
Define a time limit on reevaluation phase (done everynodeImpactnodes). When the limit is reached, reevaluting impacts stops and the search can go on.- Parameters:
timeLimit- in milliseconds
-
init
public boolean init()
Description copied from class:AbstractStrategyPreparethisto be used in a search loop The initialization can detect inconsistency, in that case, it returns false- Overrides:
initin classAbstractStrategy<IntVar>
-
onContradiction
public void onContradiction(ContradictionException cex)
- Specified by:
onContradictionin interfaceIMonitorContradiction
-
afterDownBranch
public void afterDownBranch(boolean left)
Description copied from interface:IMonitorDownBranchAction to perform after going down in the tree search- Specified by:
afterDownBranchin interfaceIMonitorDownBranch- Parameters:
left- set to true to specify that this is a left branch
-
-