Package org.moeaframework.algorithm
Class AbstractEvolutionaryAlgorithm
java.lang.Object
org.moeaframework.algorithm.AbstractAlgorithm
org.moeaframework.algorithm.AbstractEvolutionaryAlgorithm
- All Implemented Interfaces:
Algorithm,EvolutionaryAlgorithm,Extensible,Configurable,Named,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.-
Field Summary
Fields inherited from class org.moeaframework.algorithm.AbstractAlgorithm
initialized, numberOfEvaluations, problem, terminated -
Constructor Summary
ConstructorsConstructorDescriptionAbstractEvolutionaryAlgorithm(Problem problem, int initialPopulationSize, Population population, NondominatedPopulation archive, Initialization initialization, Variation variation) Constructs an abstract evolutionary algorithm. -
Method Summary
Modifier and TypeMethodDescriptionReturns the current non-dominated archive of the best solutions generated by this evolutionary algorithm, ornullif no archive is used.Returns the initialization method for generating solutions in the initial population.intReturns the initial population size.Returns the current population of this evolutionary algorithm.Returns the current best-known result.Returns the variation operator currently in use by this algorithm.voidPerforms any initialization that is required by this algorithm.voidloadState(ObjectInputStream stream) Loads the state of this object from the stream.voidsaveState(ObjectOutputStream stream) Writes the state of this object to the stream.protected voidsetArchive(NondominatedPopulation archive) Sets the archive used by this algorithm.voidsetInitialization(Initialization initialization) Sets the initialization method for generating solutions in the initial population.protected voidsetInitialPopulationSize(int initialPopulationSize) Sets the initial population size.protected voidsetPopulation(Population population) Sets the population used by this algorithm.protected voidsetVariation(Variation variation) Replaces the variation operator to be used by this algorithm.Methods inherited from class org.moeaframework.algorithm.AbstractAlgorithm
assertNotInitialized, evaluate, getExtensions, getNumberOfEvaluations, getProblem, isInitialized, isTerminated, iterate, step, terminateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.moeaframework.algorithm.Algorithm
evaluate, evaluateAll, evaluateAll, getName, getNumberOfEvaluations, getProblem, isInitialized, isTerminated, run, run, step, terminateMethods inherited from interface org.moeaframework.core.configuration.Configurable
applyConfiguration, getConfigurationMethods inherited from interface org.moeaframework.algorithm.extension.Extensible
addExtension, getExtensions, removeExtension
-
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 solvedinitialPopulationSize- the initial population sizepopulation- the populationarchive- the archive storing the non-dominated solutionsinitialization- the initialization operatorvariation- the variation operator
-
-
Method Details
-
getResult
Description copied from interface:AlgorithmReturns the current best-known result. -
initialize
public void initialize()Description copied from interface:AlgorithmPerforms 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 throwAlgorithmInitializationExceptionif called multiple times.Implementations should always call
super.initialize()to ensure the algorithm is initialized correctly.- Specified by:
initializein interfaceAlgorithm- Overrides:
initializein classAbstractAlgorithm
-
getArchive
Description copied from interface:EvolutionaryAlgorithmReturns the current non-dominated archive of the best solutions generated by this evolutionary algorithm, ornullif no archive is used.- Specified by:
getArchivein interfaceEvolutionaryAlgorithm- Returns:
- the current non-dominated archive of the best solutions generated by this evolutionary algorithm,
or
nullif no archive is used
-
setArchive
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
Description copied from interface:EvolutionaryAlgorithmReturns the current population of this evolutionary algorithm.- Specified by:
getPopulationin interfaceEvolutionaryAlgorithm- Returns:
- the current population of this evolutionary algorithm
-
setPopulation
Sets the population used by this algorithm. This value can not be set after initialization.- Parameters:
population- the population
-
getVariation
Returns the variation operator currently in use by this algorithm.- Returns:
- the variation operator
-
setVariation
Replaces the variation operator to be used by this algorithm.- Parameters:
variation- the variation operator
-
getInitialization
Returns the initialization method for generating solutions in the initial population.- Returns:
- the initialization method
-
setInitialization
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
Description copied from interface:StatefulWrites the state of this object to the stream. The order that objects are written to the stream is important. We recommend first callingsuper.saveState(stream)followed by writing each field.- Specified by:
saveStatein interfaceStateful- Overrides:
saveStatein classAbstractAlgorithm- Parameters:
stream- the stream- Throws:
IOException- if an I/O error occurred
-
loadState
Description copied from interface:StatefulLoads 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 inStateful.saveState(ObjectOutputStream).- Specified by:
loadStatein interfaceStateful- Overrides:
loadStatein classAbstractAlgorithm- Parameters:
stream- the stream- Throws:
IOException- if an I/O error occurredClassNotFoundException- if the stream referenced a class that is not defined
-