Class PeriodicExtension
java.lang.Object
org.moeaframework.algorithm.extension.PeriodicExtension
- Direct Known Subclasses:
AdaptiveTimeContinuationExtension
,CheckpointExtension
,InstrumentedExtension
,RuntimeCollectorExtension
An extension that performs an action at a fixed frequency, specified by its
FrequencyType
.-
Field Summary
Modifier and TypeFieldDescriptionprotected int
The frequency that the#doAction()
method is invoked.protected final FrequencyType
The type of frequency.protected int
The number of invocations of theAlgorithm.step()
method.protected int
The last invocation#doAction()
was invoked, either as iterations or evaluations depending on the frequency type. -
Constructor Summary
ConstructorDescriptionPeriodicExtension
(int frequency, FrequencyType frequencyType) 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, onTerminate
-
Field Details
-
frequency
protected int frequencyThe frequency that the#doAction()
method is invoked. -
frequencyType
The type of frequency. -
iteration
protected int iterationThe number of invocations of theAlgorithm.step()
method. Only used if the frequency type isSTEPS
. -
lastInvocation
protected int lastInvocationThe last invocation#doAction()
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 the#doAction()
method is invokedfrequencyType
- the type of frequency
-
-
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
-