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 class
Builds instances of typeSelectiveRefinementTournament
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Comparator
<Individual<T>> private final float
private final Tournament
<T> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ImmutableSelectiveRefinementTournament
(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 aSelectiveRefinementTournament
value.boolean
This instance is equal to all instances ofImmutableSelectiveRefinementTournament
that have equal attribute values.private boolean
equalsByValue
(ImmutableSelectiveRefinementTournament<?> another) int
hashCode()
Computes a hash code from attributes:tournament
,refinementComparator
,refinementRatio
.Gets the comparator used for refining the selection results.float
Gets the ratio of candidates that undergo refinement selection.toString()
Prints the immutable valueSelectiveRefinementTournament
with 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 therefinementComparator
attribute.withRefinementRatio
(float value) Copy the current immutable object by setting a value for therefinementRatio
attribute.withTournament
(Tournament<T> value) Copy the current immutable object by setting a value for thetournament
attribute.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:
tournament
in 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:
refinementComparator
in 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:
refinementRatio
in 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 thetournament
attribute. 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
this
object
-
withRefinementComparator
public final ImmutableSelectiveRefinementTournament<T> withRefinementComparator(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for therefinementComparator
attribute. 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
this
object
-
withRefinementRatio
Copy the current immutable object by setting a value for therefinementRatio
attribute. 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
this
object
-
equals
This instance is equal to all instances ofImmutableSelectiveRefinementTournament
that have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:tournament
,refinementComparator
,refinementRatio
. -
toString
Prints the immutable valueSelectiveRefinementTournament
with 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 aSelectiveRefinementTournament
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
-