Class ImmutableDoubleTournament.Builder<T extends Comparable<T>>

java.lang.Object
net.bmahe.genetics4j.core.spec.selection.ImmutableDoubleTournament.Builder<T>
Enclosing class:
ImmutableDoubleTournament<T extends Comparable<T>>

public static final class ImmutableDoubleTournament.Builder<T extends Comparable<T>> extends Object
Builds instances of type ImmutableDoubleTournament. Initialize attributes and then invoke the build() method to create an immutable instance.

Builder is not thread-safe and generally should not be stored in a field or collection, but instead used immediately to create instances.

  • Field Details

    • INIT_BIT_FITNESS_TOURNAMENT

      private static final long INIT_BIT_FITNESS_TOURNAMENT
      See Also:
    • INIT_BIT_PARSIMONY_COMPARATOR

      private static final long INIT_BIT_PARSIMONY_COMPARATOR
      See Also:
    • INIT_BIT_PARSIMONY_TOURNAMENT_SIZE

      private static final long INIT_BIT_PARSIMONY_TOURNAMENT_SIZE
      See Also:
    • OPT_BIT_DO_FITNESS_FIRST

      private static final long OPT_BIT_DO_FITNESS_FIRST
      See Also:
    • initBits

      private long initBits
    • optBits

      private long optBits
    • fitnessTournament

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

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

      private double parsimonyTournamentSize
    • doFitnessFirst

      private boolean doFitnessFirst
  • Constructor Details

    • Builder

      private Builder()
  • Method Details

    • from

      public final ImmutableDoubleTournament.Builder<T> from(DoubleTournament<T> instance)
      Fill a builder with attribute values from the provided DoubleTournament instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values.
      Parameters:
      instance - The instance from which to copy values
      Returns:
      this builder for use in a chained invocation
    • fitnessTournament

      public final ImmutableDoubleTournament.Builder<T> fitnessTournament(Tournament<T> fitnessTournament)
      Initializes the value for the fitnessTournament attribute.
      Parameters:
      fitnessTournament - The value for fitnessTournament
      Returns:
      this builder for use in a chained invocation
    • parsimonyComparator

      public final ImmutableDoubleTournament.Builder<T> parsimonyComparator(Comparator<Individual<T>> parsimonyComparator)
      Initializes the value for the parsimonyComparator attribute.
      Parameters:
      parsimonyComparator - The value for parsimonyComparator
      Returns:
      this builder for use in a chained invocation
    • parsimonyTournamentSize

      public final ImmutableDoubleTournament.Builder<T> parsimonyTournamentSize(double parsimonyTournamentSize)
      Initializes the value for the parsimonyTournamentSize attribute.
      Parameters:
      parsimonyTournamentSize - The value for parsimonyTournamentSize
      Returns:
      this builder for use in a chained invocation
    • doFitnessFirst

      public final ImmutableDoubleTournament.Builder<T> doFitnessFirst(boolean doFitnessFirst)
      Initializes the value for the doFitnessFirst attribute.

      If not set, this attribute will have a default value as returned by the initializer of doFitnessFirst.

      Parameters:
      doFitnessFirst - The value for doFitnessFirst
      Returns:
      this builder for use in a chained invocation
    • build

      public ImmutableDoubleTournament<T> build()
      Returns:
      An immutable instance of DoubleTournament
      Throws:
      IllegalStateException - if any required attributes are missing
    • doFitnessFirstIsSet

      private boolean doFitnessFirstIsSet()
    • formatRequiredAttributesMessage

      private String formatRequiredAttributesMessage()