Class VariationCoefficientTermination
java.lang.Object
com.graphhopper.jsprit.core.algorithm.termination.VariationCoefficientTermination
- All Implemented Interfaces:
AlgorithmStartsListener,IterationEndsListener,IterationStartsListener,VehicleRoutingAlgorithmListener,PrematureAlgorithmTermination
public class VariationCoefficientTermination
extends Object
implements PrematureAlgorithmTermination, IterationStartsListener, AlgorithmStartsListener, IterationEndsListener
Terminates algorithm prematurely based on variationCoefficient (http://en.wikipedia.org/wiki/Coefficient_of_variation).
Note, that this must be registered as AlgorithmListener
It will be activated by:
algorithm.setPrematureAlgorithmTermination(this);
algorithm.addListener(this);
- Author:
- stefan schroeder
-
Constructor Summary
ConstructorsConstructorDescriptionVariationCoefficientTermination(int noIterations, double variationCoefficientThreshold) Constructs termination. -
Method Summary
Modifier and TypeMethodDescriptionvoidinformAlgorithmStarts(VehicleRoutingProblem problem, VehicleRoutingAlgorithm algorithm, Collection<VehicleRoutingProblemSolution> solutions) voidinformIterationEnds(int i, VehicleRoutingProblem problem, VehicleRoutingProblemSolution solution) voidinformIterationEnds(int i, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) voidinformIterationStarts(int i, VehicleRoutingProblem problem, VehicleRoutingProblemSolution solution) voidinformIterationStarts(int i, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) booleanisPrematureBreak(SearchStrategy.DiscoveredSolution discoveredSolution) Returns true if algorithm should terminate, false otherwise.toString()
-
Constructor Details
-
VariationCoefficientTermination
public VariationCoefficientTermination(int noIterations, double variationCoefficientThreshold) Constructs termination.- Parameters:
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.
-
-
Method Details
-
toString
-
isPrematureBreak
Description copied from interface:PrematureAlgorithmTerminationReturns true if algorithm should terminate, false otherwise.- Specified by:
isPrematureBreakin interfacePrematureAlgorithmTermination- Parameters:
discoveredSolution- the discovered solution- Returns:
- true if algorithm should terminate, false otherwise
-
informAlgorithmStarts
public void informAlgorithmStarts(VehicleRoutingProblem problem, VehicleRoutingAlgorithm algorithm, Collection<VehicleRoutingProblemSolution> solutions) - Specified by:
informAlgorithmStartsin interfaceAlgorithmStartsListener
-
informIterationEnds
public void informIterationEnds(int i, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) - Specified by:
informIterationEndsin interfaceIterationEndsListener
-
informIterationEnds
public void informIterationEnds(int i, VehicleRoutingProblem problem, VehicleRoutingProblemSolution solution) -
informIterationStarts
public void informIterationStarts(int i, VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) - Specified by:
informIterationStartsin interfaceIterationStartsListener
-
informIterationStarts
public void informIterationStarts(int i, VehicleRoutingProblem problem, VehicleRoutingProblemSolution solution)
-