@Test public void crossover() { final ISeq<CharacterGene> g1 = ISeq.of(CharacterChromosome.of("1234567890")); final ISeq<CharacterGene> g2 = ISeq.of(CharacterChromosome.of("abcdefghij")); final int rv1 = 12; using(new Random(10), r -> { final UniformCrossover<CharacterGene, Double> crossover = new UniformCrossover<>(0.5, 0.5); MSeq<CharacterGene> g1c = g1.copy(); MSeq<CharacterGene> g2c = g2.copy(); final int changed = crossover.crossover(g1c, g2c); Assert.assertEquals(changed, IntStream.range(0, g2c.length()) .filter(i -> Character.isDigit(g2c.get(i).charValue())) .count() ); }); }
@Override protected int crossover(final MSeq<G> that, final MSeq<G> other) { final int length = min(that.length(), other.length()); return (int)indexes(RandomRegistry.random(), length, _swapProbability) .peek(i -> that.swap(i, other)) .count(); }
UniformCrossover extends Crossover<G, C> { @Override protected int crossover(final MSeq<G> that, final MSeq<G> other) { final int length = min(that.length(), other.length()); return (int)indexes(RandomRegistry.random(), length, _swapProbability) .peek(i -> that.swap(i, other)) .count(); } }
UniformCrossover extends Crossover<G, C> { @Override protected int crossover(final MSeq<G> that, final MSeq<G> other) { final int length = min(that.length(), other.length()); return (int)indexes(RandomRegistry.random(), length, _swapProbability) .peek(i -> that.swap(i, other)) .count(); } UniformCrossover(
		final double crossoverProbability,
		final double swapProbability
	);  UniformCrossover(final double crossoverProbability);  UniformCrossover(); }
UniformCrossover extends Crossover<G, C> { @Override protected int crossover(final MSeq<G> that, final MSeq<G> other) { final int length = min(that.length(), other.length()); return (int)indexes(RandomRegistry.random(), length, _swapProbability) .peek(i -> that.swap(i, other)) .count(); } UniformCrossover(
		final double crossoverProbability,
		final double swapProbability
	);  UniformCrossover(final double crossoverProbability);  UniformCrossover(); double swapProbability(); }
UniformCrossover extends Crossover<G, C> { @Override protected int crossover(final MSeq<G> that, final MSeq<G> other) { final int length = min(that.length(), other.length()); return (int)indexes(RandomRegistry.random(), length, _swapProbability) .peek(i -> that.swap(i, other)) .count(); } UniformCrossover(
		final double crossoverProbability,
		final double swapProbability
	);  UniformCrossover(final double crossoverProbability);  UniformCrossover(); double swapProbability();  }