choco.kernel.solver.search
Class AbstractGlobalSearchStrategy

java.lang.Object
  extended by choco.kernel.solver.search.AbstractSearchStrategy
      extended by choco.kernel.solver.search.AbstractGlobalSearchStrategy
All Implemented Interfaces:
ISearchMeasures, ISolutionMeasures
Direct Known Subclasses:
AbstractOptimize, GlobalSearchStrategy, GoalSearchSolver

public abstract class AbstractGlobalSearchStrategy
extends AbstractSearchStrategy
implements ISearchMeasures

An abstract class for controlling tree search in various ways version 2.0.3 : change the value of search constant to use bit masks.


Field Summary
 int baseWorld
          the index of the world where the search started
protected  int currentTraceIndex
          index of the current trace in the stack
static int DOWN_BRANCH
           
protected  AbstractGlobalSearchLimit encounteredLimit
          indicates whether a limit was encountered in the alst incremental search
static int INIT_SEARCH
          constants for driving the incremental search algorithm
protected  long initialPropagation
           
 GlobalSearchLimitManager limitManager
           
 AbstractIntBranchingStrategy mainGoal
          the goal that needs be solved to drive the exploration
 int nextMove
          search controller: a flag storing the next move in the search tree
static int OPEN_NODE
           
static int RESTART
           
 AbstractSearchLoop searchLoop
           
 ShavingTools shavingTools
           
static int STOP
           
 boolean stopAtFirstSol
          indicates whether the control should stop after the first solution is found
protected  IntBranchingTrace[] traceStack
          a data structure storing the stack of choice contexts (for incremental search explorations)
static int UP_BRANCH
           
 
Fields inherited from class choco.kernel.solver.search.AbstractSearchStrategy
LOGGER, nbSolutions, solutionPool, solver
 
Constructor Summary
protected AbstractGlobalSearchStrategy(Solver solver)
           
 
Method Summary
protected  void advancedInitialPropagation()
           
 void clearTrace()
           
 void endTreeSearch()
           
 int getBackTrackCount()
          Get the backtrack count of the measure
 int getCurrentTraceIndex()
           
 AbstractGlobalSearchLimit getEncounteredLimit()
          If a limit has been encounteres, return the involved limit
 int getFailCount()
          Get the fail count of the measure
 GlobalSearchLimitManager getLimitManager()
           
 int getNodeCount()
          Get the node count of the measure
 IObjectiveManager getObjectiveManager()
           
 int getRestartCount()
          Get the restart count of the measure
 IntBranchingTrace getReusableInitialTrace()
           
 AbstractSearchLoop getSearchLoop()
           
 ShavingTools getShavingTools()
           
 int getTimeCount()
          Get the time count in milliseconds of the measure
 IntBranchingTrace getTrace(int index)
           
 int getTraceSize()
           
 void incrementalRun()
          main entry point: searching for one solution Note: the initial propagation must be done before pushing any world level.
 void initialPropagation()
           
 IntBranchingTrace initialTrace()
           
 void initMainGoal(SConstraint c)
           
 boolean isEncounteredLimit()
          Checks if a limit has been encountered
protected  boolean isFeasibleRootState()
           
 boolean isTraceEmpty()
           
 void newFeasibleRootState()
          called when the root state of the search tree is feasible.
 void newTreeSearch()
          called before a new search tree is explored
 Boolean nextSolution()
           
 String partialRuntimeStatistics(boolean logOnSolution)
           
 IntBranchingTrace popTrace()
           
 void postDynamicCut()
          called before going down into each branch of the choice point
 IntBranchingTrace pushTrace()
           
 void recordSolution()
          called when a solution is encountered: printing and, if needed, storing the solution
 String runtimeStatistics()
           
 void setEncounteredLimit(AbstractGlobalSearchLimit encounteredLimit)
           
 void setLimitManager(GlobalSearchLimitManager limitManager)
           
 void setSearchLoop(AbstractSearchLoop searchLoop)
           
 void setShavingTools(ShavingTools shavingTools)
           
protected  void topDownSearch()
           
 IntBranchingTrace topTrace()
           
 void writeSolution(Solution sol)
           
 
Methods inherited from class choco.kernel.solver.search.AbstractSearchStrategy
existsSolution, getSolutionCount, getSolutionPool, getSolver, getStoredSolutions, resetSolutions, restoreBestSolution, setSolutionPool
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface choco.kernel.solver.search.measure.ISearchMeasures
getSolutionCount
 

Field Detail

INIT_SEARCH

public static final int INIT_SEARCH
constants for driving the incremental search algorithm

See Also:
Constant Field Values

OPEN_NODE

public static final int OPEN_NODE
See Also:
Constant Field Values

UP_BRANCH

public static final int UP_BRANCH
See Also:
Constant Field Values

DOWN_BRANCH

public static final int DOWN_BRANCH
See Also:
Constant Field Values

RESTART

public static final int RESTART
See Also:
Constant Field Values

STOP

public static final int STOP
See Also:
Constant Field Values

currentTraceIndex

protected int currentTraceIndex
index of the current trace in the stack


