Class FitnessBasedArchive

All Implemented Interfaces:
Iterable<Solution>, Stateful, Displayable, Formattable<Solution>

public class FitnessBasedArchive extends NondominatedPopulation
Maintains a non-dominated archive of solutions with a maximum capacity. If the size exceeds the capacity, one or more solutions are pruned based on the fitness calculation. The fitness calculation only occurs when the addition of a solution exceeds the capacity. The fitness can be manually calculated by calling update().
  • Field Details

    • capacity

      protected final int capacity
      The maximum capacity of this archive.
    • fitnessEvaluator

      protected final FitnessEvaluator fitnessEvaluator
      The fitness evaluator for computing the fitness of solutions.
    • fitnessComparator

      protected final FitnessComparator fitnessComparator
      The fitness comparator for comparing fitness values.
  • Constructor Details

    • FitnessBasedArchive

      public FitnessBasedArchive(FitnessEvaluator evaluator, int capacity)
      Constructs an empty fitness-based archive.
      Parameters:
      evaluator - the fitness evaluator for computing the fitness of solutions
      capacity - the maximum capacity of this archive
    • FitnessBasedArchive

      public FitnessBasedArchive(FitnessEvaluator evaluator, int capacity, DominanceComparator comparator)
      Constructs an empty fitness-based archive.
      Parameters:
      evaluator - the fitness evaluator for computing the fitness of solutions
      capacity - the maximum capacity of this archive
      comparator - the dominance comparator
    • FitnessBasedArchive

      public FitnessBasedArchive(FitnessEvaluator evaluator, int capacity, DominanceComparator comparator, Iterable<? extends Solution> iterable)
      Constructs a fitness-based archive initialized with the specified solutions.
      Parameters:
      evaluator - the fitness evaluator for computing the fitness of solutions
      capacity - the maximum capacity of this archive
      comparator - the dominance comparator
      iterable - the solutions used to initialize this population
    • FitnessBasedArchive

      public FitnessBasedArchive(FitnessEvaluator evaluator, int capacity, Iterable<? extends Solution> iterable)
      Constructs a fitness-based archive initialized with the specified solutions.
      Parameters:
      evaluator - the fitness evaluator for computing the fitness of solutions
      capacity - the maximum capacity of this archive
      iterable - the solutions used to initialize this population
  • Method Details

    • getCapacity

      public int getCapacity()
      Returns the maximum number of solutions stored in this archive.
      Returns:
      the maximum number of solutions stored in this archive
    • add

      public boolean add(Solution solution)
      Description copied from class: NondominatedPopulation
      If newSolution is dominates any solution or is non-dominated with all solutions in this population, the dominated solutions are removed and newSolution is added to this population. Otherwise, newSolution is dominated and is not added to this population.
      Overrides:
      add in class NondominatedPopulation
      Parameters:
      solution - the solution to be added
      Returns:
      true if the population was modified as a result of this method; false otherwise.
    • update

      public void update()
      Updates the fitness of all solutions in this population.
    • copy

      public FitnessBasedArchive copy()
      Description copied from class: Population
      Returns a copy of this population. This can be thought of as a "deep copy", which creates a copy of both the population itself and copies of the individual solutions in the population. Consequently, the returned copy is completely independent, such that any modifications to the contents or order will not impact the original.

      Since creating such a "deep copy" can be expensive, prefer using the constructor Population(Iterable) or Population.addAll(Iterable) whenever possible. These alternatives are useful when filtering or reordering the solutions, but the solutions themselves are left unchanged.

      Overrides:
      copy in class NondominatedPopulation
      Returns:
      the copy of this population