Class AdaptiveTimeContinuation

java.lang.Object
org.moeaframework.core.PeriodicAction
org.moeaframework.algorithm.continuation.AdaptiveTimeContinuation
All Implemented Interfaces:
Algorithm, Configurable, EvolutionaryAlgorithm, Stateful
Direct Known Subclasses:
EpsilonNSGAII, EpsilonProgressContinuation

public class AdaptiveTimeContinuation extends PeriodicAction implements EvolutionaryAlgorithm, Configurable
Decorator for EvolutionaryAlgorithms to add time continuation (restarts). Restarts occur if either
  1. the number of fitness function evaluations since the last restart exceeds maxWindowSize; or
  2. the population-to-archive ratio exceeds populationRatio by more than 25%.
If a restart occurs, the population is emptied, the population size is adapted to maintain the populationRatio, the the new population is filled with solutions selected from algorithm.getArchive() and mutated using the specified Selection and Variation operators.

References:

  1. Goldberg, D. E. "Sizing Populations for Serial and Parallel Genetic Algorithms." In 3rd International Conference on Genetic Algorithms, pp. 70-79, 1989.
  2. Srivastava, R. P. "Time Continuation in Genetic Algorithms." Technical report, Illinois Genetic Algorithm Laboratory, 2002.
  3. Kollat, J. B., and Reed, P. M. "Comparison of Multi-Objective Evolutionary Algorithms for Long-Term Monitoring Design." Advances in Water Resources, 29(6):792-807, 2006.
  • Constructor Details

    • AdaptiveTimeContinuation

      public AdaptiveTimeContinuation(EvolutionaryAlgorithm algorithm, int windowSize, int maxWindowSize, double injectionRate, int minimumPopulationSize, int maximumPopulationSize, Selection restartSelection, Variation restartVariation)
      Decorates the specified algorithm with adaptive time continuation.
      Parameters:
      algorithm - the algorithm being decorated
      windowSize - the number of iterations between invocations of check
      maxWindowSize - the maximum number of iterations allowed since the last restart before forcing a restart
      injectionRate - the injection rate percentage
      minimumPopulationSize - the minimum size of the population
      maximumPopulationSize - the maximum size of the population
      restartSelection - the selection operator for selecting solutions from the archive during a restart
      restartVariation - the variation operator for mutating solutions selected from the archive during a restart
  • Method Details

    • getWindowSize

      public int getWindowSize()
      Returns the number of iterations between invocations of check.
      Returns:
      the window size, in iterations
    • setWindowSize

      public void setWindowSize(int windowSize)
      Sets the number of iterations between invocations of check.
      Parameters:
      windowSize - the window size, in iterations
    • getMaxWindowSize

      public int getMaxWindowSize()
      Returns the maximum number of iterations allowed since the last restart before forcing a restart.
      Returns:
      the maximum window size, in iterations
    • setMaxWindowSize

      public void setMaxWindowSize(int maxWindowSize)
      Sets the maximum number of iterations allowed since the last restart before forcing a restart.
      Parameters:
      maxWindowSize - the maximum window size, in iterations
    • getInjectionRate

      public double getInjectionRate()
      Returns the percentage of the population that, during a restart, are introduced into the new population.
      Returns:
      the injection rate
    • setInjectionRate

      public void setInjectionRate(double injectionRate)
      Sets the percentage of the population that, during a restart, are introduced into the new population. The population will be resized to hold archive.size() / injectionRate solutions.
      Parameters:
      injectionRate - the injection rate
    • getMinimumPopulationSize

      public int getMinimumPopulationSize()
      Returns the minimum size of the population.
      Returns:
      the minimum size of the population
    • setMinimumPopulationSize

      public void setMinimumPopulationSize(int minimumPopulationSize)
      Sets the minimum size of the population.
      Parameters:
      minimumPopulationSize - the minimum size of the population
    • getMaximumPopulationSize

      public int getMaximumPopulationSize()
      Returns the maximum size of the population.
      Returns:
      the maximum size of the population
    • setMaximumPopulationSize

      public void setMaximumPopulationSize(int maximumPopulationSize)
      Sets the maximum size of the population.
      Parameters:
      maximumPopulationSize - the maximum size of the population
    • addRestartListener

      public void addRestartListener(RestartListener listener)
      Adds a listener to be notified whenever a restart occurs.
      Parameters:
      listener - the listener to be notified whenever a restart occurs
    • removeRestartListener

      public void removeRestartListener(RestartListener listener)
      Removes the specified listener so it no longer receives notifications whenever a restart occurs.
      Parameters:
      listener - the listener to be removed
    • check

      protected RestartType check()
      Performs a check to determine if a restart should occur. Returns RestartType.NONE if no restart should occur; or RestartType.HARD if the population-to-archive ratio exceeds populationRatio by more than 25% or the number of fitness evaluations since the last restart exceeds maxWindowSize.
      Returns:
      RestartType.NONE if no restart should occur; or RestartType.HARD if the population-to-archive ratio exceeds populationRatio by more than 25% or if the number of fitness evaluations since the last restart exceeds maxWindowSize
    • restart

      protected void restart(RestartType type)
      Performs a restart. If the type is RestartType.HARD, the population is emptied, resized and filled with solutions selected and mutated from the archive. If the type is RestartType.SOFT, the population is not emptied; new solutions are only added to fill any empty slots.
      Parameters:
      type - the type of restart
    • 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
    • getAlgorithm

      protected EvolutionaryAlgorithm getAlgorithm()
      Description copied from class: PeriodicAction
      Returns the algorithm that is wrapped by this periodic action.
      Overrides:
      getAlgorithm in class PeriodicAction
      Returns:
      the inner algorithm
    • getPopulation

      public Population getPopulation()
      Description copied from interface: EvolutionaryAlgorithm
      Returns the current population of this evolutionary algorithm.
      Specified by:
      getPopulation in interface EvolutionaryAlgorithm
      Returns:
      the current population of this evolutionary algorithm
    • getArchive

      public NondominatedPopulation getArchive()
      Description copied from interface: EvolutionaryAlgorithm
      Returns the current non-dominated archive of the best solutions generated by this evolutionary algorithm, or null if no archive is used.
      Specified by:
      getArchive in interface EvolutionaryAlgorithm
      Returns:
      the current non-dominated archive of the best solutions generated by this evolutionary algorithm, or null if no archive is used
    • 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