Package org.moeaframework.algorithm
Class Checkpoints
java.lang.Object
org.moeaframework.core.PeriodicAction
org.moeaframework.algorithm.Checkpoints
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(); }
-
Nested Class Summary
Nested classes/interfaces inherited from class org.moeaframework.core.PeriodicAction
PeriodicAction.FrequencyType
-
Field Summary
Fields inherited from class org.moeaframework.core.PeriodicAction
algorithm, frequency, frequencyType, iteration, lastInvocation
-
Constructor Summary
ConstructorDescriptionCheckpoints
(Algorithm algorithm, File stateFile, int checkpointFrequency) Decorates an algorithm to periodically save checkpoints from which the algorithm can resume itself if unexpectedly terminated. -
Method Summary
Methods inherited from class org.moeaframework.core.PeriodicAction
evaluate, getAlgorithm, getNumberOfEvaluations, getProblem, getResult, isTerminated, loadState, saveState, step
-
Constructor Details
-
Checkpoints
Decorates an algorithm to periodically save checkpoints from which the algorithm can resume itself if unexpectedly terminated.- Parameters:
algorithm
- the algorithmstateFile
- the file containing the checkpoint statescheckpointFrequency
- 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 classPeriodicAction
-
terminate
public void terminate()Description copied from interface:Algorithm
Terminates this algorithm. Implementations should use this method to free any underlying resources; however, theAlgorithm.getResult()
andAlgorithm.getNumberOfEvaluations()
methods are still required to work after termination.- Specified by:
terminate
in interfaceAlgorithm
- Overrides:
terminate
in classPeriodicAction
-