public class ElitismSelector extends java.lang.Object implements Selector
ElitismSelector
is a single objective elitism select. If a
multi-objective problem is optimized, the objectives are summed up to a
single value.Modifier and Type | Class and Description |
---|---|
protected class |
ElitismSelector.FitnessComparator
Comparator that sorts the
Individual s based on their fitness
values. |
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<org.opt4j.core.Individual,java.lang.Double> |
fitness |
protected java.util.Random |
random |
Constructor and Description |
---|
ElitismSelector(org.opt4j.core.common.random.Rand random)
Constructs an
ElitismSelector . |
Modifier and Type | Method and Description |
---|---|
protected void |
calculateFitness(java.util.Collection<org.opt4j.core.Individual> individuals)
Calculates the fitness of the
Individual s: the sum of all double
values (these always have to be minimized) of the objectives. |
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> |
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 final java.util.Random random
protected final java.util.Map<org.opt4j.core.Individual,java.lang.Double> fitness
@Inject public ElitismSelector(org.opt4j.core.common.random.Rand random)
ElitismSelector
.random
- the random number generatorpublic 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> 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 individualsprotected void calculateFitness(java.util.Collection<org.opt4j.core.Individual> individuals)
Individual
s: the sum of all double
values (these always have to be minimized) of the objectives.individuals
- the individuals to process