SolutionType
- solution type of the problems that may be solved using this search, required to extend Solution
public class PipedLocalSearch<SolutionType extends Solution> extends LocalSearch<SolutionType>
A piped local search consists of a composition of other local search \(S_1, ..., S_n\). These local searches are consecutively executed in a pipeline where the best solution found by search \(S_i, i \le 1 \lt n,\) is used as initial solution for search \(S_{i+1}\). The initial solution of search \(S_1\) corresponds to the initial solution that has been set for the piped local search, if any; else, \(S_1\) starts from a randomly generated solution. The best solution obtained after executing the entire pipeline is eventually returned as the global best solution of the piped search.
This search is a single step search, meaning that execution of the entire pipeline is considered to be one step of the piped search and that the global algorithm terminates when this step has completed. Moreover, a piped local search can be started only once. After its single step has completed, the search will automatically dispose itself together with all contained local searches.
Only searches solving the same problem as the one specified when creating the piped local search can be included in the pipeline.
When a piped local search is requested to stop, this request is propagated to the searches included in the pipeline. Similarly, when a piped local search is disposed, all searches in the pipeline are also disposed.
Constructor and Description |
---|
PipedLocalSearch(Problem<SolutionType> problem,
List<LocalSearch<SolutionType>> pipeline)
Creates a new piped local search, specifying the problem to solve and a list of local searches to
be executed in the pipeline, in the given order.
|
PipedLocalSearch(String name,
Problem<SolutionType> problem,
List<LocalSearch<SolutionType>> pipeline)
Creates a new piped local search, specifying the problem to solve, a list of local searches to
be executed in the pipeline in the given order, and a custom search name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
searchDisposed()
When disposing a piped local search, all searches in the pipeline are also disposed.
|
protected void |
searchStep()
Executes all local searches in the pipeline, where the best solution of the previous search is used as initial
solution for the next search.
|
void |
start()
General start method is overriden so that search is automatically disposed when
Search.start() returns. |
void |
stop()
When requesting to stop a piped local search, this request is propagated to each search in the pipeline.
|
generateRandomInitialSolution, getCurrentSolution, getCurrentSolutionEvaluation, getCurrentSolutionValidation, init, setCurrentSolution, setCurrentSolution, updateCurrentAndBestSolution, updateCurrentAndBestSolution, updateCurrentSolution, updateCurrentSolution
addSearchListener, addStopCriterion, assertIdle, clearSearchListeners, clearStopCriteria, computeDelta, dispose, getBestSolution, getBestSolutionEvaluation, getBestSolutionValidation, getID, getMinDelta, getName, getProblem, getRandom, getRuntime, getSearchListeners, getStatus, getStatusLock, getSteps, getStepsWithoutImprovement, getTimeWithoutImprovement, removeSearchListener, removeStopCriterion, run, searchStarted, searchStopped, setRandom, setStopCriterionCheckPeriod, toString, updateBestSolution, updateBestSolution
public PipedLocalSearch(Problem<SolutionType> problem, List<LocalSearch<SolutionType>> pipeline)
null
, and the
list of local searches can not be empty and can not contain any null
elements. Moreover,
only searches solving the specified problem can be included in the pipeline. The search name defaults
to "PipedLocalSearch".problem
- problem to solvepipeline
- local searches to execute in the pipeline, in the given orderNullPointerException
- if problem
or pipeline
are null
,
or if pipeline
contains any null
elementsIllegalArgumentException
- if pipeline
is empty, or if it contains searches that
do not solve the specified problempublic PipedLocalSearch(String name, Problem<SolutionType> problem, List<LocalSearch<SolutionType>> pipeline)
null
in which case the default name "PipedLocalSearch" is assigned. The
list of local searches can not be empty and can not contain any null
elements.
Moreover, only searches solving the specified problem can be included in the pipeline.name
- custom search nameproblem
- problem to solvepipeline
- local searches to execute in the pipeline, in the given orderNullPointerException
- if problem
or pipeline
are null
,
or if pipeline
contains any null
elementsIllegalArgumentException
- if pipeline
is empty, or if it contains searches that
do not solve the specified problempublic void stop()
stop
in class Search<SolutionType extends Solution>
protected void searchDisposed()
searchDisposed
in class Search<SolutionType extends Solution>
public void start()
Search.start()
returns.start
in class Search<SolutionType extends Solution>
protected void searchStep()
searchStep
in class Search<SolutionType extends Solution>
Copyright © 2016. All rights reserved.