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().

  • Field Details

  • Constructor Details

  • Method Details

    • dominance

      public Comparator<T> dominance()
      Defines the Pareto dominance relation
      Overrides:
      dominance in class SPEA2Replacement<T extends Comparable<T>>
      Returns:
    • deduplicate

      public Optional<Comparator<Genotype>> deduplicate()
      Comparator used for deduplication of solution prior to processing

      If not specified, it defaults to not do any deduplication

      Overrides:
      deduplicate in class SPEA2Replacement<T extends Comparable<T>>
      Returns:
    • k

      public Optional<Integer> k()
      Determine the k-nearest distance to compute.

      It will default to sqrt(|archive| + |population|)

      Overrides:
      k in class SPEA2Replacement<T extends Comparable<T>>
      Returns:
    • distance

      public BiFunction<T,T,Double> distance()
      Define how to compute distances in objective space between two solutions
      Specified by:
      distance in class SPEA2Replacement<T extends Comparable<T>>
      Returns:
      Distance
    • withDominance

      public final ImmutableSPEA2Replacement<T> withDominance(Comparator<T> value)
      Copy the current immutable object by setting a value for the dominance attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for dominance
      Returns:
      A modified copy of the this object
    • withDeduplicate

      public final ImmutableSPEA2Replacement<T> withDeduplicate(Optional<Comparator<Genotype>> value)
      Copy the current immutable object by setting a value for the deduplicate attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for deduplicate
      Returns:
      A modified copy of the this object
    • withK

      public final ImmutableSPEA2Replacement<T> withK(Optional<Integer> value)
      Copy the current immutable object by setting a value for the k attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for k
      Returns:
      A modified copy of the this object
    • withDistance

      public final ImmutableSPEA2Replacement<T> withDistance(BiFunction<T,T,Double> value)
      Copy the current immutable object by setting a value for the distance attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for distance
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableSPEA2Replacement that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • equalTo

      private boolean equalTo(int synthetic, ImmutableSPEA2Replacement<?> another)
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: dominance, deduplicate, k, distance.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value SPEA2Replacement with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • of

      public static <T extends Comparable<T>> ImmutableSPEA2Replacement<T> of(BiFunction<T,T,Double> distance)
      Construct a new immutable SPEA2Replacement instance.
      Type Parameters:
      T - generic parameter T
      Parameters:
      distance - The value for the distance attribute
      Returns:
      An immutable SPEA2Replacement instance
    • copyOf

      public static <T extends Comparable<T>> ImmutableSPEA2Replacement<T> copyOf(SPEA2Replacement<T> instance)
      Creates an immutable copy of a SPEA2Replacement 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