Class ImmutableTournamentNSGA2Selection<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.moo.nsga2.spec.TournamentNSGA2Selection<T>
net.bmahe.genetics4j.moo.nsga2.spec.ImmutableTournamentNSGA2Selection<T>
- All Implemented Interfaces:
SelectionPolicy
@Generated(from="TournamentNSGA2Selection",
generator="Immutables")
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableTournamentNSGA2Selection<T extends Comparable<T>>
extends TournamentNSGA2Selection<T>
Immutable implementation of
TournamentNSGA2Selection.
Use the builder to create immutable instances:
new TournamentNSGA2Selection.Builder().
Use the static factory method to create immutable instances:
ImmutableTournamentNSGA2Selection.of().
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilds instances of typeTournamentNSGA2Selection.private final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Comparator<Genotype> private final ObjectiveDistance<T> private final Comparator<T> private ImmutableTournamentNSGA2Selection<T>.InitShimprivate final intprivate final intprivate final Function<Integer, Comparator<T>> private static final byteprivate static final byteprivate static final byte -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableTournamentNSGA2Selection(int numberObjectives, Comparator<T> dominance, Comparator<Genotype> deduplicate, Function<Integer, Comparator<T>> objectiveComparator, ObjectiveDistance<T> distance, int numCandidates) privateImmutableTournamentNSGA2Selection(int numberObjectives, Function<Integer, Comparator<T>> objectiveComparator, ObjectiveDistance<T> distance, int numCandidates) private -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
TournamentNSGA2Selection<T> copyOf(TournamentNSGA2Selection<T> instance) Creates an immutable copy of aTournamentNSGA2Selectionvalue.Comparator used for deduplication of solution prior to processingdistance()Define how to compute distances between fitness scores along their objectivesOverride the dominance operator.booleanThis instance is equal to all instances ofImmutableTournamentNSGA2Selectionthat have equal attribute values.private booleanequalsByValue(ImmutableTournamentNSGA2Selection<?> another) inthashCode()Computes a hash code from attributes:numberObjectives,dominance,deduplicate,objectiveComparator,distance,numCandidates.intDescribe how many objectives are embedded in TintNumber of candidates in each tournamentSort T based on the objective passed as a parameterstatic <T extends Comparable<T>>
TournamentNSGA2Selection<T> of(int numberObjectives, Function<Integer, Comparator<T>> objectiveComparator, ObjectiveDistance<T> distance, int numCandidates) Construct a new immutableTournamentNSGA2Selectioninstance.toString()Prints the immutable valueTournamentNSGA2Selectionwith attribute values.withDeduplicate(Comparator<Genotype> value) Copy the current immutable object by setting a present value for the optionaldeduplicateattribute.withDeduplicate(Optional<? extends Comparator<Genotype>> optional) Copy the current immutable object by setting an optional value for thededuplicateattribute.withDistance(ObjectiveDistance<T> value) Copy the current immutable object by setting a value for thedistanceattribute.withDominance(Comparator<T> value) Copy the current immutable object by setting a value for thedominanceattribute.withNumberObjectives(int value) Copy the current immutable object by setting a value for thenumberObjectivesattribute.withNumCandidates(int value) Copy the current immutable object by setting a value for thenumCandidatesattribute.withObjectiveComparator(Function<Integer, Comparator<T>> value) Copy the current immutable object by setting a value for theobjectiveComparatorattribute.Methods inherited from class net.bmahe.genetics4j.moo.nsga2.spec.TournamentNSGA2Selection
builder, ofFitnessVector, ofFitnessVector
-
Field Details
-
numberObjectives
private final int numberObjectives -
dominance
-
deduplicate
-
objectiveComparator
-
distance
-
numCandidates
private final int numCandidates -
STAGE_INITIALIZING
private static final byte STAGE_INITIALIZING- See Also:
-
STAGE_UNINITIALIZED
private static final byte STAGE_UNINITIALIZED- See Also:
-
STAGE_INITIALIZED
private static final byte STAGE_INITIALIZED- See Also:
-
initShim
private transient volatile ImmutableTournamentNSGA2Selection<T extends Comparable<T>>.InitShim initShim
-
-
Constructor Details
-
ImmutableTournamentNSGA2Selection
private ImmutableTournamentNSGA2Selection(int numberObjectives, Function<Integer, Comparator<T>> objectiveComparator, ObjectiveDistance<T> distance, int numCandidates) -
ImmutableTournamentNSGA2Selection
-
ImmutableTournamentNSGA2Selection
private ImmutableTournamentNSGA2Selection(int numberObjectives, Comparator<T> dominance, Comparator<Genotype> deduplicate, Function<Integer, Comparator<T>> objectiveComparator, ObjectiveDistance<T> distance, int numCandidates)
-
-
Method Details
-
numberObjectives
public int numberObjectives()Describe how many objectives are embedded in T- Specified by:
numberObjectivesin classTournamentNSGA2Selection<T extends Comparable<T>>- Returns:
- Number of objectives embedded in T
-
dominance
Override the dominance operator.If not specified, it assumes the default comparator conforms to the Pareto dominance relation
- Overrides:
dominancein classTournamentNSGA2Selection<T extends Comparable<T>>- Returns:
-
deduplicate
Comparator used for deduplication of solution prior to processingIf not specified, it defaults to not do any deduplication
- Overrides:
deduplicatein classTournamentNSGA2Selection<T extends Comparable<T>>- Returns:
-
objectiveComparator
Sort T based on the objective passed as a parameter- Specified by:
objectiveComparatorin classTournamentNSGA2Selection<T extends Comparable<T>>- Returns:
-
distance
Define how to compute distances between fitness scores along their objectives- Specified by:
distancein classTournamentNSGA2Selection<T extends Comparable<T>>- Returns:
- Distance computation method
-
numCandidates
public int numCandidates()Number of candidates in each tournament- Specified by:
numCandidatesin classTournamentNSGA2Selection<T extends Comparable<T>>- Returns:
- Number of candidates in each tournament
-
withNumberObjectives
Copy the current immutable object by setting a value for thenumberObjectivesattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for numberObjectives- Returns:
- A modified copy or the
thisobject
-
withDominance
Copy the current immutable object by setting a value for thedominanceattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for dominance- Returns:
- A modified copy or the
thisobject
-
withDeduplicate
Copy the current immutable object by setting a present value for the optionaldeduplicateattribute.- Parameters:
value- The value for deduplicate- Returns:
- A modified copy or
thisif not changed
-
withDeduplicate
public final ImmutableTournamentNSGA2Selection<T> withDeduplicate(Optional<? extends Comparator<Genotype>> optional) Copy the current immutable object by setting an optional value for thededuplicateattribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis.- Parameters:
optional- An optional value for deduplicate- Returns:
- A modified copy or
thisif not changed
-
withObjectiveComparator
public final ImmutableTournamentNSGA2Selection<T> withObjectiveComparator(Function<Integer, Comparator<T>> value) Copy the current immutable object by setting a value for theobjectiveComparatorattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for objectiveComparator- Returns:
- A modified copy or the
thisobject
-
withDistance
Copy the current immutable object by setting a value for thedistanceattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for distance- Returns:
- A modified copy or the
thisobject
-
withNumCandidates
Copy the current immutable object by setting a value for thenumCandidatesattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for numCandidates- Returns:
- A modified copy or the
thisobject
-
equals
This instance is equal to all instances ofImmutableTournamentNSGA2Selectionthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:numberObjectives,dominance,deduplicate,objectiveComparator,distance,numCandidates. -
toString
Prints the immutable valueTournamentNSGA2Selectionwith attribute values. -
of
public static <T extends Comparable<T>> TournamentNSGA2Selection<T> of(int numberObjectives, Function<Integer, Comparator<T>> objectiveComparator, ObjectiveDistance<T> distance, int numCandidates) Construct a new immutableTournamentNSGA2Selectioninstance.- Type Parameters:
T- generic parameter T- Parameters:
numberObjectives- The value for thenumberObjectivesattributeobjectiveComparator- The value for theobjectiveComparatorattributedistance- The value for thedistanceattributenumCandidates- The value for thenumCandidatesattribute- Returns:
- An immutable TournamentNSGA2Selection instance
-
copyOf
public static <T extends Comparable<T>> TournamentNSGA2Selection<T> copyOf(TournamentNSGA2Selection<T> instance) Creates an immutable copy of aTournamentNSGA2Selectionvalue. 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 TournamentNSGA2Selection instance
-