Class ImmutableSelectiveRefinementTournament<T extends Comparable<T>>
- All Implemented Interfaces:
SelectionPolicy
SelectiveRefinementTournament.
Use the builder to create immutable instances:
new SelectiveRefinementTournament.Builder().
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilds instances of typeSelectiveRefinementTournament. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Comparator<Individual<T>> private final floatprivate final Tournament<T> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableSelectiveRefinementTournament(Tournament<T> tournament, Comparator<Individual<T>> refinementComparator, float refinementRatio) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
SelectiveRefinementTournament<T> copyOf(SelectiveRefinementTournament<T> instance) Creates an immutable copy of aSelectiveRefinementTournamentvalue.booleanThis instance is equal to all instances ofImmutableSelectiveRefinementTournamentthat have equal attribute values.private booleanequalsByValue(ImmutableSelectiveRefinementTournament<?> another) inthashCode()Computes a hash code from attributes:tournament,refinementComparator,refinementRatio.Gets the comparator used for refining the selection results.floatGets the ratio of candidates that undergo refinement selection.toString()Prints the immutable valueSelectiveRefinementTournamentwith attribute values.Gets the base tournament configuration used for initial selection.private static <T extends Comparable<T>>
ImmutableSelectiveRefinementTournament<T> validate(ImmutableSelectiveRefinementTournament<T> instance) withRefinementComparator(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for therefinementComparatorattribute.withRefinementRatio(float value) Copy the current immutable object by setting a value for therefinementRatioattribute.withTournament(Tournament<T> value) Copy the current immutable object by setting a value for thetournamentattribute.Methods inherited from class net.bmahe.genetics4j.core.spec.selection.SelectiveRefinementTournament
builder, check
-
Field Details
-
tournament
-
refinementComparator
-
refinementRatio
private final float refinementRatio
-
-
Constructor Details
-
ImmutableSelectiveRefinementTournament
private ImmutableSelectiveRefinementTournament(Tournament<T> tournament, Comparator<Individual<T>> refinementComparator, float refinementRatio)
-
-
Method Details
-
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:
tournamentin classSelectiveRefinementTournament<T extends Comparable<T>>- Returns:
- the tournament configuration for initial selection
-
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:
refinementComparatorin classSelectiveRefinementTournament<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:
refinementRatioin classSelectiveRefinementTournament<T extends Comparable<T>>- Returns:
- the refinement ratio, must be between 0.0 and 1.0 inclusive
-
withTournament
Copy the current immutable object by setting a value for thetournamentattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for tournament- Returns:
- A modified copy or the
thisobject
-
withRefinementComparator
public final ImmutableSelectiveRefinementTournament<T> withRefinementComparator(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for therefinementComparatorattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for refinementComparator- Returns:
- A modified copy or the
thisobject
-
withRefinementRatio
Copy the current immutable object by setting a value for therefinementRatioattribute. A value strict bits equality used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for refinementRatio- Returns:
- A modified copy or the
thisobject
-
equals
This instance is equal to all instances ofImmutableSelectiveRefinementTournamentthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:tournament,refinementComparator,refinementRatio. -
toString
Prints the immutable valueSelectiveRefinementTournamentwith attribute values. -
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 aSelectiveRefinementTournamentvalue. 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
-