Class PeriodicAction

java.lang.Object
org.moeaframework.core.PeriodicAction
All Implemented Interfaces:
Extensible, Algorithm, Stateful
Direct Known Subclasses:
AdaptiveTimeContinuation, Checkpoints

@Deprecated public abstract class PeriodicAction extends Object implements Algorithm
Deprecated.
Use PeriodicExtension instead
Decorates an algorithm to perform some action periodically throughout the execution of the algorithm. Note that due to the underlying implementation of the algorithm, the action may be invoked less frequently than requested or not at all.
  • Field Details

    • algorithm

      protected final Algorithm algorithm
      Deprecated.
      The underlying algorithm being decorated.
    • frequency

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

      protected final PeriodicAction.FrequencyType frequencyType
      Deprecated.
      The type of frequency.
    • iteration

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

      protected int lastInvocation
      Deprecated.
      The last invocation doAction() was invoked, either as iterations or evaluations depending on the frequency type. A value of -1 indicates the run hasn't started yet.
  • Constructor Details

    • PeriodicAction

      public PeriodicAction(Algorithm algorithm, int frequency, PeriodicAction.FrequencyType frequencyType)
      Deprecated.
      Decorates an algorithm to perform a periodic action.
      Parameters:
      algorithm - the algorithm being decorated
      frequency - the frequency the doAction() method is invoked
      frequencyType - the type of frequency
  • Method Details

    • getAlgorithm

      protected Algorithm getAlgorithm()
      Deprecated.
      Returns the algorithm that is wrapped by this periodic action.
      Returns:
      the inner algorithm
    • getProblem

      public Problem getProblem()
      Deprecated.
      Description copied from interface: Algorithm
      Returns the problem being solved by this algorithm.
      Specified by:
      getProblem in interface Algorithm
      Returns:
      the problem being solved by this algorithm
    • getResult

      public NondominatedPopulation getResult()
      Deprecated.
      Description copied from interface: Algorithm
      Returns the current best-known result.
      Specified by:
      getResult in interface Algorithm
      Returns:
      the current best-known result
    • isInitialized

      public boolean isInitialized()
      Deprecated.
      Description copied from interface: Algorithm
      Returns true if this algorithm has been initialized; false otherwise.
      Specified by:
      isInitialized in interface Algorithm
      Returns:
      true if this algorithm has been initialized; false otherwise
      See Also:
    • initialize

      public void initialize()
      Deprecated.
      Description copied from interface: Algorithm
      Performs any initialization that is required by this algorithm. This method should only be called once, though the specific implementation may choose to no-op or throw AlgorithmInitializationException if called multiple times.

      Implementations should always call super.initialize() to ensure the algorithm is initialized correctly.

      Specified by:
      initialize in interface Algorithm
    • step

      public void step()
      Deprecated.
      Description copied from interface: Algorithm
      Performs one logical step of this algorithm. The amount of work performed depends on the implementation. One invocation of this method may produce one or many trial solutions.

      In general, calling this method after Algorithm.terminate() is permitted. When this happens, Algorithm.isTerminated() is reset. We recommend checking Algorithm.isTerminated() after each step to detect when termination conditions are reached. However, if the implementation is unable to continue, this method should throw AlgorithmTerminationException.

      Specified by:
      step in interface Algorithm
    • evaluate

      public void evaluate(Solution solution)
      Deprecated.
      Description copied from interface: Algorithm
      Evaluates the specified solution for the problem being solved by this algorithm.
      Specified by:
      evaluate in interface Algorithm
      Parameters:
      solution - the solution to be evaluated
      See Also:
    • getNumberOfEvaluations

      public int getNumberOfEvaluations()
      Deprecated.
      Description copied from interface: Algorithm
      Returns the number of times the evaluate method was invoked. This is the primary measure of runtime for optimization algorithms.
      Specified by:
      getNumberOfEvaluations in interface Algorithm
      Returns:
      the number of times the evaluate method was invoked
    • isTerminated

      public boolean isTerminated()
      Deprecated.
      Description copied from interface: Algorithm
      Returns true if this algorithm has reached its termination condition; false otherwise.
      Specified by:
      isTerminated in interface Algorithm
      Returns:
      true if this algorithm has reached its termination condition; false otherwise
      See Also:
    • terminate

      public void terminate()
      Deprecated.
      Description copied from interface: Algorithm
      Called when the termination condition is reached and the run is complete. This method is automatically called when using Algorithm.run(TerminationCondition), but can also be invoked directly if executing the algorithm step-by-step with Algorithm.step().

      Implementations should always call super.terminate() to ensure the algorithm is terminated correctly.

      Specified by:
      terminate in interface Algorithm
    • getExtensions

      public Extensions getExtensions()
      Deprecated.
      Description copied from interface: Extensible
      Returns the extensions associated with the algorithm.
      Specified by:
      getExtensions in interface Extensible
      Returns:
      the extensions
    • doAction

      public abstract void doAction()
      Deprecated.
      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.
    • saveState

      public void saveState(ObjectOutputStream stream) throws IOException
      Deprecated.
      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
      Deprecated.
      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