public class TimeTermination extends Object implements PrematureAlgorithmTermination, AlgorithmStartsListener
Note, TimeTermination must be registered as AlgorithmListener
TimeTermination will be activated by:
algorithm.setPrematureAlgorithmTermination(this);
algorithm.addListener(this);
| Modifier and Type | Class and Description |
|---|---|
static interface |
TimeTermination.TimeGetter |
| Constructor and Description |
|---|
TimeTermination(long timeThreshold_in_milliseconds)
Constructs TimeTermination that terminates algorithm prematurely based on specified time.
|
| Modifier and Type | Method and Description |
|---|---|
void |
informAlgorithmStarts(VehicleRoutingProblem problem,
VehicleRoutingAlgorithm algorithm,
Collection<VehicleRoutingProblemSolution> solutions) |
boolean |
isPrematureBreak(SearchStrategy.DiscoveredSolution discoveredSolution)
Returns true if algorithm should terminate, false otherwise.
|
void |
setTimeGetter(TimeTermination.TimeGetter timeGetter) |
String |
toString() |
public TimeTermination(long timeThreshold_in_milliseconds)
timeThreshold_in_milliseconds - the computation time [in ms] after which the algorithm terminatespublic void setTimeGetter(TimeTermination.TimeGetter timeGetter)
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 AlgorithmStartsListenerCopyright © 2013–2019. All rights reserved.