@Test(expectedExceptions = CompletionException.class) public void withEngineOutOfBounds() { final Problem<Double, DoubleGene, Double> problem = Problem.of( x -> cos(0.5 + sin(x))*cos(x), Codecs.ofScalar(DoubleRange.of(0.0, 2.0*PI)) ); final Genotype<DoubleGene> gtf = Genotype.of( DoubleChromosome.of(0, 1), DoubleChromosome.of(1, 2), DoubleChromosome.of(2, 3), DoubleChromosome.of(3, 4) ); final Engine<DoubleGene, Double> engine = Engine .builder(gt -> gt.gene().doubleValue(), gtf) .selector(new RouletteWheelSelector<>()) .alterers( PartialAlterer.of(new Mutator<DoubleGene, Double>(), 0, 2), PartialAlterer.of(new MeanAlterer<DoubleGene, Double>(), 3, 4), new GaussianMutator<>() ) .build(); engine.stream() .limit(100) .collect(EvolutionResult.toBestEvolutionResult()); }
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);  }