Class PeriodicExtension

java.lang.Object
org.moeaframework.algorithm.extension.PeriodicExtension
All Implemented Interfaces:
Extension, Stateful
Direct Known Subclasses:
AdaptiveTimeContinuationExtension, CheckpointExtension, InstrumentedExtension, RuntimeCollectorExtension

public abstract class PeriodicExtension extends Object implements Extension, Stateful
An extension that performs an action at a fixed frequency, specified by its FrequencyType.
  • Field Details

    • frequency

      protected int frequency
      The frequency that the #doAction() method is invoked.
    • frequencyType

      protected final FrequencyType frequencyType
      The type of frequency.
    • iteration

      protected int iteration
      The number of invocations of the Algorithm.step() method. Only used if the frequency type is STEPS.
    • lastInvocation

      protected int lastInvocation
      The last invocation #doAction() was invoked, either as iterations or evaluations depending on the frequency type.
  • Constructor Details

    • PeriodicExtension

      public PeriodicExtension(int frequency, FrequencyType frequencyType)
      Extension that performs an action at a fixed frequency.
      Parameters:
      frequency - the frequency the #doAction() method is invoked
      frequencyType - the type of frequency
  • Method Details

    • doAction

      public abstract void doAction(Algorithm algorithm)
      The action that is called by this extension.
      Parameters:
      algorithm - the algorithm associated with this extension
    • onRegister

      public void onRegister(Algorithm algorithm)
      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 interface Extension
      Parameters:
      algorithm - the algorithm associated with this extension
    • onStep

      public void onStep(Algorithm algorithm)
      Description copied from interface: Extension
      Called after each step of the algorithm.
      Specified by:
      onStep in interface Extension
      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
      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
      Parameters:
      stream - the stream
      Throws:
      IOException - if an I/O error occurred
      ClassNotFoundException - if the stream referenced a class that is not defined