@Test(dataProvider = "numberOfCrossoverPoints") public void reverseCrossover(final Integer npoints) { for (int i = 1; i < 500; ++i) { final CharSeq chars = CharSeq.of("a-zA-Z"); final ISeq<Character> a = ISeq.of(CharacterChromosome.of(chars, i)) .map(CharacterGene::allele); final ISeq<Character> b = ISeq.of(CharacterChromosome.of(chars, i)) .map(CharacterGene::allele); final MSeq<Character> ma1 = a.copy(); final MSeq<Character> mb1 = b.copy(); final int[] points = Combinatorics.subset( a.length() + 1, min(npoints, a.length() + 1), new Random(1234) ); MultiPointCrossover.crossover(ma1, mb1, points); MultiPointCrossover.crossover(ma1, mb1, points); Assert.assertEquals(ma1, a); Assert.assertEquals(mb1, b); } }
@Override protected int crossover(final MSeq<G> that, final MSeq<G> other) { assert that.length() == other.length(); final int n = min(that.length(), other.length()); final int k = min(n, _n); final Random random = RandomRegistry.random(); final int[] points = k > 0 ? Combinatorics.subset(n, k, random) : new int[0]; crossover(that, other, points); return 2; }
MultiPointCrossover extends Crossover<G, C> { @Override protected int crossover(final MSeq<G> that, final MSeq<G> other) { assert that.length() == other.length(); final int n = min(that.length(), other.length()); final int k = min(n, _n); final Random random = RandomRegistry.random(); final int[] points = k > 0 ? Combinatorics.subset(n, k, random) : new int[0]; crossover(that, other, points); return 2; } }
MultiPointCrossover extends Crossover<G, C> { @Override protected int crossover(final MSeq<G> that, final MSeq<G> other) { assert that.length() == other.length(); final int n = min(that.length(), other.length()); final int k = min(n, _n); final Random random = RandomRegistry.random(); final int[] points = k > 0 ? Combinatorics.subset(n, k, random) : new int[0]; crossover(that, other, points); return 2; } MultiPointCrossover(final double probability, final int n);  MultiPointCrossover(final double probability);  MultiPointCrossover(final int n);  MultiPointCrossover(); }
MultiPointCrossover extends Crossover<G, C> { @Override protected int crossover(final MSeq<G> that, final MSeq<G> other) { assert that.length() == other.length(); final int n = min(that.length(), other.length()); final int k = min(n, _n); final Random random = RandomRegistry.random(); final int[] points = k > 0 ? Combinatorics.subset(n, k, random) : new int[0]; crossover(that, other, points); return 2; } MultiPointCrossover(final double probability, final int n);  MultiPointCrossover(final double probability);  MultiPointCrossover(final int n);  MultiPointCrossover(); int crossoverPointCount(); @Override String toString(); }
MultiPointCrossover extends Crossover<G, C> { @Override protected int crossover(final MSeq<G> that, final MSeq<G> other) { assert that.length() == other.length(); final int n = min(that.length(), other.length()); final int k = min(n, _n); final Random random = RandomRegistry.random(); final int[] points = k > 0 ? Combinatorics.subset(n, k, random) : new int[0]; crossover(that, other, points); return 2; } MultiPointCrossover(final double probability, final int n);  MultiPointCrossover(final double probability);  MultiPointCrossover(final int n);  MultiPointCrossover(); int crossoverPointCount(); @Override String toString();  }