org.drools.planner.core.localsearch.termination
Class TimeMillisSpendTermination

java.lang.Object
  extended by org.drools.planner.core.localsearch.termination.AbstractTermination
      extended by org.drools.planner.core.localsearch.termination.TimeMillisSpendTermination
All Implemented Interfaces:
LocalSearchSolverAware, LocalSearchSolverLifecycleListener, Termination

public class TimeMillisSpendTermination
extends AbstractTermination


Field Summary
 
Fields inherited from class org.drools.planner.core.localsearch.termination.AbstractTermination
localSearchSolver, logger
 
Constructor Summary
TimeMillisSpendTermination()
           
 
Method Summary
 double calculateTimeGradient(LocalSearchStepScope localSearchStepScope)
          A timeGradient is a relative estimate of how long the search will continue.
 boolean isTerminated(LocalSearchStepScope localSearchStepScope)
          Called by the LocalSearchSolver after every step to determine if the search should stop.
 void setMaximumTimeMillisSpend(long maximumTimeMillisSpend)
           
 
Methods inherited from class org.drools.planner.core.localsearch.termination.AbstractTermination
beforeDeciding, setLocalSearchSolver, solvingEnded, solvingStarted, stepDecided, stepTaken
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeMillisSpendTermination

public TimeMillisSpendTermination()
Method Detail

setMaximumTimeMillisSpend

public void setMaximumTimeMillisSpend(long maximumTimeMillisSpend)

isTerminated

public boolean isTerminated(LocalSearchStepScope localSearchStepScope)
Description copied from interface: Termination
Called by the LocalSearchSolver after every step to determine if the search should stop.

Parameters:
localSearchStepScope - never null
Returns:
true if the search should terminate.

calculateTimeGradient

public double calculateTimeGradient(LocalSearchStepScope localSearchStepScope)
Description copied from interface: Termination
A timeGradient is a relative estimate of how long the search will continue.

Clients that use a timeGradient should cache it at the start of a single step because some implementations are not time-stable.

If a timeGradient can not be calulated, it should return -1.0. Several implementations (such a similated annealing) require a correctly implemented timeGradient.

A Termination's timeGradient can be requested after they are terminated, so implementations should be carefull not to return a tempature above 1.0.

Parameters:
localSearchStepScope - never null
Returns:
timeGradient t for which 0.0 <= t <= 1.0 or -1.0 when it is not supported. At the start of a search t is 0.0 and at the end of a search t would be 1.0.


Copyright © 2001-2011 JBoss Inc.. All Rights Reserved.