Class ImmutableNSGA2Selection<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.moo.nsga2.spec.NSGA2Selection<T>
net.bmahe.genetics4j.moo.nsga2.spec.ImmutableNSGA2Selection<T>
- All Implemented Interfaces:
SelectionPolicy
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableNSGA2Selection<T extends Comparable<T>>
extends NSGA2Selection<T>
Immutable implementation of
NSGA2Selection
.
Use the builder to create immutable instances:
new NSGA2Selection.Builder()
.
Use the static factory method to create immutable instances:
ImmutableNSGA2Selection.of()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
ImmutableNSGA2Selection.Builder<T extends Comparable<T>>
Builds instances of typeImmutableNSGA2Selection
.private final class
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Optional
<Comparator<Genotype>> private final ObjectiveDistance
<T> private final Comparator
<T> private ImmutableNSGA2Selection<T>.InitShim
private final int
private final Function
<Integer, Comparator<T>> private static final byte
private static final byte
private static final byte
-
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableNSGA2Selection
(int numberObjectives, Comparator<T> dominance, Optional<Comparator<Genotype>> deduplicate, Function<Integer, Comparator<T>> objectiveComparator, ObjectiveDistance<T> distance) private
ImmutableNSGA2Selection
(int numberObjectives, Function<Integer, Comparator<T>> objectiveComparator, ObjectiveDistance<T> distance) private
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
ImmutableNSGA2Selection<T> copyOf
(NSGA2Selection<T> instance) Creates an immutable copy of aNSGA2Selection
value.Comparator used for deduplication of solution prior to processingdistance()
Define how to compute distances between fitness scores along their objectivesOverride the dominance operator.boolean
This instance is equal to all instances ofImmutableNSGA2Selection
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableNSGA2Selection<?> another) int
hashCode()
Computes a hash code from attributes:numberObjectives
,dominance
,deduplicate
,objectiveComparator
,distance
.int
Number of objectivesSort T based on the objective passed as a parameterstatic <T extends Comparable<T>>
ImmutableNSGA2Selection<T> of
(int numberObjectives, Function<Integer, Comparator<T>> objectiveComparator, ObjectiveDistance<T> distance) Construct a new immutableNSGA2Selection
instance.toString()
Prints the immutable valueNSGA2Selection
with attribute values.final ImmutableNSGA2Selection
<T> withDeduplicate
(Optional<Comparator<Genotype>> value) Copy the current immutable object by setting a value for thededuplicate
attribute.final ImmutableNSGA2Selection
<T> withDistance
(ObjectiveDistance<T> value) Copy the current immutable object by setting a value for thedistance
attribute.final ImmutableNSGA2Selection
<T> withDominance
(Comparator<T> value) Copy the current immutable object by setting a value for thedominance
attribute.final ImmutableNSGA2Selection
<T> withNumberObjectives
(int value) Copy the current immutable object by setting a value for thenumberObjectives
attribute.final ImmutableNSGA2Selection
<T> withObjectiveComparator
(Function<Integer, Comparator<T>> value) Copy the current immutable object by setting a value for theobjectiveComparator
attribute.Methods inherited from class net.bmahe.genetics4j.moo.nsga2.spec.NSGA2Selection
builder, ofFitnessVector, ofFitnessVector
-
Field Details
-
numberObjectives
private final int numberObjectives -
dominance
-
deduplicate
-
objectiveComparator
-
distance
-
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
-
-
Constructor Details
-
ImmutableNSGA2Selection
private ImmutableNSGA2Selection(int numberObjectives, Function<Integer, Comparator<T>> objectiveComparator, ObjectiveDistance<T> distance) -
ImmutableNSGA2Selection
-
ImmutableNSGA2Selection
private ImmutableNSGA2Selection(int numberObjectives, Comparator<T> dominance, Optional<Comparator<Genotype>> deduplicate, Function<Integer, Comparator<T>> objectiveComparator, ObjectiveDistance<T> distance)
-
-
Method Details
-
numberObjectives
public int numberObjectives()Number of objectives- Specified by:
numberObjectives
in classNSGA2Selection<T extends Comparable<T>>
- Returns:
-
dominance
Override the dominance operator.If not specified, it assumes the default comparator conforms to the Pareto dominance relation
- Overrides:
dominance
in classNSGA2Selection<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:
deduplicate
in classNSGA2Selection<T extends Comparable<T>>
- Returns:
-
objectiveComparator
Sort T based on the objective passed as a parameter- Specified by:
objectiveComparator
in classNSGA2Selection<T extends Comparable<T>>
- Returns:
-
distance
Define how to compute distances between fitness scores along their objectives- Specified by:
distance
in classNSGA2Selection<T extends Comparable<T>>
- Returns:
- Distance computation method
-
withNumberObjectives
Copy the current immutable object by setting a value for thenumberObjectives
attribute. 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 of the
this
object
-
withDominance
Copy the current immutable object by setting a value for thedominance
attribute. 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 of the
this
object
-
withDeduplicate
Copy the current immutable object by setting a value for thededuplicate
attribute. An equals check used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for deduplicate- Returns:
- A modified copy of the
this
object
-
withObjectiveComparator
public final ImmutableNSGA2Selection<T> withObjectiveComparator(Function<Integer, Comparator<T>> value) Copy the current immutable object by setting a value for theobjectiveComparator
attribute. 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 of the
this
object
-
withDistance
Copy the current immutable object by setting a value for thedistance
attribute. 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 of the
this
object
-
equals
This instance is equal to all instances ofImmutableNSGA2Selection
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:numberObjectives
,dominance
,deduplicate
,objectiveComparator
,distance
. -
toString
Prints the immutable valueNSGA2Selection
with attribute values. -
of
public static <T extends Comparable<T>> ImmutableNSGA2Selection<T> of(int numberObjectives, Function<Integer, Comparator<T>> objectiveComparator, ObjectiveDistance<T> distance) Construct a new immutableNSGA2Selection
instance.- Type Parameters:
T
- generic parameter T- Parameters:
numberObjectives
- The value for thenumberObjectives
attributeobjectiveComparator
- The value for theobjectiveComparator
attributedistance
- The value for thedistance
attribute- Returns:
- An immutable NSGA2Selection instance
-
copyOf
public static <T extends Comparable<T>> ImmutableNSGA2Selection<T> copyOf(NSGA2Selection<T> instance) Creates an immutable copy of aNSGA2Selection
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 NSGA2Selection instance
-