Package org.moeaframework.algorithm
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.-
Field Summary
Fields inherited from class org.moeaframework.algorithm.AbstractAlgorithm
initialized, numberOfEvaluations, problem, terminated
-
Constructor Summary
ConstructorDescriptionAbstractEvolutionaryAlgorithm
(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, ornull
if no archive is used.Returns the initialization method for generating solutions in the initial population.int
Returns 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.void
Performs any initialization that is required by this algorithm.void
loadState
(ObjectInputStream stream) Loads the state of this object from the stream.void
saveState
(ObjectOutputStream stream) Writes the state of this object to the stream.protected void
setArchive
(NondominatedPopulation archive) Sets the archive used by this algorithm.void
setInitialization
(Initialization initialization) Sets the initialization method for generating solutions in the initial population.protected void
setInitialPopulationSize
(int initialPopulationSize) Sets the initial population size.protected void
setPopulation
(Population population) Sets the population used by this algorithm.protected void
setVariation
(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, terminate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.moeaframework.core.Algorithm
evaluate, evaluateAll, evaluateAll, getNumberOfEvaluations, getProblem, isInitialized, isTerminated, run, run, step, terminate
Methods inherited from interface org.moeaframework.core.configuration.Configurable
applyConfiguration, getConfiguration
Methods 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: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 throwAlgorithmInitializationException
if called multiple times.Implementations should always call
super.initialize()
to ensure the algorithm is initialized correctly.- Specified by:
initialize
in interfaceAlgorithm
- Overrides:
initialize
in classAbstractAlgorithm
-
getArchive
Description copied from interface:EvolutionaryAlgorithm
Returns the current non-dominated archive of the best solutions generated by this evolutionary algorithm, ornull
if no archive is used.- Specified by:
getArchive
in interfaceEvolutionaryAlgorithm
- Returns:
- the current non-dominated archive of the best solutions generated by this evolutionary algorithm,
or
null
if 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:EvolutionaryAlgorithm
Returns the current population of this evolutionary algorithm.- Specified by:
getPopulation
in 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:Stateful
Writes 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:
saveState
in interfaceStateful
- Overrides:
saveState
in classAbstractAlgorithm
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurred
-
loadState
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 inStateful.saveState(ObjectOutputStream)
.- Specified by:
loadState
in interfaceStateful
- Overrides:
loadState
in classAbstractAlgorithm
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurredClassNotFoundException
- if the stream referenced a class that is not defined
-