Module org.chocosolver
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 void
afterDownBranch(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.boolean
init()
Preparethis
to be used in a search loop The initialization can detect inconsistency, in that case, it returns falsevoid
onContradiction(ContradictionException cex)
void
remove()
Remove the current strategy.void
setInitialisationTimeLimit(long timeLimit)
Define a time limit on initialisation phase.void
setReevaluationTimeLimit(long timeLimit)
Define a time limit on reevaluation phase (done everynodeImpact
nodes).-
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.ICause
explain, forEachIntVar
-
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 everynodeImpact
nodes. 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: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
-
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 everynodeImpact
nodes). 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: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>
-
remove
public void remove()
Description copied from class:AbstractStrategy
Remove the current strategy. This implies unplugging variable or search monitors.- Overrides:
remove
in classAbstractStrategy<IntVar>
-
onContradiction
public void onContradiction(ContradictionException cex)
- Specified by:
onContradiction
in interfaceIMonitorContradiction
-
afterDownBranch
public void afterDownBranch(boolean left)
Description copied from interface:IMonitorDownBranch
Action to perform after going down in the tree search- Specified by:
afterDownBranch
in interfaceIMonitorDownBranch
- Parameters:
left
- set to true to specify that this is a left branch
-
-