*/
@Override
public void performOperation(Random rnd, Genome[] parents, int parentIndex,
Genome[] offspring, int offspringIndex) {
ArrayGenome mother = (ArrayGenome)parents[parentIndex];
ArrayGenome father = (ArrayGenome)parents[parentIndex+1];
ArrayGenome offspring1 = (ArrayGenome)this.owner.getPopulation().getGenomeFactory().factor();
ArrayGenome offspring2 = (ArrayGenome)this.owner.getPopulation().getGenomeFactory().factor();
offspring[offspringIndex] = offspring1;
offspring[offspringIndex+1] = offspring2;
final int geneLength = mother.size();
// the chromosome must be cut at two positions, determine them
final int cutpoint1 = (int) (rnd.nextInt(geneLength - this.cutLength));
final int cutpoint2 = cutpoint1 + this.cutLength;
// handle cut section
for (int i = 0; i < geneLength; i++) {
if (!((i < cutpoint1) || (i > cutpoint2))) {
offspring1.copy(father,i,i);
offspring2.copy(mother,i,i);
}
}
// handle outer sections
for (int i = 0; i < geneLength; i++) {
if ((i < cutpoint1) || (i > cutpoint2)) {
offspring1.copy(mother,i,i);
offspring2.copy(father,i,i);
}
}
}