@Test(dataProvider = "crossoverParameters") public void crossover( final String stringA, final String stringB, final Seq<Integer> points, final String expectedA, final String expectedB ) { final ISeq<Character> a = CharSeq.toISeq(stringA); final ISeq<Character> b = CharSeq.toISeq(stringB); final MSeq<Character> ma = a.copy(); final MSeq<Character> mb = b.copy(); final int[] intPoints = points.stream() .mapToInt(Integer::intValue) .toArray(); MultiPointCrossover.crossover(ma, mb, intPoints); Assert.assertEquals(toString(ma), expectedA); Assert.assertEquals(toString(mb), expectedB); }
@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();  }