Class InstrumentedAlgorithm

java.lang.Object
org.moeaframework.core.PeriodicAction
org.moeaframework.analysis.collector.InstrumentedAlgorithm
All Implemented Interfaces:
Algorithm, Stateful

public class InstrumentedAlgorithm extends PeriodicAction
Decorates an algorithm to periodically collect information about its runtime behavior. The NFE field is automatically recorded by this class.
  • Constructor Details

    • InstrumentedAlgorithm

      public InstrumentedAlgorithm(Algorithm algorithm, 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
    • 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 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()
      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 class PeriodicAction
    • 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 PeriodicAction
      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 PeriodicAction
      Parameters:
      stream - the stream
      Throws:
      IOException - if an I/O error occurred
      ClassNotFoundException - if the stream referenced a class that is not defined