traceStack

protected IntBranchingTrace[] traceStack
a data structure storing the stack of choice contexts (for incremental search explorations)


nextMove

public int nextMove
search controller: a flag storing the next move in the search tree


stopAtFirstSol

public final boolean stopAtFirstSol
indicates whether the control should stop after the first solution is found


encounteredLimit

protected AbstractGlobalSearchLimit encounteredLimit
indicates whether a limit was encountered in the alst incremental search


mainGoal

public AbstractIntBranchingStrategy mainGoal
the goal that needs be solved to drive the exploration


baseWorld

public int baseWorld
the index of the world where the search started


shavingTools

public ShavingTools shavingTools

limitManager

public GlobalSearchLimitManager limitManager

searchLoop

public AbstractSearchLoop searchLoop

initialPropagation

protected long initialPropagation
Constructor Detail

AbstractGlobalSearchStrategy

protected AbstractGlobalSearchStrategy(Solver solver)
Method Detail

initMainGoal

public void initMainGoal(SConstraint c)

getObjectiveManager

public IObjectiveManager getObjectiveManager()

getLimitManager

public final GlobalSearchLimitManager getLimitManager()

getSearchLoop

public final AbstractSearchLoop getSearchLoop()

getShavingTools

public final ShavingTools getShavingTools()

setShavingTools

public final void setShavingTools(ShavingTools shavingTools)

setSearchLoop

public final void setSearchLoop(AbstractSearchLoop searchLoop)

setLimitManager

public final void setLimitManager(GlobalSearchLimitManager limitManager)

isFeasibleRootState

protected final boolean isFeasibleRootState()

initialPropagation

public final void initialPropagation()

advancedInitialPropagation

protected void advancedInitialPropagation()
                                   throws ContradictionException
Throws:
ContradictionException

topDownSearch

protected final void topDownSearch()

incrementalRun

public void incrementalRun()
main entry point: searching for one solution Note: the initial propagation must be done before pushing any world level. It is therefore kept before restoring a solution


newTreeSearch

public void newTreeSearch()
                   throws ContradictionException
called before a new search tree is explored

Throws:
ContradictionException

newFeasibleRootState

public void newFeasibleRootState()
called when the root state of the search tree is feasible.


endTreeSearch

public void endTreeSearch()

nextSolution

public Boolean nextSolution()

writeSolution

public void writeSolution(Solution sol)
Overrides:
writeSolution in class AbstractSearchStrategy

recordSolution

public void recordSolution()
called when a solution is encountered: printing and, if needed, storing the solution

Overrides:
recordSolution in class AbstractSearchStrategy

postDynamicCut

public void postDynamicCut()
                    throws ContradictionException
called before going down into each branch of the choice point

Throws:
ContradictionException

pushTrace

public final IntBranchingTrace pushTrace()

isTraceEmpty

public final boolean isTraceEmpty()

getTrace

public final IntBranchingTrace getTrace(int index)

getCurrentTraceIndex

public final int getCurrentTraceIndex()

getTraceSize

public final int getTraceSize()

popTrace

public final IntBranchingTrace popTrace()

initialTrace

public final IntBranchingTrace initialTrace()

getReusableInitialTrace

public final IntBranchingTrace getReusableInitialTrace()

topTrace

public final IntBranchingTrace topTrace()

clearTrace

public final void clearTrace()

runtimeStatistics

public String runtimeStatistics()

partialRuntimeStatistics

public String partialRuntimeStatistics(boolean logOnSolution)

getTimeCount

public int getTimeCount()
Description copied from interface: ISearchMeasures
Get the time count in milliseconds of the measure

Specified by:
getTimeCount in interface ISearchMeasures
Returns:
the time elapsed during the last search in milliseconds

getNodeCount

public int getNodeCount()
Description copied from interface: ISearchMeasures
Get the node count of the measure

Specified by:
getNodeCount in interface ISearchMeasures
Returns:
the number of nodes of the tree search (including the root node where initial propagation has been performed and saved)

getBackTrackCount

public int getBackTrackCount()
Description copied from interface: ISearchMeasures
Get the backtrack count of the measure

Specified by:
getBackTrackCount in interface ISearchMeasures
Returns:
the number of backtracks of the tree search

getRestartCount

public int getRestartCount()
Description copied from interface: ISearchMeasures
Get the restart count of the measure

Specified by:
getRestartCount in interface ISearchMeasures
Returns:
restart count

getFailCount

public int getFailCount()
Description copied from interface: ISearchMeasures
Get the fail count of the measure

Specified by:
getFailCount in interface ISearchMeasures
Returns:
the number of fails of the tree search

isEncounteredLimit

public final boolean isEncounteredLimit()
Checks if a limit has been encountered

Returns:
true if a limit has been reached

getEncounteredLimit

public final AbstractGlobalSearchLimit getEncounteredLimit()
If a limit has been encounteres, return the involved limit

Returns:
the encoutered limit

setEncounteredLimit

public final void setEncounteredLimit(AbstractGlobalSearchLimit encounteredLimit)


Copyright © 2012. All Rights Reserved.