Class ImmutableDoubleTournament<T extends Comparable<T>>

java.lang.Object
net.bmahe.genetics4j.gp.spec.selection.DoubleTournament<T>
net.bmahe.genetics4j.gp.spec.selection.ImmutableDoubleTournament<T>
All Implemented Interfaces:
SelectionPolicy

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

Use the builder to create immutable instances: ImmutableDoubleTournament.builder(). Use the static factory method to create immutable instances: ImmutableDoubleTournament.of().

  • Field Details

    • fitnessTournament

      private final Tournament<T extends Comparable<T>> fitnessTournament
    • parsimonyComparator

      private final Comparator<Individual<T extends Comparable<T>>> parsimonyComparator
    • parsimonyTournamentSize

      private final double parsimonyTournamentSize
    • doFitnessFirst

      private final boolean doFitnessFirst
  • Constructor Details

  • Method Details

    • fitnessTournament

      public Tournament<T> fitnessTournament()
      The fitness tournament configuration used for selecting individuals based on fitness. This tournament determines how many candidates compete in each fitness-based selection round.
      Specified by:
      fitnessTournament in class DoubleTournament<T extends Comparable<T>>
      Returns:
      the tournament configuration for fitness-based selection
    • parsimonyComparator

      public Comparator<Individual<T>> parsimonyComparator()
      Comparator used to evaluate parsimony (complexity) between individuals. Typically compares individuals based on size, depth, or other complexity metrics. The comparator should return:
      • Negative value if first individual is less complex than second
      • Zero if both individuals have equal complexity
      • Positive value if first individual is more complex than second
      Specified by:
      parsimonyComparator in class DoubleTournament<T extends Comparable<T>>
      Returns:
      the comparator for evaluating individual complexity
    • parsimonyTournamentSize

      public double parsimonyTournamentSize()
      Controls the selection pressure toward less complex individuals in parsimony tournaments. Must be between 0.0 and 2.0 inclusive.
      • 0.0: No parsimony pressure, selection is random
      • 1.0: Balanced parsimony pressure
      • 2.0: Maximum parsimony pressure, always selects less complex individual
      Specified by:
      parsimonyTournamentSize in class DoubleTournament<T extends Comparable<T>>
      Returns:
      the parsimony tournament size parameter
    • doFitnessFirst

      public boolean doFitnessFirst()
      Determines the order of selection operations.
      • true (default): Fitness first mode - perform fitness tournaments first, then apply parsimony selection between winners
      • false: Parsimony first mode - apply parsimony selection to random pairs first, then perform fitness tournament among parsimony winners
      Overrides:
      doFitnessFirst in class DoubleTournament<T extends Comparable<T>>
      Returns:
      true for fitness-first mode, false for parsimony-first mode
    • withFitnessTournament

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

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

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

      public final ImmutableDoubleTournament<T> withDoFitnessFirst(boolean value)
      Copy the current immutable object by setting a value for the doFitnessFirst attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for doFitnessFirst
      Returns:
      A modified copy or the this object
    • equals

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

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

      public int hashCode()
      Computes a hash code from attributes: fitnessTournament, parsimonyComparator, parsimonyTournamentSize, doFitnessFirst.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

      public static <T extends Comparable<T>> DoubleTournament<T> of(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize)
      Construct a new immutable DoubleTournament instance.
      Type Parameters:
      T - generic parameter T
      Parameters:
      fitnessTournament - The value for the fitnessTournament attribute
      parsimonyComparator - The value for the parsimonyComparator attribute
      parsimonyTournamentSize - The value for the parsimonyTournamentSize attribute
      Returns:
      An immutable DoubleTournament instance
    • validate

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

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

      public static <T extends Comparable<T>> ImmutableDoubleTournament.Builder<T> builder()
      Creates a builder for DoubleTournament.
       ImmutableDoubleTournament.<T>builder()
          .fitnessTournament(net.bmahe.genetics4j.core.spec.selection.Tournament<T>) // required fitnessTournament
          .parsimonyComparator(Comparator<net.bmahe.genetics4j.core.Individual<T>>) // required parsimonyComparator
          .parsimonyTournamentSize(double) // required parsimonyTournamentSize
          .doFitnessFirst(boolean) // optional doFitnessFirst
          .build();
       
      Type Parameters:
      T - generic parameter T
      Returns:
      A new DoubleTournament builder