@Test public void split() { final Phenotype<DoubleGene, Double> pt = Phenotype.of( Genotype.of( DoubleChromosome.of(0, 1), DoubleChromosome.of(1, 2), DoubleChromosome.of(2, 3), DoubleChromosome.of(3, 4), DoubleChromosome.of(4, 5), DoubleChromosome.of(5, 6), DoubleChromosome.of(6, 7), DoubleChromosome.of(7, 8), DoubleChromosome.of(8, 9), DoubleChromosome.of(9, 10) ), 0 ); final PartialAlterer.Projection projection = PartialAlterer.Projection.of(1, 3, 5); final Phenotype<DoubleGene, Double> split = projection.project(pt); Assert.assertEquals(split.genotype().length(), 3); Assert.assertEquals(split.genotype().get(0), pt.genotype().get(1)); Assert.assertEquals(split.genotype().get(1), pt.genotype().get(3)); Assert.assertEquals(split.genotype().get(2), pt.genotype().get(5)); }
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);  }