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().
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classImmutableDoubleTournament.Builder<T extends Comparable<T>>Builds instances of typeDoubleTournament. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate final Tournament<T> private final Comparator<Individual<T>> private final double -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableDoubleTournament(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize) privateImmutableDoubleTournament(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize, boolean doFitnessFirst) private -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
ImmutableDoubleTournament.Builder<T> builder()Creates a builder forDoubleTournament.static <T extends Comparable<T>>
DoubleTournament<T> copyOf(DoubleTournament<T> instance) Creates an immutable copy of aDoubleTournamentvalue.booleanDetermines the order of selection operations.booleanThis instance is equal to all instances ofImmutableDoubleTournamentthat have equal attribute values.private booleanequalsByValue(ImmutableDoubleTournament<?> another) The fitness tournament configuration used for selecting individuals based on fitness.inthashCode()Computes a hash code from attributes:fitnessTournament,parsimonyComparator,parsimonyTournamentSize,doFitnessFirst.static <T extends Comparable<T>>
DoubleTournament<T> of(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize) Construct a new immutableDoubleTournamentinstance.Comparator used to evaluate parsimony (complexity) between individuals.doubleControls the selection pressure toward less complex individuals in parsimony tournaments.toString()Prints the immutable valueDoubleTournamentwith attribute values.private static <T extends Comparable<T>>
ImmutableDoubleTournament<T> validate(ImmutableDoubleTournament<T> instance) final ImmutableDoubleTournament<T> withDoFitnessFirst(boolean value) Copy the current immutable object by setting a value for thedoFitnessFirstattribute.final ImmutableDoubleTournament<T> withFitnessTournament(Tournament<T> value) Copy the current immutable object by setting a value for thefitnessTournamentattribute.final ImmutableDoubleTournament<T> withParsimonyComparator(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for theparsimonyComparatorattribute.final ImmutableDoubleTournament<T> withParsimonyTournamentSize(double value) Copy the current immutable object by setting a value for theparsimonyTournamentSizeattribute.Methods inherited from class net.bmahe.genetics4j.gp.spec.selection.DoubleTournament
check
-
Field Details
-
fitnessTournament
-
parsimonyComparator
-
parsimonyTournamentSize
private final double parsimonyTournamentSize -
doFitnessFirst
private final boolean doFitnessFirst
-
-
Constructor Details
-
ImmutableDoubleTournament
private ImmutableDoubleTournament(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize) -
ImmutableDoubleTournament
-
ImmutableDoubleTournament
private ImmutableDoubleTournament(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize, boolean doFitnessFirst)
-
-
Method Details
-
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:
fitnessTournamentin classDoubleTournament<T extends Comparable<T>>- Returns:
- the tournament configuration for fitness-based selection
-
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:
parsimonyComparatorin classDoubleTournament<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:
parsimonyTournamentSizein classDoubleTournament<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 winnersfalse: Parsimony first mode - apply parsimony selection to random pairs first, then perform fitness tournament among parsimony winners
- Overrides:
doFitnessFirstin classDoubleTournament<T extends Comparable<T>>- Returns:
- true for fitness-first mode, false for parsimony-first mode
-
withFitnessTournament
Copy the current immutable object by setting a value for thefitnessTournamentattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for fitnessTournament- Returns:
- A modified copy or the
thisobject
-
withParsimonyComparator
Copy the current immutable object by setting a value for theparsimonyComparatorattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for parsimonyComparator- Returns:
- A modified copy or the
thisobject
-
withParsimonyTournamentSize
Copy the current immutable object by setting a value for theparsimonyTournamentSizeattribute. A value strict bits equality used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for parsimonyTournamentSize- Returns:
- A modified copy or the
thisobject
-
withDoFitnessFirst
Copy the current immutable object by setting a value for thedoFitnessFirstattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for doFitnessFirst- Returns:
- A modified copy or the
thisobject
-
equals
This instance is equal to all instances ofImmutableDoubleTournamentthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:fitnessTournament,parsimonyComparator,parsimonyTournamentSize,doFitnessFirst. -
toString
Prints the immutable valueDoubleTournamentwith attribute values. -
of
public static <T extends Comparable<T>> DoubleTournament<T> of(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize) Construct a new immutableDoubleTournamentinstance.- Type Parameters:
T- generic parameter T- Parameters:
fitnessTournament- The value for thefitnessTournamentattributeparsimonyComparator- The value for theparsimonyComparatorattributeparsimonyTournamentSize- The value for theparsimonyTournamentSizeattribute- Returns:
- An immutable DoubleTournament instance
-
validate
private static <T extends Comparable<T>> ImmutableDoubleTournament<T> validate(ImmutableDoubleTournament<T> instance) -
copyOf
Creates an immutable copy of aDoubleTournamentvalue. 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
Creates a builder forDoubleTournament.ImmutableDoubleTournament.<T>builder() .fitnessTournament(net.bmahe.genetics4j.core.spec.selection.Tournament<T>) // requiredfitnessTournament.parsimonyComparator(Comparator<net.bmahe.genetics4j.core.Individual<T>>) // requiredparsimonyComparator.parsimonyTournamentSize(double) // requiredparsimonyTournamentSize.doFitnessFirst(boolean) // optionaldoFitnessFirst.build();- Type Parameters:
T- generic parameter T- Returns:
- A new DoubleTournament builder
-