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>
The 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 to memory: remember the best solution found so far. A problem with elitism is that it may cause 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
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    select(Seq<Phenotype<G,C>> population, int count, Optimize opt)
    Select phenotypes from the Population.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • 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 individuals to be selected
      nonEliteSelector - the selector used for selecting the rest of the population
      Throws:
      IllegalArgumentException - if eliteCount < 1
      NullPointerException - if the nonEliteSelector is null
    • 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 with TournamentSelector<>(3).
      Parameters:
      eliteCount - the desired number of elite individuals to be selected
      Throws:
      IllegalArgumentException - if eliteCount < 1
      See Also:
    • 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 the nonEliteSelector is null
      See Also:
    • EliteSelector

      public 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)
  • Method Details

    • 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 interface Selector<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).
    • toString

      public String toString()
      Overrides:
      toString in class Object