Class NondominatedPopulation

java.lang.Object
org.moeaframework.core.Population
org.moeaframework.core.NondominatedPopulation
All Implemented Interfaces:
Iterable<Solution>, Stateful, Displayable, Formattable<Solution>
Direct Known Subclasses:
AdaptiveGridArchive, EpsilonBoxDominanceArchive, FitnessBasedArchive

public class NondominatedPopulation extends Population
A population that maintains the property of pair-wise non-dominance between all solutions. When the add method is invoked with a new solution, all solutions currently in the population that are dominated by the new solution are removed. If the new solution is dominated by any member of the population, the new solution is not added.

Avoid modifying solutions contained in non-dominated populations. Since the dominance checks are only performed when adding solutions, modifying an existing solution can violating this contract.

  • Field Details

  • Constructor Details

    • NondominatedPopulation

      public NondominatedPopulation()
      Constructs an empty non-dominated population using the Pareto dominance relation.
    • NondominatedPopulation

      public NondominatedPopulation(NondominatedPopulation.DuplicateMode duplicateMode)
      Constructs an empty non-dominated population using the Pareto dominance relation.
      Parameters:
      duplicateMode - specifies how duplicate solutions are handled
    • NondominatedPopulation

      public NondominatedPopulation(DominanceComparator comparator)
      Constructs an empty non-dominated population using the specified dominance relation.
      Parameters:
      comparator - the dominance relation used by this non-dominated population
    • NondominatedPopulation

      public NondominatedPopulation(DominanceComparator comparator, NondominatedPopulation.DuplicateMode duplicateMode)
      Constructs an empty non-dominated population using the specified dominance relation.
      Parameters:
      comparator - the dominance relation used by this non-dominated population
      duplicateMode - specifies how duplicate solutions are handled
    • NondominatedPopulation

      public NondominatedPopulation(Iterable<? extends Solution> iterable)
      Constructs a non-dominated population using the Pareto dominance relation and initialized with the specified solutions.
      Parameters:
      iterable - the solutions used to initialize this non-dominated population
    • NondominatedPopulation

      public NondominatedPopulation(DominanceComparator comparator, Iterable<? extends Solution> iterable)
      Constructs a non-dominated population using the specified dominance comparator and initialized with the specified solutions.
      Parameters:
      comparator - the dominance relation used by this non-dominated population
      iterable - the solutions used to initialize this non-dominated population
  • Method Details

    • add

      public boolean add(Solution newSolution)
      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 Population
      Parameters:
      newSolution - the solution to be added
      Returns:
      true if the population was modified as a result of this method; false otherwise.
    • replace

      public void replace(int index, Solution newSolution)
      Replace is not supported with non-dominated populations. Calling this method will throw an exception.
      Overrides:
      replace in class Population
      Parameters:
      index - the index to replace
      newSolution - the new solution
      Throws:
      UnsupportedOperationException - if this method is called
    • forceAddWithoutCheck

      protected boolean forceAddWithoutCheck(Solution newSolution)
      Adds the specified solution to the population, bypassing the non-domination check. This method should only be used when a non-domination check has been performed elsewhere, such as in a subclass.

      This method should only be used internally, and should never be made public by any subclasses.

      Parameters:
      newSolution - the solution to be added
      Returns:
      true if the population was modified as a result of this operation
    • isDuplicate

      protected boolean isDuplicate(Solution s1, Solution s2)
      Returns true if the two solutions are duplicates and one should be ignored based on the duplicate mode. This default implementation depends on the Object.equals(Object) method of the Variable class to check for equality of the decision variables.
      Parameters:
      s1 - the first solution
      s2 - the second solution
      Returns:
      true if the solutions are duplicates; false otherwise
    • getComparator

      public DominanceComparator getComparator()
      Returns the dominance comparator used by this non-dominated population.
      Returns:
      the dominance comparator used by this non-dominated population
    • copy

      public NondominatedPopulation 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 Population
      Returns:
      the copy of this population
    • loadReferenceSet

      public static NondominatedPopulation loadReferenceSet(String resource) throws IOException
      Loads a reference set, which contains the objective values for a set of non-dominated solutions. Any dominated solutions are discarded.
      Parameters:
      resource - the path of the file or resource on the classpath
      Returns:
      the reference set, or null if the file or resource was not found
      Throws:
      IOException - if an I/O error occurred
    • loadReferenceSet

      public static NondominatedPopulation loadReferenceSet(File file) throws IOException
      Loads a reference set file, which contains the objective values for a set of non-dominated solutions. Any dominated solutions are discarded.
      Parameters:
      file - the file containing the reference set
      Returns:
      the reference set
      Throws:
      IOException - if an I/O error occurred or the file was not found