Class ImmutableSPEA2Replacement<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.moo.spea2.spec.replacement.SPEA2Replacement<T>
net.bmahe.genetics4j.moo.spea2.spec.replacement.ImmutableSPEA2Replacement<T>
- All Implemented Interfaces:
ReplacementStrategy
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableSPEA2Replacement<T extends Comparable<T>>
extends SPEA2Replacement<T>
Immutable implementation of
SPEA2Replacement
.
Use the builder to create immutable instances:
new SPEA2Replacement.Builder()
.
Use the static factory method to create immutable instances:
ImmutableSPEA2Replacement.of()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
ImmutableSPEA2Replacement.Builder<T extends Comparable<T>>
Builds instances of typeImmutableSPEA2Replacement
.private final class
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Optional
<Comparator<Genotype>> private final BiFunction
<T, T, Double> private final Comparator
<T> private ImmutableSPEA2Replacement<T>.InitShim
private static final byte
private static final byte
private static final byte
-
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableSPEA2Replacement
(Comparator<T> dominance, Optional<Comparator<Genotype>> deduplicate, Optional<Integer> k, BiFunction<T, T, Double> distance) private
ImmutableSPEA2Replacement
(BiFunction<T, T, Double> distance) private
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
ImmutableSPEA2Replacement<T> copyOf
(SPEA2Replacement<T> instance) Creates an immutable copy of aSPEA2Replacement
value.Comparator used for deduplication of solution prior to processingdistance()
Define how to compute distances in objective space between two solutionsDefines the Pareto dominance relationboolean
This instance is equal to all instances ofImmutableSPEA2Replacement
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableSPEA2Replacement<?> another) int
hashCode()
Computes a hash code from attributes:dominance
,deduplicate
,k
,distance
.k()
Determine the k-nearest distance to compute.static <T extends Comparable<T>>
ImmutableSPEA2Replacement<T> of
(BiFunction<T, T, Double> distance) Construct a new immutableSPEA2Replacement
instance.toString()
Prints the immutable valueSPEA2Replacement
with attribute values.final ImmutableSPEA2Replacement
<T> withDeduplicate
(Optional<Comparator<Genotype>> value) Copy the current immutable object by setting a value for thededuplicate
attribute.final ImmutableSPEA2Replacement
<T> withDistance
(BiFunction<T, T, Double> value) Copy the current immutable object by setting a value for thedistance
attribute.final ImmutableSPEA2Replacement
<T> withDominance
(Comparator<T> value) Copy the current immutable object by setting a value for thedominance
attribute.final ImmutableSPEA2Replacement
<T> Copy the current immutable object by setting a value for thek
attribute.Methods inherited from class net.bmahe.genetics4j.moo.spea2.spec.replacement.SPEA2Replacement
builder, ofFitnessVector, ofFitnessVector
-
Field Details
-
dominance
-
deduplicate
-
k
-
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
-
ImmutableSPEA2Replacement
-
ImmutableSPEA2Replacement
-
ImmutableSPEA2Replacement
private ImmutableSPEA2Replacement(Comparator<T> dominance, Optional<Comparator<Genotype>> deduplicate, Optional<Integer> k, BiFunction<T, T, Double> distance)
-
-
Method Details
-
dominance
Defines the Pareto dominance relation- Overrides:
dominance
in classSPEA2Replacement<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 classSPEA2Replacement<T extends Comparable<T>>
- Returns:
-
k
Determine the k-nearest distance to compute.It will default to sqrt(|archive| + |population|)
- Overrides:
k
in classSPEA2Replacement<T extends Comparable<T>>
- Returns:
-
distance
Define how to compute distances in objective space between two solutions- Specified by:
distance
in classSPEA2Replacement<T extends Comparable<T>>
- Returns:
- Distance
-
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
-
withK
Copy the current immutable object by setting a value for thek
attribute. An equals check used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for k- 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 ofImmutableSPEA2Replacement
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:dominance
,deduplicate
,k
,distance
. -
toString
Prints the immutable valueSPEA2Replacement
with attribute values. -
of
public static <T extends Comparable<T>> ImmutableSPEA2Replacement<T> of(BiFunction<T, T, Double> distance) Construct a new immutableSPEA2Replacement
instance.- Type Parameters:
T
- generic parameter T- Parameters:
distance
- The value for thedistance
attribute- Returns:
- An immutable SPEA2Replacement instance
-
copyOf
public static <T extends Comparable<T>> ImmutableSPEA2Replacement<T> copyOf(SPEA2Replacement<T> instance) Creates an immutable copy of aSPEA2Replacement
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 SPEA2Replacement instance
-