Class Checkpoints

java.lang.Object
org.moeaframework.core.PeriodicAction
org.moeaframework.algorithm.Checkpoints
All Implemented Interfaces:
Algorithm, Stateful

public class Checkpoints extends PeriodicAction
Decorates an Algorithm to periodically save checkpoint files from which the algorithm can resume itself if unexpectedly terminated.
   File stateFile = new File("last.state");
 
   Algorithm algorithm = new Checkpoints(new NSGAII(...), stateFile, 100);
 
   while (!algorithm.isTerminated()) {
     algorithm.step();
   }
 
  • Constructor Details

    • Checkpoints

      public Checkpoints(Algorithm algorithm, File stateFile, int checkpointFrequency)
      Decorates an algorithm to periodically save checkpoints from which the algorithm can resume itself if unexpectedly terminated.
      Parameters:
      algorithm - the algorithm
      stateFile - the file containing the checkpoint states
      checkpointFrequency - the number of objective function evaluations between checkpoints
  • Method Details

    • doAction

      public void doAction()
      Description copied from class: PeriodicAction
      Invoked periodically by this class to perform some function. This function should not depend on the frequency that it is invoked, since it is not guaranteed that this method is invoked at any specific frequency and, in some cases, may not be invoked at all.
      Specified by:
      doAction in class PeriodicAction
    • terminate

      public void terminate()
      Description copied from interface: Algorithm
      Terminates this algorithm. Implementations should use this method to free any underlying resources; however, the Algorithm.getResult() and Algorithm.getNumberOfEvaluations() methods are still required to work after termination.
      Specified by:
      terminate in interface Algorithm
      Overrides:
      terminate in class PeriodicAction