Class ImmutableElitism

java.lang.Object
net.bmahe.genetics4j.core.spec.replacement.ImmutableElitism
All Implemented Interfaces:
Elitism, ReplacementStrategy

@Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableElitism extends Object implements Elitism
Immutable implementation of Elitism.

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

  • Field Details

    • offspringSelectionPolicy

      private final SelectionPolicy offspringSelectionPolicy
    • atLeastNumOffsprings

      private final int atLeastNumOffsprings
    • survivorSelectionPolicy

      private final SelectionPolicy survivorSelectionPolicy
    • atLeastNumSurvivors

      private final int atLeastNumSurvivors
    • offspringRatio

      private final double offspringRatio
    • STAGE_INITIALIZING

      private static final byte STAGE_INITIALIZING
      See Also:
    • STAGE_UNINITIALIZED

      private static final byte STAGE_UNINITIALIZED
      See Also:
    • STAGE_INITIALIZED

      private static final byte STAGE_INITIALIZED
      See Also:
    • initShim

      private transient volatile ImmutableElitism.InitShim initShim
  • Constructor Details

    • ImmutableElitism

      private ImmutableElitism(ImmutableElitism.Builder builder)
    • ImmutableElitism

      private ImmutableElitism(SelectionPolicy offspringSelectionPolicy, int atLeastNumOffsprings, SelectionPolicy survivorSelectionPolicy, int atLeastNumSurvivors, double offspringRatio)
  • Method Details

    • atLeastNumOffspringsInitialize

      private int atLeastNumOffspringsInitialize()
    • atLeastNumSurvivorsInitialize

      private int atLeastNumSurvivorsInitialize()
    • offspringRatioInitialize

      private double offspringRatioInitialize()
    • offspringSelectionPolicy

      public SelectionPolicy offspringSelectionPolicy()
      Returns the policy used to select offsprings for the next generation.
      Specified by:
      offspringSelectionPolicy in interface Elitism
      Returns:
      the policy used to select offsprings for the next generation
    • atLeastNumOffsprings

      public int atLeastNumOffsprings()
      Returns how many offsprings that elitism will always select.
      Specified by:
      atLeastNumOffsprings in interface Elitism
      Returns:
      how many offsprings that elitism will always select
    • survivorSelectionPolicy

      public SelectionPolicy survivorSelectionPolicy()
      Returns the policy used to select survivors for the next generation.
      Specified by:
      survivorSelectionPolicy in interface Elitism
      Returns:
      the policy used to select survivors for the next generation
    • atLeastNumSurvivors

      public int atLeastNumSurvivors()
      Returns how many survivors that elitism will always select.
      Specified by:
      atLeastNumSurvivors in interface Elitism
      Returns:
      how many survivors that elitism will always select
    • offspringRatio

      public double offspringRatio()
      Returns how many children will be generated at each iteration. Value must be between 0 and 1 (inclusive)

      The number of survivor will be the complement of it, or 1 - offspringRatio().

      Specified by:
      offspringRatio in interface Elitism
      Returns:
      how many children will be generated at each iteration. Value must be between 0 and 1 (inclusive)

      The number of survivor will be the complement of it, or 1 - offspringRatio()

    • withOffspringSelectionPolicy

      public final ImmutableElitism withOffspringSelectionPolicy(SelectionPolicy value)
      Copy the current immutable object by setting a value for the offspringSelectionPolicy attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for offspringSelectionPolicy
      Returns:
      A modified copy of the this object
    • withAtLeastNumOffsprings

      public final ImmutableElitism withAtLeastNumOffsprings(int value)
      Copy the current immutable object by setting a value for the atLeastNumOffsprings attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for atLeastNumOffsprings
      Returns:
      A modified copy of the this object
    • withSurvivorSelectionPolicy

      public final ImmutableElitism withSurvivorSelectionPolicy(SelectionPolicy value)
      Copy the current immutable object by setting a value for the survivorSelectionPolicy attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for survivorSelectionPolicy
      Returns:
      A modified copy of the this object
    • withAtLeastNumSurvivors

      public final ImmutableElitism withAtLeastNumSurvivors(int value)
      Copy the current immutable object by setting a value for the atLeastNumSurvivors attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for atLeastNumSurvivors
      Returns:
      A modified copy of the this object
    • withOffspringRatio

      public final ImmutableElitism withOffspringRatio(double value)
      Copy the current immutable object by setting a value for the offspringRatio attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for offspringRatio
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableElitism 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, ImmutableElitism another)
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: offspringSelectionPolicy, atLeastNumOffsprings, survivorSelectionPolicy, atLeastNumSurvivors, offspringRatio.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

      private static ImmutableElitism validate(ImmutableElitism instance)
    • copyOf

      public static ImmutableElitism copyOf(Elitism instance)
      Creates an immutable copy of a Elitism value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable Elitism instance