Program: 180754
Project: 180754
Buggy source:
/** 
 * Selects two parents by calling <code>getProgramSelector()</code> on the  instance of <code>GPModel</code> given at construction and submits them  to the <code>Crossover</code> operator which is obtained by calling  <code>getCrossover()</code> on the model.  <p>After a crossover is made, the controlling model is requested to  confirm the crossover by a call to <code>acceptCrossover()</code>. This  gives the model total control over whether a crossover is allowed to  proceed. If <code>acceptCrossover()</code> returns <code>false</code>  then the children are discarded and two new parents are selected and  attempted for crossover. The number of times the crossover was reverted  before being accepted is available through a call to  <code>getRevertedCount()</code>. <p>Even after a crossover has been accepted by the model, it may still  be prevented from proceeding if the program depth of either of the  children exceeds the max depth that the model defines. In the case that  the children do exceed the limit then the parents are returned as the  result. This does not count towards the number of reversions.
 * @return an array of CandidatePrograms generated through crossover. This is typically 2 child programs, but could in theory be any number  as returned by the Crossover operator in use.
 */
public CandidateProgram<TYPE>[] crossover(){
  long crossoverStartTime=System.nanoTime();
  CandidateProgram<TYPE> parent1;
  CandidateProgram<TYPE> parent2;
  CandidateProgram<TYPE> clone1;
  CandidateProgram<TYPE> clone2;
  CandidateProgram<TYPE>[] parents=null;
  CandidateProgram<TYPE>[] children=null;
  reversions=-1;
  boolean accepted=true;
  do {
    parent1=programSelector.getProgram();
    parent2=programSelector.getProgram();
    clone1=(CandidateProgram<TYPE>)parent1.clone();
    clone2=(CandidateProgram<TYPE>)parent2.clone();
    parents=new CandidateProgram[]{parent1,parent2};
    children=crossover.crossover(clone1,clone2);
    accepted=model.acceptCrossover(parents,children);
    reversions++;
  }
 while (!accepted);
  for (int i=0; i < children.length; i++) {
    if (children[i].getProgramDepth() > model.getMaxDepth()) {
      children[i]=(CandidateProgram<TYPE>)parents[i].clone();
    }
  }
  long runtime=System.nanoTime() - crossoverStartTime;
  crossoverStats.addCrossover(parents,children,runtime);
  return children;
}

Fixed version (ground truth):
/** 
 * Selects two parents by calling <code>getProgramSelector()</code> on the  instance of <code>GPModel</code> given at construction and submits them  to the <code>Crossover</code> operator which is obtained by calling  <code>getCrossover()</code> on the model.  <p>After a crossover is made, the controlling model is requested to  confirm the crossover by a call to <code>acceptCrossover()</code>. This  gives the model total control over whether a crossover is allowed to  proceed. If <code>acceptCrossover()</code> returns <code>false</code>  then the children are discarded and two new parents are selected and  attempted for crossover. The number of times the crossover was reverted  before being accepted is available through a call to  <code>getRevertedCount()</code>. <p>Even after a crossover has been accepted by the model, it may still  be prevented from proceeding if the program depth of either of the  children exceeds the max depth that the model defines. In the case that  the children do exceed the limit then the parents are returned as the  result. This does not count towards the number of reversions.
 * @return an array of CandidatePrograms generated through crossover. This is typically 2 child programs, but could in theory be any number  as returned by the Crossover operator in use.
 */
public CandidateProgram<TYPE>[] crossover(){
  long crossoverStartTime=System.nanoTime();
  CandidateProgram<TYPE> parent1;
  CandidateProgram<TYPE> parent2;
  CandidateProgram<TYPE> clone1;
  CandidateProgram<TYPE> clone2;
  CandidateProgram<TYPE>[] parents=null;
  CandidateProgram<TYPE>[] children=null;
  reversions=-1;
  boolean accepted=true;
  do {
    parent1=programSelector.getProgram();
    parent2=programSelector.getProgram();
    clone1=(CandidateProgram<TYPE>)parent1.clone();
    clone2=(CandidateProgram<TYPE>)parent2.clone();
    parents=new CandidateProgram[]{parent1,parent2};
    children=crossover.crossover(clone1,clone2);
    accepted=model.acceptCrossover(parents,children);
    reversions++;
  }
 while (!accepted);
  int replacement=0;
  for (int i=0; i < children.length; i++) {
    if (children[i].getProgramDepth() > model.getMaxDepth()) {
      if (replacement >= parents.length) {
        replacement=0;
      }
      children[i]=(CandidateProgram<TYPE>)parents[replacement].clone();
      replacement++;
    }
  }
  long runtime=System.nanoTime() - crossoverStartTime;
  crossoverStats.addCrossover(parents,children,runtime);
  return children;
}