Pareto { public static <T> int[] rank(final BaseSeq<? extends Vec<T>> set) { return rank(set, Vec::dominance); } private  Pareto(); static double[] crowdingDistance(final BaseSeq<? extends Vec<T>> set); static double[] crowdingDistance(
		final BaseSeq<? extends T> set,
		final ElementComparator<? super T> comparator,
		final ElementDistance<? super T> distance,
		final ToIntFunction<? super T> dimension
	); static int[] rank(final BaseSeq<? extends Vec<T>> set); static int[] rank(
		final BaseSeq<? extends T> set,
		final Comparator<? super T> dominance
	); static ISeq<Vec<T>> front(final BaseSeq<? extends Vec<T>> set); static ISeq<T> front(
		final BaseSeq<? extends T> set,
		final Comparator<? super T> dominance
	); static int dominance(final C[] u, final C[] v); static int dominance(final T[] u, final T[] v, final Comparator<? super T> comparator); static int dominance(final int[] u, final int[] v); static int dominance(final long[] u, final long[] v); static int dominance(final double[] u, final double[] v); static int dominance(
		final V u,
		final V v,
		final int dimensions,
		final ElementComparator<? super V> comparator
	);  }
@Test public void rankMax() { final Random random = new Random(123123); final ISeq<Vec<double[]>> rank0 = frontMax(20, 50, random); final ISeq<Vec<double[]>> rank1 = frontMax(15, 50, random); final ISeq<Vec<double[]>> rank2 = frontMax(10, 50, random); final ISeq<Vec<double[]>> rank3 = frontMax(5, 50, random); final ISeq<Vec<double[]>> rank4 = frontMax(1, 50, random); final ISeq<Vec<double[]>> points = rank0 .append(rank1) .append(rank2) .append(rank3) .append(rank4); final int[] rank = Pareto.rank(points); Assert.assertEquals( IntStream.range(0, points.size()) .filter(i -> rank[i] == 0) .mapToObj(points) .collect(Collectors.toSet()), new HashSet<>(rank0.asList()) ); Assert.assertEquals( IntStream.range(0, points.size()) .filter(i -> rank[i] == 1) .mapToObj(points) .collect(Collectors.toSet()), new HashSet<>(rank1.asList()) ); Assert.assertEquals( IntStream.range(0, points.size()) .filter(i -> rank[i] == 2) .mapToObj(points) .collect(Collectors.toSet()), new HashSet<>(rank2.asList()) ); Assert.assertEquals( IntStream.range(0, points.size()) .filter(i -> rank[i] == 3) .mapToObj(points) .collect(Collectors.toSet()), new HashSet<>(rank3.asList()) ); Assert.assertEquals( IntStream.range(0, points.size()) .filter(i -> rank[i] == 4) .mapToObj(points) .collect(Collectors.toSet()), new HashSet<>(rank4.asList()) ); }