Class AbstractEvolutionaryAlgorithm

java.lang.Object
org.moeaframework.algorithm.AbstractAlgorithm
org.moeaframework.algorithm.AbstractEvolutionaryAlgorithm
All Implemented Interfaces:
Extensible, Algorithm, Configurable, EvolutionaryAlgorithm, Stateful
Direct Known Subclasses:
AGEMOEAII, DBEA, EpsilonMOEA, GDE3, IBEA, MSOPS, NSGAII, PAES, PESA2, RVEA, SingleObjectiveEvolutionaryAlgorithm, SMSEMOA, SPEA2, VEGA

public abstract class AbstractEvolutionaryAlgorithm extends AbstractAlgorithm implements EvolutionaryAlgorithm, Configurable
Abstract class providing default implementations for several EvolutionaryAlgorithm methods. Primarily, the initialize() method generates and evaluates the initial population, adding the solutions to the archive if available. The getResult() method returns the non-dominated solutions from the population and, if available, the archive. The majority of evolutionary algorithms should only need to override the AbstractAlgorithm.iterate() method.
  • Constructor Details

    • AbstractEvolutionaryAlgorithm

      public AbstractEvolutionaryAlgorithm(Problem problem, int initialPopulationSize, Population population, NondominatedPopulation archive, Initialization initialization, Variation variation)
      Constructs an abstract evolutionary algorithm.
      Parameters:
      problem - the problem being solved
      initialPopulationSize - the initial population size
      population - the population
      archive - the archive storing the non-dominated solutions
      initialization - the initialization operator
      variation - the variation operator
  • Method Details

    • getResult

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

      public void initialize()
      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
      Overrides:
      initialize in class AbstractAlgorithm
    • 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
    • setArchive

      protected void setArchive(NondominatedPopulation archive)
      Sets the archive used by this algorithm. This value can not be set after initialization.
      Parameters:
      archive - the archive
    • getInitialPopulationSize

      public int getInitialPopulationSize()
      Returns the initial population size.
      Returns:
      the initial population size
    • setInitialPopulationSize

      protected void setInitialPopulationSize(int initialPopulationSize)
      Sets the initial population size. This value can not be set after initialization.
      Parameters:
      initialPopulationSize - the initial population size
    • 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
    • setPopulation

      protected void setPopulation(Population population)
      Sets the population used by this algorithm. This value can not be set after initialization.
      Parameters:
      population - the population
    • getVariation

      public Variation getVariation()
      Returns the variation operator currently in use by this algorithm.
      Returns:
      the variation operator
    • setVariation

      protected void setVariation(Variation variation)
      Replaces the variation operator to be used by this algorithm.
      Parameters:
      variation - the variation operator
    • getInitialization

      public Initialization getInitialization()
      Returns the initialization method for generating solutions in the initial population.
      Returns:
      the initialization method
    • setInitialization

      public void setInitialization(Initialization initialization)
      Sets the initialization method for generating solutions in the initial population. This can only be set before initializing the algorithm.
      Parameters:
      initialization - the initialization method
    • 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 AbstractAlgorithm
      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 AbstractAlgorithm
      Parameters:
      stream - the stream
      Throws:
      IOException - if an I/O error occurred
      ClassNotFoundException - if the stream referenced a class that is not defined