### Question:
ParameterizableStringFactory extends AbstractFeatureFactory<T> { @Override public Pair<T, T> crossover(T parentA, T parentB) { assertEqualFactoryIds(parentA.getFactoryId(), parentB.getFactoryId()); assertEqualFactoryIds(getFactoryId(), parentA.getFactoryId()); float[] valsA = getValues(parentA); float[] valsB = getValues(parentB); if (valsA.length != valsB.length) { throw new IllegalArgumentException( String.format(Locale.US, "Can't have diff val lengths: %s %s", valsA.length, valsB.length) ); } float[] childA = new float[valsA.length]; float[] childB = new float[valsB.length]; for (int i = 0; i < childA.length; i++) { if (MathUtil.RANDOM.nextFloat() > 0.5) { childA[i] = valsA[i]; } else { childA[i] = valsB[i]; } if (MathUtil.RANDOM.nextFloat() > 0.5) { childB[i] = valsA[i]; } else { childB[i] = valsB[i]; } } return Pair.of(newInstance(childA), newInstance(childB)); } ParameterizableStringFactory(String name, String factoryId, Class clazz, String paramString); String getFactoryId(); @Override T random(); @Override List<T> permute(int maxSize); @Override T mutate(T parameterizableString, double probability, double amplitude); @Override Pair<T, T> crossover(T parentA, T parentB);  }### Answer:
@Test public void testCrossOver() throws Exception { 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) ); } } }