toBestEvolutionResult seems to return suboptimal result #420
Closed
Description
I'm using Release 4.2.1.
Unless I did something wrong, I'd expect thus small snippet should return a value >= 100.
Genotype<IntegerGene> genotype = Genotype.of(IntegerChromosome.of(0, 10));
AtomicInteger ai = new AtomicInteger();
Function<Genotype<IntegerGene>, Integer> genoval = x -> ai.incrementAndGet();
EvolutionResult<IntegerGene, Integer> evoResult = Engine.builder(genoval, genotype)
.build()
.stream()
.limit(Limits.byFitnessThreshold(100))
.collect(EvolutionResult.toBestEvolutionResult());
System.out.println(evoResult.getBestFitness());
But it does return a some value < 100 and since it returns a random value close to 100 I assume it's just selecting the wrong "best".