- java.lang.Object
-
- org.chocosolver.solver.search.loop.move.MoveBinaryDFS
-
- All Implemented Interfaces:
Move
- Direct Known Subclasses:
MoveBinaryHBFS
,MoveBinaryLDS
public class MoveBinaryDFS extends Object implements Move
A move dedicated to run a Depth First Search with binary decisions.Created by cprudhom on 02/09/15. Project: choco.
- Since:
- 3.3.1
- Author:
- Charles Prud'homme
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractStrategy
strategy
Search strategy to extend the search treeprotected int
topDecisionPosition
Index, in the decision path, of the decision taken just before selecting this move.
-
Constructor Summary
Constructors Constructor Description MoveBinaryDFS()
Create this move without any search strategyMoveBinaryDFS(AbstractStrategy strategy)
Create this move with a search strategy
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
extend(Solver solver)
Performs a move when the CSP associated to the current node of the search space is not proven to be not consistent.List<Move>
getChildMoves()
Returns the child moves or null Some Move only accepts one single move as child.<V extends Variable>
AbstractStrategy<V>getStrategy()
Returns the search strategy in use.boolean
init()
Called before the search starts.protected void
prevDecision(Solver solver)
Backtrack in the search treevoid
removeStrategy()
Erases the defined search strategy.boolean
repair(Solver solver)
Performs a move when the CSP associated to the current node of the search space is proven to be not consistent.protected boolean
rewind(Solver solver)
Go back in the search tree.void
setChildMoves(List<Move> someMoves)
Overrides this child moves (if possible and if any).<V extends Variable>
voidsetStrategy(AbstractStrategy<V> aStrategy)
Defines a search strategy, that is, a service which computes and returns decisions.void
setTopDecisionPosition(int position)
Indicates the position of decision made just before selecting this move.
-
-
-
Field Detail
-
strategy
protected AbstractStrategy strategy
Search strategy to extend the search tree
-
topDecisionPosition
protected int topDecisionPosition
Index, in the decision path, of the decision taken just before selecting this move.
-
-
Constructor Detail
-
MoveBinaryDFS
public MoveBinaryDFS()
Create this move without any search strategy
-
MoveBinaryDFS
public MoveBinaryDFS(AbstractStrategy strategy)
Create this move with a search strategy- Parameters:
strategy
- a search strategy
-
-
Method Detail
-
init
public boolean init()
Description copied from interface:Move
Called before the search starts. Also initializes the search strategy.
-
extend
public boolean extend(Solver solver)
Description copied from interface:Move
Performs a move when the CSP associated to the current node of the search space is not proven to be not consistent.
-
repair
public boolean repair(Solver solver)
Description copied from interface:Move
Performs a move when the CSP associated to the current node of the search space is proven to be not consistent.
-
setTopDecisionPosition
public void setTopDecisionPosition(int position)
Description copied from interface:Move
Indicates the position of decision made just before selecting this move. When only one "terminal" move is declared, the top decision decision is -1. When dealing with a sequence of Move, the position is the one of the last decision of the previous move. In consequence, when backtracking, the right move can be applied or stopped when needed. This has to be declared on the first call toMove.extend(Solver)
and is checked onMove.repair(Solver)
.- Specified by:
setTopDecisionPosition
in interfaceMove
- Parameters:
position
- position of the last decision taken before applying this move
-
getStrategy
public <V extends Variable> AbstractStrategy<V> getStrategy()
Description copied from interface:Move
Returns the search strategy in use.- Specified by:
getStrategy
in interfaceMove
- Type Parameters:
V
- the type of variable managed by the strategy- Returns:
- the current search strategy
-
setStrategy
public <V extends Variable> void setStrategy(AbstractStrategy<V> aStrategy)
Description copied from interface:Move
Defines a search strategy, that is, a service which computes and returns decisions.- Specified by:
setStrategy
in interfaceMove
- Type Parameters:
V
- the type of variable managed by the strategy- Parameters:
aStrategy
- a search strategy
-
removeStrategy
public void removeStrategy()
Description copied from interface:Move
Erases the defined search strategy.- Specified by:
removeStrategy
in interfaceMove
-
rewind
protected boolean rewind(Solver solver)
Go back in the search tree. Either refute a decision, or backtrack.- Parameters:
solver
- reference to the solver- Returns:
true
if a reparation has been found
-
prevDecision
protected void prevDecision(Solver solver)
Backtrack in the search tree- Parameters:
solver
- reference to the solver
-
getChildMoves
public List<Move> getChildMoves()
Description copied from interface:Move
Returns the child moves or null Some Move only accepts one single move as child.- Specified by:
getChildMoves
in interfaceMove
- Returns:
- the child moves
-
setChildMoves
public void setChildMoves(List<Move> someMoves)
Description copied from interface:Move
Overrides this child moves (if possible and if any). Some Move only accepts one single move as child.- Specified by:
setChildMoves
in interfaceMove
- Parameters:
someMoves
- a new child move
-
-