Class ImmutableEAConfiguration<T extends Comparable<T>>


@Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableEAConfiguration<T extends Comparable<T>> extends EAConfiguration<T>
Immutable implementation of EAConfiguration.

Use the builder to create immutable instances: new EAConfiguration.Builder().

  • Field Details

  • Constructor Details

  • Method Details

    • chromosomeSpecs

      public List<ChromosomeSpec> chromosomeSpecs()
      Genotype of the population
      Specified by:
      chromosomeSpecs in class AbstractEAConfiguration<T extends Comparable<T>>
      Returns:
    • parentSelectionPolicy

      public SelectionPolicy parentSelectionPolicy()
      Defines the policy to select the parents. The selected parents will be used for generating the new offsprings
      Specified by:
      parentSelectionPolicy in class AbstractEAConfiguration<T extends Comparable<T>>
      Returns:
    • combinationPolicy

      public CombinationPolicy combinationPolicy()
      Defines the policy to generate new offsprings from two parents
      Specified by:
      combinationPolicy in class AbstractEAConfiguration<T extends Comparable<T>>
      Returns:
    • mutationPolicies

      public List<MutationPolicy> mutationPolicies()
      Defines what mutations to be performed on the offsprings
      Specified by:
      mutationPolicies in class AbstractEAConfiguration<T extends Comparable<T>>
      Returns:
    • replacementStrategy

      public ReplacementStrategy replacementStrategy()
      Defines the replacement strategy

      The replacement strategy is what will determine the next population based on the generated and mutated offsprings along with the current population

      If not specified, the default replacement strategy will be to use Elitism with tournament selection of 3 individuals for both offsprings and survivors. The default offspring ratio is

      invalid reference
      Elitism#DEFAULT_OFFSPRING_RATIO
      Overrides:
      replacementStrategy in class AbstractEAConfiguration<T extends Comparable<T>>
      Returns:
    • postEvaluationProcessor

      public Optional<Function<Population<T>,Population<T>>> postEvaluationProcessor()
      Post-processing of a population after it got evaluated

      This gives the opportunity to filter out, repair or rescore individuals

      Specified by:
      postEvaluationProcessor in class AbstractEAConfiguration<T extends Comparable<T>>
      Returns:
      Population to be used by the remaining evolution process
    • termination

      public Termination<T> termination()
      Defines termination condition
      Specified by:
      termination in class AbstractEAConfiguration<T extends Comparable<T>>
      Returns:
    • genotypeGenerator

      public Optional<Supplier<Genotype>> genotypeGenerator()
      Defines how to generate individuals

      If not specified, the system will rely on the chromosome factories

      Specified by:
      genotypeGenerator in class AbstractEAConfiguration<T extends Comparable<T>>
      Returns:
    • seedPopulation

      public Collection<Genotype> seedPopulation()
      Seed the initial population with specific individuals
      Overrides:
      seedPopulation in class AbstractEAConfiguration<T extends Comparable<T>>
      Returns:
    • genotypeCombinator

      public GenotypeCombinator genotypeCombinator()
      Defines how to combine the offspring chromosomes generated

      Combination of individuals is done on a per chromosome basis. This means some parents may generate a different number of children for each chromosome. This method will therefore define how to take all these generated chromosomes and combine them into offspring individuals

      The current default implementation is to generate as many individual as there are combinations of generated chromosomes

      Overrides:
      genotypeCombinator in class AbstractEAConfiguration<T extends Comparable<T>>
      Returns:
    • offspringGeneratedRatio

      public double offspringGeneratedRatio()
      Defines how many children will be generated at each iteration. Value must be between 0 and 1 (inclusive) and represents a fraction of the population size
      Overrides:
      offspringGeneratedRatio in class AbstractEAConfiguration<T extends Comparable<T>>
      Returns:
    • optimization

      public Optimization optimization()
      Defines the optimization goal, whether we want to maximize the fitness or minimize it
      Overrides:
      optimization in class AbstractEAConfiguration<T extends Comparable<T>>
      Returns:
    • fitness

      public Fitness<T> fitness()
      Defines how should individuals' fitness be assessed
      Specified by:
      fitness in class EAConfiguration<T extends Comparable<T>>
      Returns:
    • withChromosomeSpecs

      public final ImmutableEAConfiguration<T> withChromosomeSpecs(ChromosomeSpec... elements)
      Copy the current immutable object with elements that replace the content of chromosomeSpecs.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withChromosomeSpecs

      public final ImmutableEAConfiguration<T> withChromosomeSpecs(Iterable<? extends ChromosomeSpec> elements)
      Copy the current immutable object with elements that replace the content of chromosomeSpecs. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of chromosomeSpecs elements to set
      Returns:
      A modified copy of this object
    • withParentSelectionPolicy

      public final ImmutableEAConfiguration<T> withParentSelectionPolicy(SelectionPolicy value)
      Copy the current immutable object by setting a value for the parentSelectionPolicy attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for parentSelectionPolicy
      Returns:
      A modified copy of the this object
    • withCombinationPolicy

      public final ImmutableEAConfiguration<T> withCombinationPolicy(CombinationPolicy value)
      Copy the current immutable object by setting a value for the combinationPolicy attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for combinationPolicy
      Returns:
      A modified copy of the this object
    • withMutationPolicies

      public final ImmutableEAConfiguration<T> withMutationPolicies(MutationPolicy... elements)
      Copy the current immutable object with elements that replace the content of mutationPolicies.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withMutationPolicies

      public final ImmutableEAConfiguration<T> withMutationPolicies(Iterable<? extends MutationPolicy> elements)
      Copy the current immutable object with elements that replace the content of mutationPolicies. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of mutationPolicies elements to set
      Returns:
      A modified copy of this object
    • withReplacementStrategy

      public final ImmutableEAConfiguration<T> withReplacementStrategy(ReplacementStrategy value)
      Copy the current immutable object by setting a value for the replacementStrategy attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for replacementStrategy
      Returns:
      A modified copy of the this object
    • withPostEvaluationProcessor

      public final ImmutableEAConfiguration<T> withPostEvaluationProcessor(Function<Population<T>,Population<T>> value)
      Copy the current immutable object by setting a present value for the optional postEvaluationProcessor attribute.
      Parameters:
      value - The value for postEvaluationProcessor
      Returns:
      A modified copy of this object
    • withPostEvaluationProcessor

      public final ImmutableEAConfiguration<T> withPostEvaluationProcessor(Optional<? extends Function<Population<T>,Population<T>>> optional)
      Copy the current immutable object by setting an optional value for the postEvaluationProcessor attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for postEvaluationProcessor
      Returns:
      A modified copy of this object
    • withTermination

      public final ImmutableEAConfiguration<T> withTermination(Termination<T> value)
      Copy the current immutable object by setting a value for the termination attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for termination
      Returns:
      A modified copy of the this object
    • withGenotypeGenerator

      public final ImmutableEAConfiguration<T> withGenotypeGenerator(Supplier<Genotype> value)
      Copy the current immutable object by setting a present value for the optional genotypeGenerator attribute.
      Parameters:
      value - The value for genotypeGenerator
      Returns:
      A modified copy of this object
    • withGenotypeGenerator

      public final ImmutableEAConfiguration<T> withGenotypeGenerator(Optional<? extends Supplier<Genotype>> optional)
      Copy the current immutable object by setting an optional value for the genotypeGenerator attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for genotypeGenerator
      Returns:
      A modified copy of this object
    • withSeedPopulation

      public final ImmutableEAConfiguration<T> withSeedPopulation(Collection<Genotype> value)
      Copy the current immutable object by setting a value for the seedPopulation attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for seedPopulation
      Returns:
      A modified copy of the this object
    • withGenotypeCombinator

      public final ImmutableEAConfiguration<T> withGenotypeCombinator(GenotypeCombinator value)
      Copy the current immutable object by setting a value for the genotypeCombinator attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for genotypeCombinator
      Returns:
      A modified copy of the this object
    • withOffspringGeneratedRatio

      public final ImmutableEAConfiguration<T> withOffspringGeneratedRatio(double value)
      Copy the current immutable object by setting a value for the offspringGeneratedRatio attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for offspringGeneratedRatio
      Returns:
      A modified copy of the this object
    • withOptimization

      public final ImmutableEAConfiguration<T> withOptimization(Optimization value)
      Copy the current immutable object by setting a value for the optimization attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for optimization
      Returns:
      A modified copy of the this object
    • withFitness

      public final ImmutableEAConfiguration<T> withFitness(Fitness<T> value)
      Copy the current immutable object by setting a value for the fitness attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for fitness
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableEAConfiguration that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • equalTo

      private boolean equalTo(int synthetic, ImmutableEAConfiguration<?> another)
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: chromosomeSpecs, parentSelectionPolicy, combinationPolicy, mutationPolicies, replacementStrategy, postEvaluationProcessor, termination, genotypeGenerator, seedPopulation, genotypeCombinator, offspringGeneratedRatio, optimization, fitness.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value EAConfiguration with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • validate

      private static <T extends Comparable<T>> ImmutableEAConfiguration<T> validate(ImmutableEAConfiguration<T> instance)
    • copyOf

      public static <T extends Comparable<T>> ImmutableEAConfiguration<T> copyOf(EAConfiguration<T> instance)
      Creates an immutable copy of a EAConfiguration value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Type Parameters:
      T - generic parameter T
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable EAConfiguration instance
    • createSafeList

      private static <T> List<T> createSafeList(Iterable<? extends T> iterable, boolean checkNulls, boolean skipNulls)
    • createUnmodifiableList

      private static <T> List<T> createUnmodifiableList(boolean clone, List<T> list)