Package org.moeaframework.core
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
A population that maintains the property of pairwise nondominance 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 nondominated populations. Since the dominance checks are only performed when adding solutions, modifying an existing solution can violating this contract.

Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Specifies how duplicate solutions are handled. 
Field Summary
Modifier and TypeFieldDescriptionprotected final DominanceComparator
The dominance comparator used by this nondominated population.protected final NondominatedPopulation.DuplicateMode
Specifies how duplicate solutions are handled. 
Constructor Summary
ConstructorDescriptionConstructs an empty nondominated population using the Pareto dominance relation.NondominatedPopulation
(Iterable<? extends Solution> iterable) Constructs a nondominated population using the Pareto dominance relation and initialized with the specified solutions.NondominatedPopulation
(DominanceComparator comparator) Constructs an empty nondominated population using the specified dominance relation.NondominatedPopulation
(DominanceComparator comparator, Iterable<? extends Solution> iterable) Constructs a nondominated population using the specified dominance comparator and initialized with the specified solutions.NondominatedPopulation
(DominanceComparator comparator, NondominatedPopulation.DuplicateMode duplicateMode) Constructs an empty nondominated population using the specified dominance relation.NondominatedPopulation
(NondominatedPopulation.DuplicateMode duplicateMode) Constructs an empty nondominated population using the Pareto dominance relation. 
Method Summary
Modifier and TypeMethodDescriptionboolean
IfnewSolution
is dominates any solution or is nondominated with all solutions in this population, the dominated solutions are removed andnewSolution
is added to this population.copy()
Returns a copy of this population.protected boolean
forceAddWithoutCheck
(Solution newSolution) Adds the specified solution to the population, bypassing the nondomination check.Returns the dominance comparator used by this nondominated population.protected boolean
isDuplicate
(Solution s1, Solution s2) Returnstrue
if the two solutions are duplicates and one should be ignored based on the duplicate mode.static NondominatedPopulation
loadReferenceSet
(File file) Loads a reference set file, which contains the objective values for a set of nondominated solutions.static NondominatedPopulation
loadReferenceSet
(String resource) Loads a reference set, which contains the objective values for a set of nondominated solutions.void
Replace is not supported with nondominated populations.Methods inherited from class org.moeaframework.core.Population
addAll, addAll, asList, asTabularData, clear, contains, containsAll, containsAll, filter, get, getLowerBounds, getUpperBounds, indexOf, isEmpty, iterator, loadBinary, loadBinary, loadObjectives, loadObjectives, loadState, remove, remove, removeAll, removeAll, removeAll, saveBinary, saveBinary, saveObjectives, saveObjectives, saveState, size, sort, truncate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.moeaframework.util.format.Displayable
display
Methods inherited from interface org.moeaframework.util.format.Formattable
display, display, display, save, saveCSV
Methods inherited from interface java.lang.Iterable
forEach, spliterator

Field Details

comparator
The dominance comparator used by this nondominated population. 
duplicateMode
Specifies how duplicate solutions are handled.


Constructor Details

NondominatedPopulation
public NondominatedPopulation()Constructs an empty nondominated population using the Pareto dominance relation. 
NondominatedPopulation
Constructs an empty nondominated population using the Pareto dominance relation. Parameters:
duplicateMode
 specifies how duplicate solutions are handled

NondominatedPopulation
Constructs an empty nondominated population using the specified dominance relation. Parameters:
comparator
 the dominance relation used by this nondominated population

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

NondominatedPopulation
Constructs a nondominated population using the Pareto dominance relation and initialized with the specified solutions. Parameters:
iterable
 the solutions used to initialize this nondominated population

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


Method Details

add
IfnewSolution
is dominates any solution or is nondominated with all solutions in this population, the dominated solutions are removed andnewSolution
is added to this population. Otherwise,newSolution
is dominated and is not added to this population. Overrides:
add
in classPopulation
 Parameters:
newSolution
 the solution to be added Returns:
true
if the population was modified as a result of this method;false
otherwise.

replace
Replace is not supported with nondominated populations. Calling this method will throw an exception. Overrides:
replace
in classPopulation
 Parameters:
index
 the index to replacenewSolution
 the new solution Throws:
UnsupportedOperationException
 if this method is called

forceAddWithoutCheck
Adds the specified solution to the population, bypassing the nondomination check. This method should only be used when a nondomination 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
Returnstrue
if the two solutions are duplicates and one should be ignored based on the duplicate mode. This default implementation depends on theObject.equals(Object)
method of theVariable
class to check for equality of the decision variables. Parameters:
s1
 the first solutions2
 the second solution Returns:
true
if the solutions are duplicates;false
otherwise

getComparator
Returns the dominance comparator used by this nondominated population. Returns:
 the dominance comparator used by this nondominated population

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)
orPopulation.addAll(Iterable)
whenever possible. These alternatives are useful when filtering or reordering the solutions, but the solutions themselves are left unchanged. Overrides:
copy
in classPopulation
 Returns:
 the copy of this population

loadReferenceSet
Loads a reference set, which contains the objective values for a set of nondominated 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
Loads a reference set file, which contains the objective values for a set of nondominated 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
