Class InstrumentedAlgorithm
java.lang.Object
org.moeaframework.core.PeriodicAction
org.moeaframework.analysis.collector.InstrumentedAlgorithm
Decorates an algorithm to periodically collect information about its runtime behavior. The
NFE
field is
automatically recorded by this class.-
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
ConstructorDescriptionInstrumentedAlgorithm
(Algorithm algorithm, int frequency) Decorates the specified algorithm to periodically collect information about its runtime behavior.InstrumentedAlgorithm
(Algorithm algorithm, int frequency, PeriodicAction.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
doAction()
Invoked periodically by this class to perform some function.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.core.PeriodicAction
evaluate, getAlgorithm, getNumberOfEvaluations, getProblem, getResult, isTerminated, step, terminate
-
Constructor Details
-
InstrumentedAlgorithm
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
-
InstrumentedAlgorithm
public InstrumentedAlgorithm(Algorithm algorithm, int frequency, PeriodicAction.FrequencyType frequencyType) 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
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
-
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 classPeriodicAction
- 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 classPeriodicAction
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurredClassNotFoundException
- if the stream referenced a class that is not defined
-