@Test public void bestWorstPhenotype() { final int length = 100; final Function<Genotype<IntegerGene>, Integer> ff = gt -> gt.getGene().getAllele(); final MSeq<Phenotype<IntegerGene, Integer>> population = MSeq.ofLength(length); for (int i = 0; i < length; ++i) { final Genotype<IntegerGene> gt = Genotype.of(IntegerChromosome.of( IntegerGene.of(i, 0, length) )); population.set(i, Phenotype.of(gt, 1, ff)); } population.shuffle(RandomRegistry.getRandom()); final EvolutionResult<IntegerGene, Integer> maxResult = EvolutionResult.of( Optimize.MAXIMUM, population.toISeq(), 0, 0, EvolutionDurations.ZERO, 0, 0, 0 ); Assert.assertEquals(maxResult.getBestFitness().intValue(), length - 1); Assert.assertEquals(maxResult.getWorstFitness().intValue(), 0); final EvolutionResult<IntegerGene, Integer> minResult = EvolutionResult.of( Optimize.MINIMUM, population.toISeq(), 0, 0, EvolutionDurations.ZERO, 0, 0, 0 ); Assert.assertEquals(minResult.getBestFitness().intValue(), 0); Assert.assertEquals(minResult.getWorstFitness().intValue(), length - 1); }