public abstract class AbstractEvolutionaryAlgorithm extends AbstractAlgorithm implements EvolutionaryAlgorithm, Configurable
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.initialized, numberOfEvaluations, problem, terminated
Constructor and Description |
---|
AbstractEvolutionaryAlgorithm(Problem problem,
int initialPopulationSize,
Population population,
NondominatedPopulation archive,
Initialization initialization,
Variation variation)
Constructs an abstract evolutionary algorithm.
|
Modifier and Type | Method and Description |
---|---|
NondominatedPopulation |
getArchive()
Returns the current non-dominated archive of the best solutions generated
by this evolutionary algorithm, or
null if no archive is used. |
Initialization |
getInitialization()
Returns the initialization method for generating solutions in the initial population.
|
int |
getInitialPopulationSize()
Returns the initial population size.
|
Population |
getPopulation()
Returns the current population of this evolutionary algorithm.
|
NondominatedPopulation |
getResult()
Returns the current best-known result.
|
Variation |
getVariation()
Returns the variation operator currently in use by this algorithm.
|
protected void |
initialize()
Performs any initialization that is required by this algorithm.
|
void |
loadState(java.io.ObjectInputStream stream)
Loads the state of this object from the stream.
|
void |
saveState(java.io.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.
|
assertNotInitialized, evaluate, evaluateAll, evaluateAll, getNumberOfEvaluations, getProblem, isInitialized, isTerminated, iterate, step, terminate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
evaluate, getNumberOfEvaluations, getProblem, isTerminated, run, run, step, terminate
checkTypeSafety, getState, setState, writeTypeSafety
applyConfiguration, getConfiguration
public AbstractEvolutionaryAlgorithm(Problem problem, int initialPopulationSize, Population population, NondominatedPopulation archive, Initialization initialization, Variation variation)
problem
- the problem being solvedinitialPopulationSize
- the initial population sizepopulation
- the populationarchive
- the archive storing the non-dominated solutionsinitialization
- the initialization operatorvariation
- the variation operatorpublic NondominatedPopulation getResult()
Algorithm
protected void initialize()
AbstractAlgorithm
AbstractAlgorithm.step()
. Implementations should always invoke
super.initialize()
to ensure the algorithm is initialized
correctly.initialize
in class AbstractAlgorithm
public NondominatedPopulation getArchive()
EvolutionaryAlgorithm
null
if no archive is used.getArchive
in interface EvolutionaryAlgorithm
null
if no archive is
usedprotected void setArchive(NondominatedPopulation archive)
archive
- the archivepublic int getInitialPopulationSize()
protected void setInitialPopulationSize(int initialPopulationSize)
initialPopulationSize
- the initial population sizepublic Population getPopulation()
EvolutionaryAlgorithm
getPopulation
in interface EvolutionaryAlgorithm
protected void setPopulation(Population population)
population
- the populationpublic Variation getVariation()
protected void setVariation(Variation variation)
variation
- the variation operatorpublic Initialization getInitialization()
public void setInitialization(Initialization initialization)
initialization
- the initialization methodpublic void saveState(java.io.ObjectOutputStream stream) throws java.io.IOException
Stateful
super.saveState(stream)
followed by writing each
field.saveState
in interface Stateful
saveState
in class AbstractAlgorithm
stream
- the streamjava.io.IOException
- if an I/O error occurredpublic void loadState(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Stateful
Stateful.saveState(ObjectOutputStream)
.loadState
in interface Stateful
loadState
in class AbstractAlgorithm
stream
- the streamjava.io.IOException
- if an I/O error occurredjava.lang.ClassNotFoundException
- if the stream referenced a class that is not definedCopyright 2009-2024 David Hadka and other contributors. All rights reserved.
Licensed under the GNU Lesser General Public License.
Return to the MOEA Framework homepage.