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(from="SPEA2Replacement",
generator="Immutables")
@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
Nested ClassesModifier and TypeClassDescriptionstatic classImmutableSPEA2Replacement.Builder<T extends Comparable<T>>Builds instances of typeSPEA2Replacement.private final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Comparator<Genotype> private final BiFunction<T, T, Double> private final Comparator<T> private ImmutableSPEA2Replacement<T>.InitShimprivate final Integerprivate static final byteprivate static final byteprivate static final byte -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableSPEA2Replacement(Comparator<T> dominance, Comparator<Genotype> deduplicate, Integer k, BiFunction<T, T, Double> distance) privateImmutableSPEA2Replacement(BiFunction<T, T, Double> distance) private -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
SPEA2Replacement<T> copyOf(SPEA2Replacement<T> instance) Creates an immutable copy of aSPEA2Replacementvalue.Comparator used for deduplication of solution prior to processingdistance()Define how to compute distances in objective space between two solutionsDefines the Pareto dominance relationbooleanThis instance is equal to all instances ofImmutableSPEA2Replacementthat have equal attribute values.private booleanequalsByValue(ImmutableSPEA2Replacement<?> another) inthashCode()Computes a hash code from attributes:dominance,deduplicate,k,distance.k()Determine the k-nearest distance to compute.static <T extends Comparable<T>>
SPEA2Replacement<T> of(BiFunction<T, T, Double> distance) Construct a new immutableSPEA2Replacementinstance.toString()Prints the immutable valueSPEA2Replacementwith attribute values.final ImmutableSPEA2Replacement<T> withDeduplicate(Comparator<Genotype> value) Copy the current immutable object by setting a present value for the optionaldeduplicateattribute.final ImmutableSPEA2Replacement<T> withDeduplicate(Optional<? extends Comparator<Genotype>> optional) Copy the current immutable object by setting an optional value for thededuplicateattribute.final ImmutableSPEA2Replacement<T> withDistance(BiFunction<T, T, Double> value) Copy the current immutable object by setting a value for thedistanceattribute.final ImmutableSPEA2Replacement<T> withDominance(Comparator<T> value) Copy the current immutable object by setting a value for thedominanceattribute.final ImmutableSPEA2Replacement<T> withK(int value) Copy the current immutable object by setting a present value for the optionalkattribute.final ImmutableSPEA2Replacement<T> Copy the current immutable object by setting an optional value for thekattribute.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, Comparator<Genotype> deduplicate, Integer k, BiFunction<T, T, Double> distance)
-
-
Method Details
-
dominance
Defines the Pareto dominance relation- Overrides:
dominancein 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:
deduplicatein classSPEA2Replacement<T extends Comparable<T>>- Returns:
-
k
Determine the k-nearest distance to compute.It will default to sqrt(|archive| + |population|)
- Overrides:
kin classSPEA2Replacement<T extends Comparable<T>>- Returns:
-
distance
Define how to compute distances in objective space between two solutions- Specified by:
distancein classSPEA2Replacement<T extends Comparable<T>>- Returns:
- Distance
-
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 ImmutableSPEA2Replacement<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
-
withK
Copy the current immutable object by setting a present value for the optionalkattribute.- Parameters:
value- The value for k- Returns:
- A modified copy or
thisif not changed
-
withK
Copy the current immutable object by setting an optional value for thekattribute. An equality check is used on inner value to prevent copying of the same value by returningthis.- Parameters:
optional- An optional value for k- Returns:
- A modified copy or
thisif not changed
-
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
-
equals
This instance is equal to all instances ofImmutableSPEA2Replacementthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:dominance,deduplicate,k,distance. -
toString
Prints the immutable valueSPEA2Replacementwith attribute values. -
of
Construct a new immutableSPEA2Replacementinstance.- Type Parameters:
T- generic parameter T- Parameters:
distance- The value for thedistanceattribute- Returns:
- An immutable SPEA2Replacement instance
-
copyOf
Creates an immutable copy of aSPEA2Replacementvalue. 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
-