PhenotypeGaussianMutationReproductionOperator extends AbstractMutationReproductionOperator { public void setStepSize(double stepSize) { this.stepSize = stepSize; this.deviation = this.getDeviation(stepSize); } PhenotypeGaussianMutationReproductionOperator(); Class<? extends Representation> getAcceptableType(); double getDeviation(); double getDeviation(double stepSize); double getStepSize(); void setStepSize(double stepSize);  }
@Test public void testReproduce() throws Exception { this.operator = new PhenotypeGaussianMutationReproductionOperator(); this.randomGenerator = new EmptyRandomGenerator(){ protected double[] randoms = new double[]{0.8, 0.3, 0.4, 0.5}; protected int randomIdx = 0; protected double[] gaussians = new double[]{1.0, 0.5, -0.75}; protected int gaussIdx = 0; @Override public double nextRandom() { return randoms[randomIdx++]; } @Override public double nextGaussian(double mean, double standardDeviation) { return gaussians[gaussIdx++]; } }; this.operator.setRandomGenerator(this.randomGenerator); this.function = new EmptyObjectiveFunction(){ @Override public boolean inBounds(Point position) { double[] pos = position.toArray(); return (pos[0] > -3.0 && pos[0] < 1.0 && pos[1] > -2.0 && pos[1] < 1.0); } @Override public int getDimension() { return 2; } }; this.operator.setFunction(this.function); this.operator.setPopulationFactory(new SimplePopulationFactory()); this.operator.setMutationProbability(0.5); this.operator.setStepSize(1.0); double[] positionsX = new double[]{0.0, -2.0}; double[] positionsY = new double[]{0.5, -1.0}; Individual[] parents = new Individual[2]; for (int i = 0; i < 2; i++){ parents[i] = new SimpleIndividual(1, 1.0, new SimplePhenotypeRepresentation(new double[]{positionsX[i], positionsY[i]})); } Population[] childrenPops = this.operator.reproduce(new Population[]{new SimplePopulation(parents)}); assertTrue(childrenPops.length == 1); Individual[] children = childrenPops[0].getIndividuals(); assertTrue(children.length == 2); assertEquals(0.0, children[0].getRepresentation().getDoubleValue()[0]); assertEquals(0.5, children[0].getRepresentation().getDoubleValue()[1]); assertEquals(-1.5, children[1].getRepresentation().getDoubleValue()[0]); assertEquals(-1.75, children[1].getRepresentation().getDoubleValue()[1]); }