Pareto { public static <T> double[] crowdingDistance(final BaseSeq<? extends Vec<T>> set) { return crowdingDistance( set, Vec::compare, Vec::distance, Vec::length ); } 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 crowdedDistance() { final Random random = new Random(5345); ISeq<Vec<double[]>> points = IntStream.range(0, 50) .mapToObj(i -> { final double k = random.nextInt(10_000); final double l = random.nextInt(10_000); return Vec.of(k, l); }) .collect(ISeq.toISeq()); final double[] distance = Pareto.crowdingDistance(points); Assert.assertEquals( distance, new double[]{ 0.07870822748764089, POSITIVE_INFINITY, 0.04223935440208857, 0.0734723931549105, 0.08262933375836108, 0.07080599996446849, 0.1280772521691561, 0.07500782380601785, 0.10346165319126902, 0.08739273743069301, 0.09371414325750799, 0.09677297469253897, 0.06860068967311245, 0.1556309291729891, 0.044762588039068914, 0.05301158371826927, 0.05807157942534296, 0.12285056425606283, 0.05444377867925762, 0.07798119564333192, 0.08084558556530863, 0.05994420808040598, 0.13953549396293413, 0.08340532220133795, POSITIVE_INFINITY, 0.030426551909450487, 0.09843817081818175, 0.12123391133159023, 0.04392629523611162, 0.02599473437004262, 0.091243421437676, 0.11746678529383461, 0.08712213776362061, 0.033935252836441665, 0.04480182979654032, 0.06176829353429881, 0.10228229213988838, 0.07835188917954063, 0.040138923055904996, 0.14922803236443535, 0.062381971784731975, 0.03538877910831255, POSITIVE_INFINITY, 0.15121414896756094, 0.11176206518424872, 0.10671055446081582, 0.10338412049057095, 0.06070200703348302, 0.10065784667258369, POSITIVE_INFINITY} ); }