public class VariationCoefficientTermination extends Object implements PrematureAlgorithmTermination, IterationStartsListener, AlgorithmStartsListener, IterationEndsListener
Note, that this must be registered as AlgorithmListener
It will be activated by:
algorithm.setPrematureAlgorithmTermination(this);
algorithm.addListener(this);
| Constructor and Description |
|---|
VariationCoefficientTermination(int noIterations,
double variationCoefficientThreshold)
Constructs termination.
|
| Modifier and Type | Method and Description |
|---|---|
void |
informAlgorithmStarts(VehicleRoutingProblem problem,
VehicleRoutingAlgorithm algorithm,
Collection<VehicleRoutingProblemSolution> solutions) |
void |
informIterationEnds(int i,
VehicleRoutingProblem problem,
Collection<VehicleRoutingProblemSolution> solutions) |
void |
informIterationStarts(int i,
VehicleRoutingProblem problem,
Collection<VehicleRoutingProblemSolution> solutions) |
boolean |
isPrematureBreak(SearchStrategy.DiscoveredSolution discoveredSolution)
Returns true if algorithm should terminate, false otherwise.
|
String |
toString() |
public VariationCoefficientTermination(int noIterations,
double variationCoefficientThreshold)
noIterations - size of the sample, i.e. number previous solutions values to take into account. If for example
noIterations = 10 then every 10th iteration the variationCoefficient will be calculated with the
last 10 solution values.variationCoefficientThreshold - the threshold used to terminate the algorithm. If the calculated variationCoefficient
is smaller than the specified threshold, the algorithm terminates.public boolean isPrematureBreak(SearchStrategy.DiscoveredSolution discoveredSolution)
PrematureAlgorithmTerminationisPrematureBreak in interface PrematureAlgorithmTerminationdiscoveredSolution - the discovered solutionpublic void informAlgorithmStarts(VehicleRoutingProblem problem, VehicleRoutingAlgorithm algorithm, Collection<VehicleRoutingProblemSolution> solutions)
informAlgorithmStarts in interface AlgorithmStartsListenerpublic void informIterationEnds(int i,
VehicleRoutingProblem problem,
Collection<VehicleRoutingProblemSolution> solutions)
informIterationEnds in interface IterationEndsListenerpublic void informIterationStarts(int i,
VehicleRoutingProblem problem,
Collection<VehicleRoutingProblemSolution> solutions)
informIterationStarts in interface IterationStartsListenerCopyright © 2013–2016. All rights reserved.