Class InstrumentedExtension

java.lang.Object
org.moeaframework.algorithm.extension.PeriodicExtension
org.moeaframework.analysis.collector.InstrumentedExtension
All Implemented Interfaces:
Extension, Stateful

public class InstrumentedExtension extends PeriodicExtension implements Stateful
Decorates an algorithm to periodically collect information about its runtime behavior. The NFE field is automatically recorded by this class.
  • 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 decorate
      frequency - the frequency, in evaluations, that data is collected
    • InstrumentedExtension

      public InstrumentedExtension(int frequency, FrequencyType frequencyType)
      Decorates the specified algorithm to periodically collect information about its runtime behavior.
      Parameters:
      algorithm - the algorithm to decorate
      frequency - the frequency that data is collected
      frequencyType - if frequency is defined by EVALUATIONS or STEPS
  • Method Details

    • addCollector

      public void addCollector(Collector collector)
      Adds a collector to this instrumented algorithm. The collector should have already been attached to the algorithm.
      Parameters:
      collector - the collector
    • getObservations

      public Observations getObservations()
      Returns the observations collected from this algorithm.
      Returns:
      the observations
    • doAction

      public void doAction(Algorithm algorithm)
      Description copied from class: PeriodicExtension
      The action that is called by this extension.
      Specified by:
      doAction in class PeriodicExtension
      Parameters:
      algorithm - the algorithm associated with this extension
    • saveState

      public void saveState(ObjectOutputStream stream) throws IOException
      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 calling super.saveState(stream) followed by writing each field.
      Specified by:
      saveState in interface Stateful
      Overrides:
      saveState in class PeriodicExtension
      Parameters:
      stream - the stream
      Throws:
      IOException - if an I/O error occurred
    • loadState

      public void loadState(ObjectInputStream stream) throws IOException, ClassNotFoundException
      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 in Stateful.saveState(ObjectOutputStream).
      Specified by:
      loadState in interface Stateful
      Overrides:
      loadState in class PeriodicExtension
      Parameters:
      stream - the stream
      Throws:
      IOException - if an I/O error occurred
      ClassNotFoundException - if the stream referenced a class that is not defined