### Question:
ParameterizableStringListFactory extends AbstractFeatureFactory<T> { @Override public T mutate(ParameterizableStringListFeature listFeature, double probability, double amplitude) { List<ParameterizableString> mutated = new ArrayList<>(); int numMutations = (int) FastMath.floor(amplitude * factories.size()); numMutations = (numMutations == 0) ? 1 : numMutations; for (int i = 0; i < listFeature.size(); i++) { mutated.add(listFeature.get(i)); } for (int i = 0; i < numMutations; i++) { MUTATE_OPERATION op = nextMutateOperation(); switch (op) { case INSERT: if (mutated.size() == factoryMap.size() || (maxSetSize > -1 && mutated.size() >= maxSetSize)) { remove(mutated); } else { insert(mutated, amplitude); } break; case MUTATE: if (mutated.size() < minSetSize) { insert(mutated, amplitude); } else { modify(mutated, amplitude); } break; case REMOVE: if (mutated.size() < minSetSize) { insert(mutated, amplitude); } else { remove(mutated); } break; } } List<ParameterizableString> ret = new ArrayList<>(); while (mutated.size() < minSetSize) { insert(mutated, amplitude); } for (ParameterizableString s : mutated) { ret.add(s); } return (T)newInstance(ret); } 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 testMutate() { String paramString = "recip(rord(creationDate),[1,2,3],[10,100,1000],[$2])"; TestParam t = new TestParam("bf", "0", "recip(rord(creationDate),2,100,100)"); ParameterizableStringFactory<TestParam> fact = new ParameterizableStringFactory("bf", "0", TestParam.class, paramString); int diffs = 0; for (int i = 0; i < 100; i++) { TestParam mutated = fact.mutate(t, 0.8, 0.8); float[] vals = mutated.getValues(); assertTrue(vals[0] >= 1.0f && vals[0] <= 3.0f); assertTrue(vals[1] >= 10f && vals[1] <= 1000f); if (!MathUtil.equals(2, mutated.getValues()[0], 0.1f) && !MathUtil.equals(100, mutated.getValues()[1], 0.1f)) { diffs++; } } assertTrue(diffs > 10); }