SolutionType
- solution type, required to extend Solution
public interface SearchListener<SolutionType extends Solution>
Interface of a search listener that can be attached to any search with the specified solution type (or a subtype).
A listener is informed when certain events occur, e.g. when the search has started, stopped or found a new best
solution. Every callback receives a reference to the search that called it, which may be cast to a specific search
type if required; if an incompatible search type is received, an IncompatibleSearchListenerException
may
be thrown.
All callbacks have a default empty implementation. Some callbacks may only be fired by specific search types.
Modifier and Type | Method and Description |
---|---|
default void |
newBestSolution(Search<? extends SolutionType> search,
SolutionType newBestSolution,
Evaluation newBestSolutionEvaluation,
Validation newBestSolutionValidation)
Fired when the search has found a new best solution.
|
default void |
newCurrentSolution(LocalSearch<? extends SolutionType> search,
SolutionType newCurrentSolution,
Evaluation newCurrentSolutionEvaluation,
Validation newCurrentSolutionValidation)
Fired by local searches only, when a new current solution has been adopted.
|
default void |
searchStarted(Search<? extends SolutionType> search)
Fired when the search has started.
|
default void |
searchStopped(Search<? extends SolutionType> search)
Fired when the search has stopped.
|
default void |
statusChanged(Search<? extends SolutionType> search,
SearchStatus newStatus)
Fired when the search enters a new status.
|
default void |
stepCompleted(Search<? extends SolutionType> search,
long numSteps)
Fired when the search has completed a step.
|
default void searchStarted(Search<? extends SolutionType> search)
search
- search which has startedIncompatibleSearchListenerException
- if the listener is not compatible with the searchdefault void searchStopped(Search<? extends SolutionType> search)
search
- search which has stoppedIncompatibleSearchListenerException
- if the listener is not compatible with the searchdefault void newBestSolution(Search<? extends SolutionType> search, SolutionType newBestSolution, Evaluation newBestSolutionEvaluation, Validation newBestSolutionValidation)
search
- search which has found a new best solutionnewBestSolution
- new best solutionnewBestSolutionEvaluation
- evaluation of the new best solutionnewBestSolutionValidation
- validation of the new best solutionIncompatibleSearchListenerException
- if the listener is not compatible with the searchdefault void newCurrentSolution(LocalSearch<? extends SolutionType> search, SolutionType newCurrentSolution, Evaluation newCurrentSolutionEvaluation, Validation newCurrentSolutionValidation)
search
- local search which has updated its current solutionnewCurrentSolution
- newly adopted current solutionnewCurrentSolutionEvaluation
- evaluation of new current solutionnewCurrentSolutionValidation
- validation of new current solutionIncompatibleSearchListenerException
- if the listener is not compatible with the searchdefault void stepCompleted(Search<? extends SolutionType> search, long numSteps)
search
- search which has completed a stepnumSteps
- number of steps completed so far (during the current search run)IncompatibleSearchListenerException
- if the listener is not compatible with the searchdefault void statusChanged(Search<? extends SolutionType> search, SearchStatus newStatus)
search
- search which has changed statusnewStatus
- new status of the searchCopyright © 2016. All rights reserved.