Class Replacement<T>

  • Type Parameters:
    T - The type of evolvable entity that this operator applies to.
    All Implemented Interfaces:
    EvolutionaryOperator<T>

    public class Replacement<T>
    extends Object
    implements EvolutionaryOperator<T>
    An evolutionary operator that replaces individuals with randomly-generated new individuals, according to some specified probability. The new individuals are not derived from the selected individuals, they are completely random. This operator provides a way to prevent stagnation by occassionally introducing new genetic material into the population.
    • Constructor Detail

      • Replacement

        public Replacement​(CandidateFactory<T> factory,
                           Probability replacementProbability)
        Creates a replacement operator that replaces individuals according to the specified probability. New individuals are obtained from the factory provided.
        Parameters:
        factory - A source of new individuals.
        replacementProbability - The probability that any given individual will be replaced by a new individual. This should typically be quite low. If it is too high, it will undermine the evolutionary progress.
      • Replacement

        public Replacement​(CandidateFactory<T> factory,
                           NumberGenerator<Probability> replacementProbability)
        Creates a replacement operator that replaces individuals according to a variable probability. New individuals are obtained from the factory provided.
        Parameters:
        factory - A source of new individuals.
        replacementProbability - A NumberGenerator that provides a probability of replacement. The probablity may be constant, or it may change over time. The probability should typically be quite low. If it is too high, it will undermine the evolutionary progress.
    • Method Detail

      • apply

        public List<T> apply​(List<T> selectedCandidates,
                             Random rng)
        Randomly replace zero or more of the selected candidates with new, independent individuals that are randomly created.
        Specified by:
        apply in interface EvolutionaryOperator<T>
        Parameters:
        selectedCandidates - The selected candidates, some of these may be discarded and replaced with new individuals.
        rng - A source of randomness.
        Returns:
        The remaining candidates after some (or none) have been replaced with new individuals.