return false;
}
});
// Create a splice operator, length = 5. Use it 1.0 (100%) of the time.
Splice opp = new Splice(5);
train.addOperation(1.0, opp);
// Create two parents, the genes are set to 1,2,3,4,5,7,8,9,10
// and 10,9,8,7,6,5,4,3,2,1.
IntegerArrayGenome[] parents = new IntegerArrayGenome[2];
parents[0] = (IntegerArrayGenome) pop.getGenomeFactory().factor();
parents[1] = (IntegerArrayGenome) pop.getGenomeFactory().factor();
for (int i = 1; i <= 10; i++) {
parents[0].getData()[i - 1] = i;
parents[1].getData()[i - 1] = 11 - i;
}
// Create an array to hold the offspring.
IntegerArrayGenome[] offspring = new IntegerArrayGenome[2];
// Perform the operation
opp.performOperation(rnd, parents, 0, offspring, 0);
// Display the results
System.out.println("Parent 1: " + Arrays.toString(parents[0].getData()));
System.out.println("Parent 2: " + Arrays.toString(parents[1].getData()));
System.out.println("Offspring 1: " + Arrays.toString(offspring[0].getData()));