Class MoveLNS
- java.lang.Object
-
- org.chocosolver.solver.search.loop.move.MoveLNS
-
-
Field Summary
Fields Modifier and Type Field Description protected ICountercounterRestart counterprotected longfrequencyFor restart strategyprotected booleanfreshRestartIndicate a restart has been triggeredprotected Movemovethe strategy required to complete the generated fragmentprotected INeighborneighborNeighbor to usedprotected longsolutionsNumber of solutions found so far
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoRestart(Solver solver)Extend the neighbor when conditions are met and do the restartbooleanextend(Solver solver)Return false when: the underlying search has no more decision to provide,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.booleaninit()Called before the search starts.voidloadFromSolution(Solution solution, Solver solver)Give an initial solution to begin with if called before executing the solving process or erase the last recorded one otherwise.booleanrepair(Solver solver)Return false when : move.repair(searchLoop) returns false and neighbor is complete.voidsetChildMoves(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.voidsetTopDecisionPosition(int position)Indicates the position of decision made just before selecting this move.
-
-
-
Field Detail
-
move
protected Move move
the strategy required to complete the generated fragment
-
neighbor
protected INeighbor neighbor
Neighbor to used
-
solutions
protected long solutions
Number of solutions found so far
-
freshRestart
protected boolean freshRestart
Indicate a restart has been triggered
-
counter
protected ICounter counter
Restart counter
-
frequency
protected long frequency
For restart strategy
-
-
Method Detail
-
init
public boolean init()
Description copied from interface:MoveCalled before the search starts. Also initializes the search strategy.
-
extend
public boolean extend(Solver solver)
Return false when:- the underlying search has no more decision to provide,
Return true when:
- a new neighbor is provided,
- or a new decision is provided by the underlying decision
- or the fast restart criterion is met.
Restart when:
- a restart criterion is met
-
repair
public boolean repair(Solver solver)
Return false when :- move.repair(searchLoop) returns false and neighbor is complete.
- posting the cut at root node fails
- move.repair(searchLoop) returns true,
- or move.repair(searchLoop) returns false and neighbor is not complete,
Restart when:
- a new solution has been found
- move.repair(searchLoop) returns false and neighbor is not complete,
- or the fast restart criterion is met
-
loadFromSolution
public void loadFromSolution(Solution solution, Solver solver)
Give an initial solution to begin with if called before executing the solving process or erase the last recorded one otherwise.- Parameters:
solution- a solution to recordsolver- that manages the LNS
-
setTopDecisionPosition
public void setTopDecisionPosition(int position)
Description copied from interface:MoveIndicates 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:
setTopDecisionPositionin 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:MoveReturns the search strategy in use.- Specified by:
getStrategyin 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:MoveDefines a search strategy, that is, a service which computes and returns decisions.- Specified by:
setStrategyin interfaceMove- Type Parameters:
V- the type of variable managed by the strategy- Parameters:
aStrategy- a search strategy
-
doRestart
protected void doRestart(Solver solver)
Extend the neighbor when conditions are met and do the restart- Parameters:
solver- SearchLoop
-
getChildMoves
public List<Move> getChildMoves()
Description copied from interface:MoveReturns the child moves or null Some Move only accepts one single move as child.- Specified by:
getChildMovesin interfaceMove- Returns:
- the child moves
-
setChildMoves
public void setChildMoves(List<Move> someMoves)
Description copied from interface:MoveOverrides this child moves (if possible and if any). Some Move only accepts one single move as child.- Specified by:
setChildMovesin interfaceMove- Parameters:
someMoves- a new child move
-
-