SolutionType - solution type of the problems that may be solved using this search, required to extend Solutionpublic class TabuSearch<SolutionType extends Solution> extends SingleNeighbourhoodSearch<SolutionType>
If all valid neighbours of the current solution are tabu, the search stops. Note that this may never happen so that a stop criterion should preferably be set to ensure termination.
| Constructor and Description |
|---|
TabuSearch(Problem<SolutionType> problem,
Neighbourhood<? super SolutionType> neighbourhood,
TabuMemory<SolutionType> tabuMemory)
Creates a new tabu search, specifying the problem to solve, the neighbourhood used to modify the current
solution and the applied tabu memory.
|
TabuSearch(String name,
Problem<SolutionType> problem,
Neighbourhood<? super SolutionType> neighbourhood,
TabuMemory<SolutionType> tabuMemory)
Creates a new tabu search, specifying the problem to solve, the neighbourhood used to modify the current
solution, the applied tabu memory and a custom search name.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
accept(Move<? super SolutionType> move)
Overrides acceptance of a move to update the tabu memory by registering the newly visited solution.
|
void |
clearTabuMemory()
Clear the tabu memory.
|
protected void |
generateRandomInitialSolution()
Updates the tabu memory if a random initial solution is generated.
|
TabuMemory<SolutionType> |
getTabuMemory()
Get the tabu memory.
|
protected void |
searchStep()
In every step, all neighbours of the current solution are inspected and the best valid, non tabu neighbour is
adopted as the new current solution, if any.
|
void |
setCurrentSolution(SolutionType solution)
Updates the tabu memory when a custom current/initial solution is set.
|
void |
setTabuMemory(TabuMemory<SolutionType> tabuMemory)
Set the tabu memory.
|
getNeighbourhood, setNeighbourhoodevaluate, getBestMove, getNumAcceptedMoves, getNumRejectedMoves, incNumAcceptedMoves, incNumRejectedMoves, init, isImprovement, reject, setEvaluatedMoveCache, updateCurrentSolution, validategetCurrentSolution, getCurrentSolutionEvaluation, getCurrentSolutionValidation, setCurrentSolution, updateCurrentAndBestSolution, updateCurrentAndBestSolution, updateCurrentSolutionaddSearchListener, addStopCriterion, assertIdle, clearSearchListeners, clearStopCriteria, computeDelta, dispose, getBestSolution, getBestSolutionEvaluation, getBestSolutionValidation, getID, getMinDelta, getName, getProblem, getRandom, getRuntime, getSearchListeners, getStatus, getStatusLock, getSteps, getStepsWithoutImprovement, getTimeWithoutImprovement, removeSearchListener, removeStopCriterion, run, searchDisposed, searchStarted, searchStopped, setRandom, setStopCriterionCheckPeriod, start, stop, toString, updateBestSolution, updateBestSolutionpublic TabuSearch(Problem<SolutionType> problem, Neighbourhood<? super SolutionType> neighbourhood, TabuMemory<SolutionType> tabuMemory)
null. The search name defaults
to "TabuSearch".
Note that the applied neighbourhood and tabu memory should be compatible in terms of generated and accepted move
types, respectively, else an IncompatibleTabuMemoryException might be thrown during search.
problem - problem to solveneighbourhood - neighbourhood used to create neighbouring solutionstabuMemory - applied tabu memoryNullPointerException - if problem, neighbourhood or tabuMemory
are nullpublic TabuSearch(String name, Problem<SolutionType> problem, Neighbourhood<? super SolutionType> neighbourhood, TabuMemory<SolutionType> tabuMemory)
null. The search name can be null in which case the default name "TabuSearch"
is assigned.
Note that the applied neighbourhood and tabu memory should be compatible in terms of generated and accepted move
types, respectively, else an IncompatibleTabuMemoryException might be thrown during search.
name - custom search nameproblem - problem to solveneighbourhood - neighbourhood used to create neighbouring solutionstabuMemory - applied tabu memoryNullPointerException - if problem, neighbourhood or tabyMemory
are nullpublic void clearTabuMemory()
public TabuMemory<SolutionType> getTabuMemory()
public void setTabuMemory(TabuMemory<SolutionType> tabuMemory)
null.tabuMemory - new tabu memoryNullPointerException - if tabuMemory is nullprotected boolean accept(Move<? super SolutionType> move)
accept in class NeighbourhoodSearch<SolutionType extends Solution>move - move to be acceptedtrue if the update was successful, false if the move is invalidpublic void setCurrentSolution(SolutionType solution)
setCurrentSolution in class LocalSearch<SolutionType extends Solution>solution - manually specified current solutionSearchException - if the search is not idleNullPointerException - if solution is nullprotected void generateRandomInitialSolution()
generateRandomInitialSolution in class LocalSearch<SolutionType extends Solution>SearchException - if a current solution is already set when calling this methodprotected void searchStep()
searchStep in class Search<SolutionType extends Solution>IncompatibleTabuMemoryException - if the applied tabu memory is not compatible with the type of moves
generated by the applied neighbourhoodJamesRuntimeException - if depending on malfunctioning components (problem, neighbourhood, ...)Copyright © 2016. All rights reserved.