Package io.jenetics
Class EliteSelector<G extends Gene<?,G>,C extends Comparable<? super C>>
- java.lang.Object
-
- io.jenetics.EliteSelector<G,C>
-
- All Implemented Interfaces:
Selector<G,C>
public class EliteSelector<G extends Gene<?,G>,C extends Comparable<? super C>> extends Object implements Selector<G,C>
TheEliteSelector
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<>() );
- Since:
- 4.0
- Version:
- 5.0
-
-
Constructor Summary
Constructors Constructor Description EliteSelector()
Create a new elite selector with elite count 1 and the selector for selecting the rest of the population is initialized withTournamentSelector<>(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.
-
-
-
Constructor Detail
-
EliteSelector
public 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.- Parameters:
eliteCount
- the desired number of elite individual to be selectednonEliteSelector
- the selector used for selecting the rest of the population- Throws:
IllegalArgumentException
- ifeliteCount < 1
NullPointerException
- if thenonEliteSelector
isnull
-
EliteSelector
public EliteSelector(int eliteCount)
Create a new elite selector with the desired number of elites to be selected. The selector for selecting the rest of the population is initialized withTournamentSelector<>(3)
.- Parameters:
eliteCount
- the desired number of elite individual to be selected- Throws:
IllegalArgumentException
- ifeliteCount < 1
- See Also:
TournamentSelector
-
EliteSelector
public EliteSelector(Selector<G,C> nonEliteSelector)
Create a new elite selector with selector used for selecting the rest of the population. The elite count is set to 1.- Parameters:
nonEliteSelector
- the selector used for selecting the rest of the population- Throws:
NullPointerException
- if thenonEliteSelector
isnull
- See Also:
TournamentSelector
-
EliteSelector
public EliteSelector()
Create a new elite selector with elite count 1 and the selector for selecting the rest of the population is initialized withTournamentSelector<>(3)
-
-
Method Detail
-
select
public ISeq<Phenotype<G,C>> select(Seq<Phenotype<G,C>> population, int count, Optimize opt)
Description copied from interface:Selector
Select phenotypes from the Population.- Specified by:
select
in interfaceSelector<G extends Gene<?,G>,C extends Comparable<? super C>>
- Parameters:
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.- Returns:
- The selected phenotypes (a new Population).
-
-