Class PeriodicExtension
java.lang.Object
org.moeaframework.algorithm.extension.PeriodicExtension
- Direct Known Subclasses:
AdaptiveTimeContinuationExtension
,CheckpointExtension
,InstrumentedExtension
,IslandMigrationExtension
,RuntimeCollectorExtension
An extension that performs an action at a given
Frequency
.-
Field Summary
Modifier and TypeFieldDescriptionprotected Frequency
The frequency that thedoAction(Algorithm)
method is invoked.protected int
The number of invocations of theAlgorithm.step()
method.protected int
The last invocationdoAction(Algorithm)
was invoked, either as iterations or evaluations depending on the frequency type. -
Constructor Summary
ConstructorDescriptionPeriodicExtension
(Frequency frequency) Extension that performs an action at a fixed frequency. -
Method Summary
Modifier and TypeMethodDescriptionabstract void
The action that is called by this extension.void
loadState
(ObjectInputStream stream) Loads the state of this object from the stream.void
onRegister
(Algorithm algorithm) Called when this extension is registered with an algorithm.void
Called after each step of the algorithm.void
saveState
(ObjectOutputStream stream) Writes the state of this object to the stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.moeaframework.algorithm.extension.Extension
onInitialize, onRun, onTerminate
-
Field Details
-
frequency
The frequency that thedoAction(Algorithm)
method is invoked. -
iteration
protected int iterationThe number of invocations of theAlgorithm.step()
method. Only used if the frequency type isFrequency.Type.ITERATIONS
. -
lastInvocation
protected int lastInvocationThe last invocationdoAction(Algorithm)
was invoked, either as iterations or evaluations depending on the frequency type.
-
-
Constructor Details
-
PeriodicExtension
Extension that performs an action at a fixed frequency.- Parameters:
frequency
- the frequency thedoAction(Algorithm)
method is invoked
-
-
Method Details
-
doAction
The action that is called by this extension.- Parameters:
algorithm
- the algorithm associated with this extension
-
onRegister
Description copied from interface:Extension
Called when this extension is registered with an algorithm. This can be used to perform any type checking or initialization.- Specified by:
onRegister
in interfaceExtension
- Parameters:
algorithm
- the algorithm associated with this extension
-
onStep
Description copied from interface:Extension
Called after each step of the algorithm. -
saveState
Description copied from interface:Stateful
Writes the state of this object to the stream. The order that objects are written to the stream is important. We recommend first callingsuper.saveState(stream)
followed by writing each field.- Specified by:
saveState
in interfaceStateful
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurred
-
loadState
Description copied from interface:Stateful
Loads the state of this object from the stream. The order for reading objects from the stream must match the order they are written to the stream inStateful.saveState(ObjectOutputStream)
.- Specified by:
loadState
in interfaceStateful
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurredClassNotFoundException
- if the stream referenced a class that is not defined
-