Class ImmutableSelectiveRefinementTournament<T extends Comparable<T>>

java.lang.Object
net.bmahe.genetics4j.core.spec.selection.SelectiveRefinementTournament<T>
net.bmahe.genetics4j.core.spec.selection.ImmutableSelectiveRefinementTournament<T>
All Implemented Interfaces:
SelectionPolicy

@Generated(from="SelectiveRefinementTournament", generator="Immutables") @Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableSelectiveRefinementTournament<T extends Comparable<T>> extends SelectiveRefinementTournament<T>
Immutable implementation of SelectiveRefinementTournament.

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

  • Field Details

  • Constructor Details

    • ImmutableSelectiveRefinementTournament

      private ImmutableSelectiveRefinementTournament(Tournament<T> tournament, Comparator<Individual<T>> refinementComparator, float refinementRatio)
  • Method Details

    • tournament

      public Tournament<T> tournament()
      Gets the base tournament configuration used for initial selection.

      This tournament defines the primary selection mechanism including the number of candidates per tournament and the comparison strategy for determining winners.

      Specified by:
      tournament in class SelectiveRefinementTournament<T extends Comparable<T>>
      Returns:
      the tournament configuration for initial selection
    • refinementComparator

      public Comparator<Individual<T>> refinementComparator()
      Gets the comparator used for refining the selection results.

      This comparator is applied during the refinement phase to reorder or filter a subset of the initially selected individuals. It allows for secondary selection criteria beyond basic fitness comparison, such as diversity measures, age-based preferences, or multi-objective considerations.

      Specified by:
      refinementComparator in class SelectiveRefinementTournament<T extends Comparable<T>>
      Returns:
      the comparator for refinement selection
    • refinementRatio

      public float refinementRatio()
      Gets the ratio of candidates that undergo refinement selection.

      This value determines what fraction of the initially selected candidates will be subject to the refinement process using the refinement comparator. A value of 0.0 means no refinement (equivalent to standard tournament), while 1.0 means all candidates undergo refinement.

      Specified by:
      refinementRatio in class SelectiveRefinementTournament<T extends Comparable<T>>
      Returns:
      the refinement ratio, must be between 0.0 and 1.0 inclusive
    • withTournament

      public final ImmutableSelectiveRefinementTournament<T> withTournament(Tournament<T> value)
      Copy the current immutable object by setting a value for the tournament attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for tournament
      Returns:
      A modified copy or the this object
    • withRefinementComparator

      public final ImmutableSelectiveRefinementTournament<T> withRefinementComparator(Comparator<Individual<T>> value)
      Copy the current immutable object by setting a value for the refinementComparator attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for refinementComparator
      Returns:
      A modified copy or the this object
    • withRefinementRatio

      public final ImmutableSelectiveRefinementTournament<T> withRefinementRatio(float value)
      Copy the current immutable object by setting a value for the refinementRatio attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for refinementRatio
      Returns:
      A modified copy or the this object
    • equals

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

      private boolean equalsByValue(ImmutableSelectiveRefinementTournament<?> another)
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: tournament, refinementComparator, refinementRatio.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

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

      public static <T extends Comparable<T>> SelectiveRefinementTournament<T> copyOf(SelectiveRefinementTournament<T> instance)
      Creates an immutable copy of a SelectiveRefinementTournament 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 SelectiveRefinementTournament instance