Class InstrumentedExtension
java.lang.Object
org.moeaframework.algorithm.extension.PeriodicExtension
org.moeaframework.analysis.collector.InstrumentedExtension
Decorates an algorithm to periodically collect information about its runtime behavior. The
NFE
field is
automatically recorded by this class.-
Field Summary
Fields inherited from class org.moeaframework.algorithm.extension.PeriodicExtension
frequency, frequencyType, iteration, lastInvocation
-
Constructor Summary
ConstructorDescriptionInstrumentedExtension
(int frequency) Decorates the specified algorithm to periodically collect information about its runtime behavior.InstrumentedExtension
(int frequency, FrequencyType frequencyType) Decorates the specified algorithm to periodically collect information about its runtime behavior. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCollector
(Collector collector) Adds a collector to this instrumented algorithm.void
The action that is called by this extension.Returns the observations collected from this algorithm.void
loadState
(ObjectInputStream stream) Loads the state of this object from the stream.void
saveState
(ObjectOutputStream stream) Writes the state of this object to the stream.Methods inherited from class org.moeaframework.algorithm.extension.PeriodicExtension
onRegister, onStep
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
-
Constructor Details
-
InstrumentedExtension
public InstrumentedExtension(int frequency) Decorates the specified algorithm to periodically collect information about its runtime behavior. Frequency is given in number of evaluations.- Parameters:
algorithm
- the algorithm to decoratefrequency
- the frequency, in evaluations, that data is collected
-
InstrumentedExtension
Decorates the specified algorithm to periodically collect information about its runtime behavior.- Parameters:
algorithm
- the algorithm to decoratefrequency
- the frequency that data is collectedfrequencyType
- if frequency is defined by EVALUATIONS or STEPS
-
-
Method Details
-
addCollector
Adds a collector to this instrumented algorithm. The collector should have already been attached to the algorithm.- Parameters:
collector
- the collector
-
getObservations
Returns the observations collected from this algorithm.- Returns:
- the observations
-
doAction
Description copied from class:PeriodicExtension
The action that is called by this extension.- Specified by:
doAction
in classPeriodicExtension
- Parameters:
algorithm
- the algorithm associated with this extension
-
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
- Overrides:
saveState
in classPeriodicExtension
- 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
- Overrides:
loadState
in classPeriodicExtension
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurredClassNotFoundException
- if the stream referenced a class that is not defined
-