Class GeneticAlgorithm
java.lang.Object
org.moeaframework.algorithm.AbstractAlgorithm
org.moeaframework.algorithm.AbstractEvolutionaryAlgorithm
org.moeaframework.algorithm.single.SingleObjectiveEvolutionaryAlgorithm
org.moeaframework.algorithm.single.GeneticAlgorithm
- All Implemented Interfaces:
Algorithm,EvolutionaryAlgorithm,Extensible,Configurable,Named,Stateful
Single-objective genetic algorithm (GA) implementation with elitism. A single elite individual is retained in each
generation.
References:
- John Holland. "Adaptation in Natural and Artificial Systems." MIT Press, ISBN: 9780262082136.
-
Field Summary
Fields inherited from class org.moeaframework.algorithm.single.SingleObjectiveEvolutionaryAlgorithm
comparatorFields inherited from class org.moeaframework.algorithm.AbstractAlgorithm
initialized, numberOfEvaluations, problem, terminated -
Constructor Summary
ConstructorsConstructorDescriptionGeneticAlgorithm(Problem problem) Constructs a new instance of the genetic algorithm (GA) with default settings.GeneticAlgorithm(Problem problem, int initialPopulationSize, AggregateObjectiveComparator comparator, Initialization initialization, Variation variation) Constructs a new instance of the genetic algorithm (GA). -
Method Summary
Modifier and TypeMethodDescriptiongetName()Returns the name of this algorithm.Returns the current best-known result.voidPerforms any initialization that is required by this algorithm.voiditerate()Performs one iteration of the algorithm.voidloadState(ObjectInputStream stream) Loads the state of this object from the stream.voidsetComparator(AggregateObjectiveComparator comparator) Sets the aggregate objective comparator that scalarizes multiple objectives into a single fitness value.voidsetVariation(Variation variation) Replaces the variation operator to be used by this algorithm.voidUpdate the elite solution.Methods inherited from class org.moeaframework.algorithm.single.SingleObjectiveEvolutionaryAlgorithm
applyConfiguration, getComparator, getConfiguration, setInitialPopulationSizeMethods inherited from class org.moeaframework.algorithm.AbstractEvolutionaryAlgorithm
getArchive, getInitialization, getInitialPopulationSize, getPopulation, getVariation, saveState, setArchive, setInitialization, setPopulationMethods inherited from class org.moeaframework.algorithm.AbstractAlgorithm
assertNotInitialized, evaluate, getExtensions, getNumberOfEvaluations, getProblem, isInitialized, isTerminated, 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, getNumberOfEvaluations, getProblem, isInitialized, isTerminated, run, run, step, terminateMethods inherited from interface org.moeaframework.algorithm.extension.Extensible
addExtension, getExtensions, removeExtension
-
Constructor Details
-
GeneticAlgorithm
Constructs a new instance of the genetic algorithm (GA) with default settings.- Parameters:
problem- the problem
-
GeneticAlgorithm
public GeneticAlgorithm(Problem problem, int initialPopulationSize, AggregateObjectiveComparator comparator, Initialization initialization, Variation variation) Constructs a new instance of the genetic algorithm (GA).- Parameters:
problem- the probleminitialPopulationSize- the initial population sizecomparator- the aggregate objective comparatorinitialization- the initialization methodvariation- the variation operator
-
-
Method Details
-
getName
Description copied from interface:AlgorithmReturns the name of this algorithm. Whenever possible, this name should match the name recognized byAlgorithmFactory.- Returns:
- the name of this algorithm
-
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 classAbstractEvolutionaryAlgorithm
-
iterate
public void iterate()Description copied from class:AbstractAlgorithmPerforms one iteration of the algorithm. This method should be overridden by implementations to perform each logical iteration of the algorithm.- Specified by:
iteratein classAbstractAlgorithm
-
updateEliteSolution
public void updateEliteSolution()Update the elite solution. -
getResult
Description copied from interface:AlgorithmReturns the current best-known result.- Specified by:
getResultin interfaceAlgorithm- Overrides:
getResultin classSingleObjectiveEvolutionaryAlgorithm- Returns:
- the current best-known result
-
setVariation
Description copied from class:AbstractEvolutionaryAlgorithmReplaces the variation operator to be used by this algorithm.- Overrides:
setVariationin classAbstractEvolutionaryAlgorithm- Parameters:
variation- the variation operator
-
setComparator
Description copied from class:SingleObjectiveEvolutionaryAlgorithmSets the aggregate objective comparator that scalarizes multiple objectives into a single fitness value.- Overrides:
setComparatorin classSingleObjectiveEvolutionaryAlgorithm- Parameters:
comparator- the aggregate objective comparator
-
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 classAbstractEvolutionaryAlgorithm- Parameters:
stream- the stream- Throws:
IOException- if an I/O error occurredClassNotFoundException- if the stream referenced a class that is not defined
-