Package org.opt4j.optimizer.ea
Class Spea2
java.lang.Object
org.opt4j.optimizer.ea.Spea2
- All Implemented Interfaces:
Selector
The Spea2
-Selector is a Java implementation of the SPEA2-MOEA.
The Spea2
-Selector will not work properly if the Objectives
are not fixed, i.e., the Objectives
of an Individual
change
during the optimization process. This caused by the internal caching of
distances, etc. In this case, it is recommended to use the Nsga2
.
- See Also:
-
- "SPEA2: Improving the Strength Pareto Evolutionary Algorithm For Multiobjective Optimization, Eckart Zitzler, Marco Laumanns, and Lothar Thiele, In Evolutionary Methods for Design, Optimisation, and Control, pages 19–26, 2002."
-
Field Summary
Modifier and TypeFieldDescriptionprotected double[][]
protected boolean
protected final LinkedList<Integer>
protected final Set<org.opt4j.optimizer.ea.Spea2.IndividualSet>
protected final Map<Individual,
org.opt4j.optimizer.ea.Spea2.IndividualSet> protected final Rand
protected final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
add
(Individual individual) Add a newIndividual
.protected double
calculateDistance
(org.opt4j.optimizer.ea.Spea2.IndividualSet w0, org.opt4j.optimizer.ea.Spea2.IndividualSet w1) Calculate the distance between twoSpea2.IndividualSet
s.protected void
Calculate the fitness.protected double
distance
(org.opt4j.optimizer.ea.Spea2.IndividualSet w0, org.opt4j.optimizer.ea.Spea2.IndividualSet w1) Return the distance of twoSpea2.IndividualSet
s.protected List<org.opt4j.optimizer.ea.Spea2.IndividualSet>
Returns all dominatedSpea2.IndividualSet
s (fitness > 0).getLames
(int lambda, Collection<Individual> population) getLamesFromNonDominated
(int count) Returns a specific number of lames from the non-dominatedIndividual
s.protected double
getMinDistance
(org.opt4j.optimizer.ea.Spea2.IndividualSet w0) protected List<org.opt4j.optimizer.ea.Spea2.IndividualSet>
getNearest
(int n, Collection<org.opt4j.optimizer.ea.Spea2.IndividualSet> candidates) Returns n with nearest neighbor based on distances.protected List<org.opt4j.optimizer.ea.Spea2.IndividualSet>
Returns all non-dominatedSpea2.IndividualSet
s (fitness == 0).getParents
(int mu, Collection<Individual> population) Selects a subset ofIndividual
s and returns it as a newCollection
.void
init
(int maxsize) Sets the maximal number ofIndividual
s.protected void
remove
(Individual individual) Remove anIndividual
.protected void
update
(Collection<Individual> population) Update with current population.
-
Field Details
-
random
-
tournament
protected final int tournament -
map
-
individualSets
-
freeIDs
-
distance
protected double[][] distance -
fitnessDirty
protected boolean fitnessDirty
-
-
Constructor Details
-
Spea2
- Parameters:
tournament
- the number of individuals that fight against each other to become a parentrandom
- the random number generator
-
-
Method Details
-
init
public void init(int maxsize) Description copied from interface:Selector
Sets the maximal number ofIndividual
s. -
getParents
Description copied from interface:Selector
Selects a subset ofIndividual
s and returns it as a newCollection
. These so called parents can be used to form the next generation.- Specified by:
getParents
in interfaceSelector
- Parameters:
mu
- the number of parents to selectpopulation
- the list of individuals- Returns:
- the parents
-
getLames
Description copied from interface:Selector
Selects a subset oflambda
Individual
s and returns it as a newCollection
. These individuals can be erased in the next generation. -
getLamesFromNonDominated
Returns a specific number of lames from the non-dominatedIndividual
s.- Parameters:
count
- the specified number- Returns:
- a collection of the lame individuals
-
getNearest
protected List<org.opt4j.optimizer.ea.Spea2.IndividualSet> getNearest(int n, Collection<org.opt4j.optimizer.ea.Spea2.IndividualSet> candidates) Returns n with nearest neighbor based on distances.- Parameters:
n
- the number of required IndividualSetscandidates
- the candidate IndividualSets- Returns:
- the n nearest neighbors
-
getMinDistance
protected double getMinDistance(org.opt4j.optimizer.ea.Spea2.IndividualSet w0) -
update
Update with current population.- Parameters:
population
- the current population
-
distance
protected double distance(org.opt4j.optimizer.ea.Spea2.IndividualSet w0, org.opt4j.optimizer.ea.Spea2.IndividualSet w1) Return the distance of twoSpea2.IndividualSet
s.- Parameters:
w0
- first setw1
- second set- Returns:
- the distance
-
add
Add a newIndividual
.- Parameters:
individual
- the individual to add
-
remove
Remove anIndividual
.- Parameters:
individual
- the individual to remove
-
calculateDistance
protected double calculateDistance(org.opt4j.optimizer.ea.Spea2.IndividualSet w0, org.opt4j.optimizer.ea.Spea2.IndividualSet w1) Calculate the distance between twoSpea2.IndividualSet
s.- Parameters:
w0
- the first setw1
- the second set- Returns:
- the distance
-
calculateFitness
protected void calculateFitness()Calculate the fitness. -
getDominated
Returns all dominatedSpea2.IndividualSet
s (fitness > 0).- Returns:
- all dominated IndividualSets
-
getNonDominated
Returns all non-dominatedSpea2.IndividualSet
s (fitness == 0).- Returns:
- all non-dominated individualSets
-