public class Spea2 extends java.lang.Object implements Selector
The Spea2
-Selector is a Java implementation of the SPEA2-MOEA, see "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.".
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
.
Modifier and Type | Field and Description |
---|---|
protected double[][] |
distance |
protected boolean |
fitnessDirty |
protected java.util.LinkedList<java.lang.Integer> |
freeIDs |
protected java.util.Set<org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet> |
individualSets |
protected java.util.Map<org.opt4j.core.Individual,org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet> |
map |
protected org.opt4j.core.common.random.Rand |
random |
protected int |
tournament |
Constructor and Description |
---|
Spea2(int tournament,
org.opt4j.core.common.random.Rand random)
|
Modifier and Type | Method and Description |
---|---|
protected void |
add(org.opt4j.core.Individual individual)
Add a new
Individual . |
protected double |
calculateDistance(org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet w0,
org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet w1)
Calculate the distance between two
Spea2IndividualSet s. |
protected void |
calculateFitness()
Calculate the fitness.
|
protected double |
distance(org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet w0,
org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet w1)
Return the distance of two
Spea2IndividualSet s. |
protected java.util.List<org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet> |
getDominated()
Returns all dominated
Spea2IndividualSet s (fitness > 0). |
java.util.Collection<org.opt4j.core.Individual> |
getLames(int lambda,
java.util.Collection<org.opt4j.core.Individual> population)
Selects a subset of
lambda Individual s and returns it as
a new Collection . |
java.util.Collection<org.opt4j.core.Individual> |
getLamesFromNonDominated(int count)
Returns a specific number of lames from the non-dominated
Individual s. |
protected double |
getMinDistance(org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet w0) |
protected java.util.List<org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet> |
getNearest(int n,
java.util.Collection<org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet> candidates)
Returns n with nearest neighbor based on distances.
|
protected java.util.List<org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet> |
getNonDominated()
Returns all non-dominated
Spea2IndividualSet s (fitness == 0). |
java.util.Collection<org.opt4j.core.Individual> |
getParents(int mu,
java.util.Collection<org.opt4j.core.Individual> population)
Selects a subset of
Individual s and returns it as a new
Collection . |
void |
init(int maxsize)
Sets the maximal number of
Individual s. |
protected void |
remove(org.opt4j.core.Individual individual)
Remove an
Individual . |
protected void |
update(java.util.Collection<org.opt4j.core.Individual> population)
Update with current population.
|
protected final org.opt4j.core.common.random.Rand random
protected final int tournament
protected final java.util.Map<org.opt4j.core.Individual,org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet> map
protected final java.util.Set<org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet> individualSets
protected final java.util.LinkedList<java.lang.Integer> freeIDs
protected double[][] distance
protected boolean fitnessDirty
@Inject public Spea2(int tournament, org.opt4j.core.common.random.Rand random)
tournament
- the number of individuals that fight against each other to
become a parentrandom
- the random number generatorpublic void init(int maxsize)
Selector
Individual
s.public java.util.Collection<org.opt4j.core.Individual> getParents(int mu, java.util.Collection<org.opt4j.core.Individual> population)
Selector
Individual
s and returns it as a new
Collection
. These so called parents can be used to form the next
generation.getParents
in interface Selector
mu
- the number of parents to selectpopulation
- the list of individualspublic java.util.Collection<org.opt4j.core.Individual> getLames(int lambda, java.util.Collection<org.opt4j.core.Individual> population)
Selector
lambda
Individual
s and returns it as
a new Collection
. These individuals can be erased in the next
generation.public java.util.Collection<org.opt4j.core.Individual> getLamesFromNonDominated(int count)
Individual
s.count
- the specified numberprotected java.util.List<org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet> getNearest(int n, java.util.Collection<org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet> candidates)
n
- the number of required IndividualSetscandidates
- the candidate IndividualSetsprotected double getMinDistance(org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet w0)
protected void update(java.util.Collection<org.opt4j.core.Individual> population)
population
- the current populationprotected double distance(org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet w0, org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet w1)
Spea2IndividualSet
s.w0
- first setw1
- second setprotected void add(org.opt4j.core.Individual individual)
Individual
.individual
- the individual to addprotected void remove(org.opt4j.core.Individual individual)
Individual
.individual
- the individual to removeprotected double calculateDistance(org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet w0, org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet w1)
Spea2IndividualSet
s.w0
- the first setw1
- the second setprotected void calculateFitness()
protected java.util.List<org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet> getDominated()
Spea2IndividualSet
s (fitness > 0).protected java.util.List<org.opt4j.optimizers.ea.Spea2.Spea2IndividualSet> getNonDominated()
Spea2IndividualSet
s (fitness == 0).