Class TimeTermination
java.lang.Object
com.graphhopper.jsprit.core.algorithm.termination.TimeTermination
- All Implemented Interfaces:
AlgorithmStartsListener,VehicleRoutingAlgorithmListener,PrematureAlgorithmTermination
public class TimeTermination
extends Object
implements PrematureAlgorithmTermination, AlgorithmStartsListener
Terminates algorithm prematurely based on specified time.
Note, TimeTermination must be registered as AlgorithmListener
TimeTermination will be activated by:
algorithm.setPrematureAlgorithmTermination(this);
algorithm.addListener(this);
- Author:
- stefan schroeder
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionTimeTermination(long timeThreshold_in_milliseconds) Constructs TimeTermination that terminates algorithm prematurely based on specified time. -
Method Summary
Modifier and TypeMethodDescriptionlonglongvoidinformAlgorithmStarts(VehicleRoutingProblem problem, VehicleRoutingAlgorithm algorithm, Collection<VehicleRoutingProblemSolution> solutions) booleanisPrematureBreak(SearchStrategy.DiscoveredSolution discoveredSolution) Returns true if algorithm should terminate, false otherwise.longnow()voidsetTimeGetter(TimeTermination.TimeGetter timeGetter) toString()
-
Constructor Details
-
TimeTermination
public TimeTermination(long timeThreshold_in_milliseconds) Constructs TimeTermination that terminates algorithm prematurely based on specified time.- Parameters:
timeThreshold_in_milliseconds- the computation time [in ms] after which the algorithm terminates
-
-
Method Details
-
setTimeGetter
-
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
-
now
public long now() -
informAlgorithmStarts
public void informAlgorithmStarts(VehicleRoutingProblem problem, VehicleRoutingAlgorithm algorithm, Collection<VehicleRoutingProblemSolution> solutions) - Specified by:
informAlgorithmStartsin interfaceAlgorithmStartsListener
-
getRemainingTime
public long getRemainingTime() -
getStartTime
public long getStartTime()
-