public class EliteSelector<G extends Gene<?,G>,C extends Comparable<? super C>> extends Object implements Selector<G,C>
EliteSelector
copies a small proportion of the fittest candidates,
without changes, into the next generation. This may have a dramatic impact on
performance by ensuring that the GA doesn't waste time re-discovering
previously refused partial solutions. Individuals that are preserved through
elitism remain eligible for selection as parents of the next generation.
Elitism is also related with memory: remember the best solution found so far.
A problem with elitism is that it may causes the GA to converge to a local
optimum, so pure elitism is a race to the nearest local optimum.
final Selector<DoubleGene, Double> selector = new EliteSelector<>(
// Number of best individuals preserved for next generation: elites
3,
// Selector used for selecting rest of population.
new RouletteWheelSelector<>()
);
Constructor and Description |
---|
EliteSelector()
Create a new elite selector with elite count 1 and the selector for
selecting the rest of the population is initialized with
TournamentSelector<>(3) |
EliteSelector(int eliteCount)
Create a new elite selector with the desired number of elites to be
selected.
|
EliteSelector(int eliteCount,
Selector<G,C> nonEliteSelector)
Create a new elite selector with the desired number of elites to be
selected and the selector used for selecting the rest of the population.
|
EliteSelector(Selector<G,C> nonEliteSelector)
Create a new elite selector with selector used for selecting the rest of
the population.
|
public EliteSelector(int eliteCount, Selector<G,C> nonEliteSelector)
eliteCount
- the desired number of elite individual to be selectednonEliteSelector
- the selector used for selecting the rest of the
populationIllegalArgumentException
- if eliteCount < 1
NullPointerException
- if the nonEliteSelector
is
null
public EliteSelector(int eliteCount)
TournamentSelector<>(3)
.eliteCount
- the desired number of elite individual to be selectedIllegalArgumentException
- if eliteCount < 1
TournamentSelector
public EliteSelector(Selector<G,C> nonEliteSelector)
nonEliteSelector
- the selector used for selecting the rest of the
populationNullPointerException
- if the nonEliteSelector
is
null
TournamentSelector
public EliteSelector()
TournamentSelector<>(3)
public ISeq<Phenotype<G,C>> select(Seq<Phenotype<G,C>> population, int count, Optimize opt)
Selector
select
in interface Selector<G extends Gene<?,G>,C extends Comparable<? super C>>
population
- The population to select from.count
- The number of phenotypes to select.opt
- Determines whether the individuals with higher fitness values
or lower fitness values must be selected. This parameter determines
whether the GA maximizes or minimizes the fitness function.© 2007-2019 Franz Wilhelmstötter (2019-02-19 21:44)