Class CancellationSignal

java.lang.Object
org.moeaframework.core.termination.CancellationSignal
All Implemented Interfaces:
Named, TerminationCondition

public class CancellationSignal extends Object implements TerminationCondition
Terminates a run when cancellation signal is received, by calling cancel().
  • Constructor Details

    • CancellationSignal

      public CancellationSignal()
      Constructs a new termination condition that allows cancellation.
  • Method Details

    • cancel

      public void cancel()
      Cancels the current run.
    • isCancelled

      public boolean isCancelled()
      Returns true if cancelled; false otherwise.
      Returns:
      true if cancelled; false otherwise
    • initialize

      public void initialize(Algorithm algorithm)
      Description copied from interface: TerminationCondition
      Invoked when the algorithm is created to collect any initial conditions. Note that the algorithm may not have been initialized at this point.
      Specified by:
      initialize in interface TerminationCondition
      Parameters:
      algorithm - the algorithm
    • shouldTerminate

      public boolean shouldTerminate(Algorithm algorithm)
      Description copied from interface: TerminationCondition
      Invoked after every step to check if the algorithm should terminate.
      Specified by:
      shouldTerminate in interface TerminationCondition
      Parameters:
      algorithm - the algorithm
      Returns:
      true if the algorithm should terminate; false otherwise
    • getPercentComplete

      public double getPercentComplete(Algorithm algorithm)
      Description copied from interface: TerminationCondition
      Returns the percentage that this condition is complete, as a value between 0.0 and 100.0. If the percentage can not be determined, returns 0d/0d.
      Specified by:
      getPercentComplete in interface TerminationCondition
      Parameters:
      algorithm - the algorithm
      Returns:
      the percentage completion