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

  • Field Details

  • Constructor Details

  • Method Details

    • numberObjectives

      public int numberObjectives()
      Describe how many objectives are embedded in T
      Specified by:
      numberObjectives in class TournamentNSGA2Selection<T extends Comparable<T>>
      Returns:
      Number of objectives embedded in T
    • dominance

      public Comparator<T> dominance()
      Override the dominance operator.

      If not specified, it assumes the default comparator conforms to the Pareto dominance relation

      Overrides:
      dominance in class TournamentNSGA2Selection<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 TournamentNSGA2Selection<T extends Comparable<T>>
      Returns:
    • objectiveComparator

      public Function<Integer,Comparator<T>> objectiveComparator()
      Sort T based on the objective passed as a parameter
      Specified by:
      objectiveComparator in class TournamentNSGA2Selection<T extends Comparable<T>>
      Returns:
    • distance

      public ObjectiveDistance<T> distance()
      Define how to compute distances between fitness scores along their objectives
      Specified by:
      distance in class TournamentNSGA2Selection<T extends Comparable<T>>
      Returns:
      Distance computation method
    • numCandidates

      public int numCandidates()
      Number of candidates in each tournament
      Specified by:
      numCandidates in class TournamentNSGA2Selection<T extends Comparable<T>>
      Returns:
      Number of candidates in each tournament
    • withNumberObjectives

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

      public final ImmutableTournamentNSGA2Selection<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 ImmutableTournamentNSGA2Selection<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
    • withObjectiveComparator

      public final ImmutableTournamentNSGA2Selection<T> withObjectiveComparator(Function<Integer,Comparator<T>> value)
      Copy the current immutable object by setting a value for the objectiveComparator attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for objectiveComparator
      Returns:
      A modified copy of the this object
    • withDistance

      public final ImmutableTournamentNSGA2Selection<T> withDistance(ObjectiveDistance<T> 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
    • withNumCandidates

      public final ImmutableTournamentNSGA2Selection<T> withNumCandidates(int value)
      Copy the current immutable object by setting a value for the numCandidates attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for numCandidates
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableTournamentNSGA2Selection 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, ImmutableTournamentNSGA2Selection<?> another)
    • hashCode

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

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

      public static <T extends Comparable<T>> ImmutableTournamentNSGA2Selection<T> of(int numberObjectives, Function<Integer,Comparator<T>> objectiveComparator, ObjectiveDistance<T> distance, int numCandidates)
      Construct a new immutable TournamentNSGA2Selection instance.
      Type Parameters:
      T - generic parameter T
      Parameters:
      numberObjectives - The value for the numberObjectives attribute
      objectiveComparator - The value for the objectiveComparator attribute
      distance - The value for the distance attribute
      numCandidates - The value for the numCandidates attribute
      Returns:
      An immutable TournamentNSGA2Selection instance
    • copyOf

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