### Question:
ParameterizableStringListFactory extends AbstractFeatureFactory<T> { @Override public Pair<T, T> crossover(T parentA, T parentB) { Set<String> union = new HashSet<>(); for (ParameterizableString p : parentA.getParameterizableStrings()) { union.add(p.getFactoryId()); } for (ParameterizableString p : parentB.getParameterizableStrings()) { union.add(p.getFactoryId()); } List<String> uniques = new ArrayList<>(union); Collections.shuffle(uniques); List<String> childA = new ArrayList<>(); int numA = MathUtil.RANDOM.nextInt(minSetSize, maxSetSize); int sz = numA >= uniques.size() ? uniques.size() : numA; for (int i = 0; i < sz; i++) { childA.add(uniques.get(i)); } Collections.shuffle(uniques); List<String> childB = new ArrayList<>(); int numB = MathUtil.RANDOM.nextInt(minSetSize, maxSetSize); sz = numB >= uniques.size() ? uniques.size() : numB; for (int i = 0; i < sz; i++) { childB.add(uniques.get(i)); } return Pair.of( (T)buildCrossOver(childA, parentA, parentB), (T)buildCrossOver(childB, parentA, parentB) ); } ParameterizableStringListFactory(String name, Class clazz,
                                            List<ParameterizableStringFactory> factories,
                                            int minSetSize, int maxSetSize); @Override T random(); @Override List<T> permute(int maxSize); @Override T mutate(ParameterizableStringListFeature listFeature,
                                                   double probability, double amplitude); @Override Pair<T, T> crossover(T parentA, T parentB);  }### Answer:
@Test public void testCrossOver() { String paramString = "recip(rord(creationDate),[1,2,3],[10,100,1000],[$2])"; TestParam t1 = new TestParam("bf", "0", "recip(rord(creationDate),2,100,100)"); TestParam t2 = new TestParam("bf", "0", "recip(rord(creationDate),1,1000,1000)"); ParameterizableStringFactory<TestParam> fact = new ParameterizableStringFactory("bf", "0", TestParam.class, paramString); for (int i = 0; i < 100; i++) { Pair<TestParam, TestParam> pair = fact.crossover(t1, t2); for (TestParam t : new TestParam[]{pair.getLeft(), pair.getRight()}) { List<Float> floats = extractFloats(t.toString()); assertTrue( MathUtil.equals(floats.get(0), 1f, 0.00001f) || MathUtil.equals(floats.get(0), 2f, 0.00001f) ); assertTrue( MathUtil.equals(floats.get(1), 100f, 0.00001f) || MathUtil.equals(floats.get(1), 1000f, 0.00001f) ); assertTrue( MathUtil.equals(floats.get(2), 100f, 0.00001f) || MathUtil.equals(floats.get(2), 1000f, 0.00001f) ); } } }