public final class ParetoFront<T> extends AbstractSet<T>
Set
, it only contains no
duplicate entries. Unlike the usual set implementation, the iteration order
is deterministic.
You can create a new ParetoFront
for Vec
objects
final ParetoFront<Vec<double[]>> front = new ParetoFront<>(Vec::dominance);
front.add(Vec.of(1.0, 2.0));
front.add(Vec.of(1.1, 2.5));
front.add(Vec.of(0.9, 2.1));
front.add(Vec.of(0.0, 2.9));
double[]
array objects
final ParetoFront<double[]> front = new ParetoFront<>(Pareto::dominance);
front.add(new double[]{1.0, 2.0});
front.add(new double[]{1.1, 2.5});
front.add(new double[]{0.9, 2.1});
front.add(new double[]{0.0, 2.9});
Pareto
O(n)
.Constructor and Description |
---|
ParetoFront(Comparator<? super T> dominance)
Create a new
ParetoSet with the given dominance measure. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(T element)
Inserts an
element to this pareto front. |
boolean |
addAll(Collection<? extends T> elements) |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
ParetoFront<T> |
merge(ParetoFront<? extends T> elements)
Add the all
elements to this pareto-set. |
int |
size() |
ISeq<T> |
toISeq()
Return the elements of
this pareto-front as ISeq . |
static <C extends Comparable<? super C>> |
toParetoFront()
Return a pareto-front collector.
|
static <T> Collector<T,?,ParetoFront<T>> |
toParetoFront(Comparator<? super T> dominance)
Return a pareto-front collector with the given pareto
dominance
measure. |
ParetoFront<T> |
trim(int size,
ElementComparator<? super T> comparator,
ElementDistance<? super T> distance,
ToIntFunction<? super T> dimension)
Trims
this pareto front to the given size. |
equals, hashCode, removeAll
clear, contains, containsAll, remove, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
clear, contains, containsAll, remove, retainAll, spliterator, toArray, toArray
parallelStream, removeIf, stream
public ParetoFront(Comparator<? super T> dominance)
ParetoSet
with the given dominance
measure.dominance
- the Pareto dominance measureNullPointerException
- if the given dominance
measure is
null
public boolean add(T element)
element
to this pareto front.add
in interface Collection<T>
add
in interface Set<T>
add
in class AbstractCollection<T>
element
- the element to addtrue
if this set did not already contain the specified
elementO(n)
.public boolean addAll(Collection<? extends T> elements)
addAll
in interface Collection<T>
addAll
in interface Set<T>
addAll
in class AbstractCollection<T>
public ParetoFront<T> merge(ParetoFront<? extends T> elements)
elements
to this
pareto-set.elements
- the elements to addthis
pareto-setNullPointerException
- if the given parameter is null
O(n*m)
.public ParetoFront<T> trim(int size, ElementComparator<? super T> comparator, ElementDistance<? super T> distance, ToIntFunction<? super T> dimension)
this
pareto front to the given size. The front elements are
sorted according its crowding distance and the elements which have smaller
distance to its neighbors are removed first.
final ParetoFront<Vec<double[]>> front = new ParetoFront<>(Vec::dominance);
front.trim(10, Vec::compare, Vec::distance, Vec::length);
size
- the number of front elements after the trim. If
size() <= size
, nothing is trimmed.comparator
- the element comparator used for calculating the
crowded distancedistance
- the element distance measuredimension
- the number of vector elements of T
this
trimmed pareto frontNullPointerException
- if one of the objects is null
public int size()
size
in interface Collection<T>
size
in interface Set<T>
size
in class AbstractCollection<T>
public boolean isEmpty()
isEmpty
in interface Collection<T>
isEmpty
in interface Set<T>
isEmpty
in class AbstractCollection<T>
public ISeq<T> toISeq()
this
pareto-front as ISeq
.this
pareto-front as ISeq
public static <C extends Comparable<? super C>> Collector<C,?,ParetoFront<C>> toParetoFront()
C
- the element typepublic static <T> Collector<T,?,ParetoFront<T>> toParetoFront(Comparator<? super T> dominance)
dominance
measure.T
- the element typedominance
- the pareto dominance comparatorNullPointerException
- if the given dominance
collector is
null
© 2007-2019 Franz Wilhelmstötter (2019-02-19 21:44)