System.out.println("Mutate Perturb");
GenerateRandom rnd = new MersenneTwisterGenerateRandom();
// Create a new population.
Population pop = new BasicPopulation();
pop.setGenomeFactory(new DoubleArrayGenomeFactory(5));
// Create a trainer with a very simple score function. We do not care
// about the calculation of the score, as they will never be calculated.
EvolutionaryAlgorithm train = new BasicEA(pop, new ScoreFunction() {
@Override
public double calculateScore(MLMethod method) {
return 0;
}
@Override
public boolean shouldMinimize() {
return false;
}
});
MutatePerturb opp = new MutatePerturb(0.1);
train.addOperation(1.0, opp);
// Create a peterb operator. Use it 1.0 (100%) of the time.
DoubleArrayGenome[] parents = new DoubleArrayGenome[1];
parents[0] = (DoubleArrayGenome) pop.getGenomeFactory().factor();
parents[0].setPopulation(pop);
for (int i = 1; i <= 5; i++) {
parents[0].getData()[i - 1] = i;
}