private Supplier<EvolutionStart<G, C>> evolutionStart(final Supplier<EvolutionStart<G, C>> start) { return () -> { final EvolutionStart<G, C> es = start.get(); final ISeq<Phenotype<G, C>> population = es.getPopulation(); final long generation = es.getGeneration(); final Stream<Phenotype<G, C>> stream = Stream.concat( population.stream().map(this::toFixedPhenotype), Stream.generate(() -> newPhenotype(generation)) ); final ISeq<Phenotype<G, C>> pop = stream .limit(getPopulationSize()) .collect(ISeq.toISeq()); return EvolutionStart.of(pop, generation); }; }
_evaluator.evaluate(start.getPopulation()); if (start.getPopulation().size() != evalPop.size()) { throw new IllegalStateException(format( "Expected %d individuals, but got %d. " + "Check your evaluator function.", start.getPopulation().size(), evalPop.size() ));
@Test public void concat1b() { EvolutionInit<IntegerGene> init = EvolutionInit.of( EvolutionStreams.result(5) .toEvolutionStart() .getPopulation().stream() .map(Phenotype::getGenotype) .collect(ISeq.toISeq()), 1 ); final EvolutionStream<IntegerGene, Integer> stream = ConcatEngine.of(streamable(1)) .stream(init); final int[] array = stream .mapToInt(r -> r.getGenotypes().get(0).getGene().intValue()) .toArray(); Assert.assertEquals(array, new int[]{6}); }