Package io.jenetics

Interface Alterer<G extends Gene<?,G>,C extends Comparable<? super C>>

Type Parameters:
G - the gene type
C - the fitness function result type
All Known Implementing Classes:
AbstractAlterer, CombineAlterer, Crossover, GaussianMutator, IntermediateCrossover, LineCrossover, MeanAlterer, MultiPointCrossover, Mutator, PartialAlterer, PartiallyMatchedCrossover, Recombinator, SinglePointCrossover, SwapMutator, UniformCrossover
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Alterer<G extends Gene<?,G>,C extends Comparable<? super C>>
The Alterer is responsible for the changing/recombining the Population. Alterers can be chained by appending a list of alterers with the Engine.Builder.alterers(Alterer, Alterer[]) method.
final Engine<DoubleGene, Double> engine = Engine .builder(gtf, ff) .alterers( new Crossover<>(0.1), new Mutator<>(0.05), new MeanAlterer<>(0.2)) .build(); final EvolutionStream<DoubleGene, Double> stream = engine.stream();
The order of the alterer calls is: Crossover, Mutation and MeanAlterer.
Since:
1.0
Version:
4.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    The default alter probability: 0.2
  • Method Summary

    Modifier and Type
    Method
    Description
    alter(Seq<Phenotype<G,C>> population, long generation)
    Alters (recombine) a given population.
    default Alterer<G,C>
    andThen(Alterer<G,C> after)
    Returns a composed alterer that applies the this alterer to its input, and then applies the after alterer to the result.
    default Alterer<G,C>
    compose(Alterer<G,C> before)
    Returns a composed alterer that first applies the before alterer to its input, and then applies this alterer to the result.
    static <G extends Gene<?, G>, C extends Comparable<? super C>>
    Alterer<G,C>
    of(Alterer<G,C>... alterers)
    Combine the given alterers.
  • Field Details

  • Method Details

    • alter

      AltererResult<G,C> alter(Seq<Phenotype<G,C>> population, long generation)
      Alters (recombine) a given population. If the population is empty, nothing is altered. The altered population is part of the returned AlterResult object.
      Parameters:
      population - The Population to be altered. If the population is null or empty, nothing is altered.
      generation - the date of birth (generation) of the altered phenotypes.
      Returns:
      the alter-result object, which contains the altered population and the alteration count
      Throws:
      NullPointerException - if the given population is null.
    • compose

      default Alterer<G,C> compose(Alterer<G,C> before)
      Returns a composed alterer that first applies the before alterer to its input, and then applies this alterer to the result.
      Parameters:
      before - the alterer to apply first
      Returns:
      the new composed alterer
    • andThen

      default Alterer<G,C> andThen(Alterer<G,C> after)
      Returns a composed alterer that applies the this alterer to its input, and then applies the after alterer to the result.
      Parameters:
      after - the alterer to apply first
      Returns:
      the new composed alterer
    • of

      @SafeVarargs static <G extends Gene<?, G>, C extends Comparable<? super C>> Alterer<G,C> of(Alterer<G,C>... alterers)
      Combine the given alterers.
      Type Parameters:
      G - the gene type
      C - the fitness function result type
      Parameters:
      alterers - the alterers to combine.
      Returns:
      a new alterer which consists of the given one
      Throws:
      NullPointerException - if one of the alterers is null.