Class SPEA2
- All Implemented Interfaces:
Algorithm,EvolutionaryAlgorithm,Extensible,Configurable,Named,Stateful
Note: First, there is a naming difference between this implementation and the original SPEA2 paper. The original
SPEA2 paper defines a "population" and an "archive", but the population is really the offspring and the archive
is the population. Secondly, the SPEA2 paper defines a parameter k = sqrt(population.size()) for computing
a crowding-based niching factor. The SPEA2 C implementation in PISA (written by the same authors as the paper)
recommends using k=1 for performance reasons. This implementation makes k a user-specified
parameter to support either option. k should be at least 1 and no larger than
population.size().
References:
- Zitzler, E., M. Laumanns, and L. Thiele (2001). SPEA2: Improving the Strength Pareto Evolutionary Algorithm. TIK-Report 103.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMapping of pair-wise distances between points.classFitness evaluator for the strength measure with crowding-based niching. -
Field Summary
Fields inherited from class org.moeaframework.algorithm.AbstractAlgorithm
initialized, numberOfEvaluations, problem, terminated -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected double[][]computeDistanceMatrix(Population population) Computes the distance matrix containing the pair-wise distances between solutions in objective space.Returns the strength-based fitness evaluator.getName()Returns the name of this algorithm.intReturns the number of offspring produced each iteration.voidPerforms any initialization that is required by this algorithm.protected voiditerate()Performs one iteration of the algorithm.voidsetInitialPopulationSize(int initialPopulationSize) Sets the initial population size.voidsetNumberOfOffspring(int numberOfOffspring) Sets the number of offspring produced each iteration.voidsetVariation(Variation variation) Replaces the variation operator to be used by this algorithm.protected Populationtruncate(Population offspring, int size) Returns the population of solutions that survive to the next generation.Methods inherited from class org.moeaframework.algorithm.AbstractEvolutionaryAlgorithm
getArchive, getInitialization, getInitialPopulationSize, getPopulation, getResult, getVariation, loadState, 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.core.configuration.Configurable
applyConfiguration, getConfigurationMethods inherited from interface org.moeaframework.algorithm.extension.Extensible
addExtension, getExtensions, removeExtension
-
Constructor Details
-
SPEA2
Constructs a new instance of SPEA2 with default settings.- Parameters:
problem- the problem
-
SPEA2
public SPEA2(Problem problem, int initialPopulationSize, Initialization initialization, Variation variation, int numberOfOffspring, int k) Constructs a new instance of SPEA2.- Parameters:
problem- the probleminitialPopulationSize- the initial population sizeinitialization- the initialization procedurevariation- the variation operatornumberOfOffspring- the number of offspring generated each iterationk- niching parameter specifying that crowding is computed using thek-th nearest neighbor, recommendk=1
-
-
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
-
setVariation
Description copied from class:AbstractEvolutionaryAlgorithmReplaces the variation operator to be used by this algorithm.- Overrides:
setVariationin classAbstractEvolutionaryAlgorithm- Parameters:
variation- the variation operator
-
setInitialPopulationSize
public void setInitialPopulationSize(int initialPopulationSize) Description copied from class:AbstractEvolutionaryAlgorithmSets the initial population size. This value can not be set after initialization.- Overrides:
setInitialPopulationSizein classAbstractEvolutionaryAlgorithm- Parameters:
initialPopulationSize- the initial population size
-
getNumberOfOffspring
public int getNumberOfOffspring()Returns the number of offspring produced each iteration.- Returns:
- the number of offspring
-
setNumberOfOffspring
public void setNumberOfOffspring(int numberOfOffspring) Sets the number of offspring produced each iteration. This is typically set to the same value as the population size.- Parameters:
numberOfOffspring- the number of offspring
-
getFitnessEvaluator
Returns the strength-based fitness evaluator.- Returns:
- the strength-based fitness evaluator
-
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
protected 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
-
truncate
Returns the population of solutions that survive to the next generation.- Parameters:
offspring- all offspring solutionssize- the number of solutions to retain- Returns:
- the population of solutions that survive to the next generation
-
computeDistanceMatrix
Computes the distance matrix containing the pair-wise distances between solutions in objective space. The diagonal will contain all 0's.- Parameters:
population- the population of solutions- Returns:
- the distance matrix
-