@Test public void limit() { final Predicate<EvolutionResult<?, Double>> l = Limits.byPopulationConvergence(0.015); int g = 0; while (l.test(result(10 + g, 100 + g, g + 1, Optimize.MAXIMUM))) { ++g; } Assert.assertEquals(g, 2901); }
@Override public boolean test(final EvolutionResult<?, N> result) { final DoubleMomentStatistics fitness = new DoubleMomentStatistics(); result.population() .forEach(p -> fitness.accept(p.fitness().doubleValue())); return result.totalGenerations() <= 1 || _proceed.test( result.bestFitness() != null ? result.bestFitness().doubleValue() : Double.NaN, DoubleMoments.of(fitness) ); }
PopulationConvergenceLimit implements Predicate<EvolutionResult<?, N>> { @Override public boolean test(final EvolutionResult<?, N> result) { final DoubleMomentStatistics fitness = new DoubleMomentStatistics(); result.population() .forEach(p -> fitness.accept(p.fitness().doubleValue())); return result.totalGenerations() <= 1 || _proceed.test( result.bestFitness() != null ? result.bestFitness().doubleValue() : Double.NaN, DoubleMoments.of(fitness) ); } }
PopulationConvergenceLimit implements Predicate<EvolutionResult<?, N>> { @Override public boolean test(final EvolutionResult<?, N> result) { final DoubleMomentStatistics fitness = new DoubleMomentStatistics(); result.population() .forEach(p -> fitness.accept(p.fitness().doubleValue())); return result.totalGenerations() <= 1 || _proceed.test( result.bestFitness() != null ? result.bestFitness().doubleValue() : Double.NaN, DoubleMoments.of(fitness) ); } PopulationConvergenceLimit(final BiPredicate<Double, DoubleMoments> proceed); }
PopulationConvergenceLimit implements Predicate<EvolutionResult<?, N>> { @Override public boolean test(final EvolutionResult<?, N> result) { final DoubleMomentStatistics fitness = new DoubleMomentStatistics(); result.population() .forEach(p -> fitness.accept(p.fitness().doubleValue())); return result.totalGenerations() <= 1 || _proceed.test( result.bestFitness() != null ? result.bestFitness().doubleValue() : Double.NaN, DoubleMoments.of(fitness) ); } PopulationConvergenceLimit(final BiPredicate<Double, DoubleMoments> proceed); @Override boolean test(final EvolutionResult<?, N> result); }
PopulationConvergenceLimit implements Predicate<EvolutionResult<?, N>> { @Override public boolean test(final EvolutionResult<?, N> result) { final DoubleMomentStatistics fitness = new DoubleMomentStatistics(); result.population() .forEach(p -> fitness.accept(p.fitness().doubleValue())); return result.totalGenerations() <= 1 || _proceed.test( result.bestFitness() != null ? result.bestFitness().doubleValue() : Double.NaN, DoubleMoments.of(fitness) ); } PopulationConvergenceLimit(final BiPredicate<Double, DoubleMoments> proceed); @Override boolean test(final EvolutionResult<?, N> result);  }