Program: 57086
Project: 57086
Buggy source:
/** 
 * Evolve the given population into the next generation. <ol> <li>Get nextGeneration population to fill from <code>current</code> generation, using its nextGeneration method</li> <li>Loop until new generation is filled:</li> <ul><li>Apply configured SelectionPolicy to select a pair of parents from <code>current</code></li> <li>With probability =   {@link #getCrossoverRate()}, apply configured   {@link CrossoverPolicy} to parents</li><li>With probability =  {@link #getMutationRate()}, apply configured   {@link MutationPolicy} to each of the offspring</li><li>Add offspring individually to nextGeneration, space permitting</li> </ul> <li>Return nextGeneration</li> </ol>
 * @param current the current population.
 * @return the population for the next generation.
 */
public Population nextGeneration(final Population current){
  Population nextGeneration=current.nextGeneration();
  UniformRandomProvider randGen=getRandomGenerator();
  while (nextGeneration.getPopulationSize() < nextGeneration.getPopulationLimit()) {
    ChromosomePair pair=getSelectionPolicy().select(current);
    if (randGen.nextDouble() < getCrossoverRate()) {
      pair=getCrossoverPolicy().crossover(pair.getFirst(),pair.getSecond());
    }
    if (randGen.nextDouble() < getMutationRate()) {
      pair=new ChromosomePair(getMutationPolicy().mutate(pair.getFirst()),getMutationPolicy().mutate(pair.getSecond()));
    }
    nextGeneration.addChromosome(pair.getFirst());
    if (nextGeneration.getPopulationSize() < nextGeneration.getPopulationLimit()) {
      nextGeneration.addChromosome(pair.getSecond());
    }
  }
  return nextGeneration;
}

Fixed version (ground truth):
/** 
 * Evolve the given population into the next generation. <ol> <li>Get nextGeneration population to fill from <code>current</code> generation, using its nextGeneration method</li> <li>Loop until new generation is filled: <ul><li>Apply configured SelectionPolicy to select a pair of parents from <code>current</code></li> <li>With probability =   {@link #getCrossoverRate()}, apply configured   {@link CrossoverPolicy} to parents</li><li>With probability =  {@link #getMutationRate()}, apply configured   {@link MutationPolicy} to each of the offspring</li><li>Add offspring individually to nextGeneration, space permitting</li> </ul></li> <li>Return nextGeneration</li> </ol>
 * @param current the current population.
 * @return the population for the next generation.
 */
public Population nextGeneration(final Population current){
  Population nextGeneration=current.nextGeneration();
  UniformRandomProvider randGen=getRandomGenerator();
  while (nextGeneration.getPopulationSize() < nextGeneration.getPopulationLimit()) {
    ChromosomePair pair=getSelectionPolicy().select(current);
    if (randGen.nextDouble() < getCrossoverRate()) {
      pair=getCrossoverPolicy().crossover(pair.getFirst(),pair.getSecond());
    }
    if (randGen.nextDouble() < getMutationRate()) {
      pair=new ChromosomePair(getMutationPolicy().mutate(pair.getFirst()),getMutationPolicy().mutate(pair.getSecond()));
    }
    nextGeneration.addChromosome(pair.getFirst());
    if (nextGeneration.getPopulationSize() < nextGeneration.getPopulationLimit()) {
      nextGeneration.addChromosome(pair.getSecond());
    }
  }
  return nextGeneration;
}