@Test public void merge() { final Genotype<DoubleGene> gt = Genotype.of( DoubleChromosome.of(0, 1), DoubleChromosome.of(1, 2), DoubleChromosome.of(2, 3), DoubleChromosome.of(3, 4) ); final ISeq<Phenotype<DoubleGene, Double>> population = gt.instances() .limit(3) .map(g -> Phenotype.<DoubleGene, Double>of(g, 0)) .collect(ISeq.toISeq()); final Projection projection = PartialAlterer.Projection.of(1, 3); final Seq<Phenotype<DoubleGene, Double>> split = projection.project(population); Assert.assertEquals(split.length(), population.length()); for (int i = 0; i < population.length(); ++i) { Assert.assertEquals(split.get(i).genotype().length(), 2); } final Seq<Phenotype<DoubleGene, Double>> merged = projection.merge(split, population); Assert.assertEquals(merged, population); }
public static <G extends Gene<?, G>, C extends Comparable<? super C>> Alterer<G, C> of(final Alterer<G, C> alterer, final int... indices) { return new PartialAlterer<>(alterer, Projection.of(indices)); }
PartialAlterer implements Alterer<G, C> { public static <G extends Gene<?, G>, C extends Comparable<? super C>> Alterer<G, C> of(final Alterer<G, C> alterer, final int... indices) { return new PartialAlterer<>(alterer, Projection.of(indices)); } }
PartialAlterer implements Alterer<G, C> { public static <G extends Gene<?, G>, C extends Comparable<? super C>> Alterer<G, C> of(final Alterer<G, C> alterer, final int... indices) { return new PartialAlterer<>(alterer, Projection.of(indices)); } private  PartialAlterer(final Alterer<G, C> alterer, final Projection projection); }
PartialAlterer implements Alterer<G, C> { public static <G extends Gene<?, G>, C extends Comparable<? super C>> Alterer<G, C> of(final Alterer<G, C> alterer, final int... indices) { return new PartialAlterer<>(alterer, Projection.of(indices)); } private  PartialAlterer(final Alterer<G, C> alterer, final Projection projection); @Override AltererResult<G, C> alter(final Seq<Phenotype<G, C>> population, final long generation); static Alterer<G, C> of(final Alterer<G, C> alterer, final int... indices); static Alterer<G, C> of(final Alterer<G, C> alterer, final IntRange section); }
PartialAlterer implements Alterer<G, C> { public static <G extends Gene<?, G>, C extends Comparable<? super C>> Alterer<G, C> of(final Alterer<G, C> alterer, final int... indices) { return new PartialAlterer<>(alterer, Projection.of(indices)); } private  PartialAlterer(final Alterer<G, C> alterer, final Projection projection); @Override AltererResult<G, C> alter(final Seq<Phenotype<G, C>> population, final long generation); static Alterer<G, C> of(final Alterer<G, C> alterer, final int... indices); static Alterer<G, C> of(final Alterer<G, C> alterer, final IntRange section);  }