Program: 10309
Project: 10309
Buggy source:
public void start(){
  psi=new Psi(learningProblem);
  System.out.println();
  System.out.println("String_Node_Str");
  System.out.println();
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + algorithmType);
  System.out.print("String_Node_Str" + selectionType);
  if (elitism)   System.out.println("String_Node_Str");
 else   System.out.println();
  System.out.println("String_Node_Str" + numberOfIndividuals);
  if (algorithmType == AlgorithmType.STEADY_STATE)   System.out.println("String_Node_Str" + numberOfSelectedIndividuals);
  System.out.println("String_Node_Str" + df.format(crossoverProbability * 100) + "String_Node_Str");
  System.out.println("String_Node_Str" + df.format(mutationProbability * 100) + "String_Node_Str");
  System.out.println("String_Node_Str" + df.format(hillClimbingProbability * 100) + "String_Node_Str");
  System.out.println("String_Node_Str" + df.format(refinementProbability * 100) + "String_Node_Str");
  System.out.println("String_Node_Str" + postConvergenceGenerations);
  System.out.println();
  individuals=new Program[numberOfIndividuals];
  if (algorithmType == AlgorithmType.GENERATIONAL) {
    if (elitism) {
      numberOfSelectedIndividuals=numberOfIndividuals - 1;
      if (numberOfSelectedIndividuals % 2 == 1)       error("String_Node_Str" + "String_Node_Str");
    }
 else {
      numberOfSelectedIndividuals=numberOfIndividuals;
      if (numberOfSelectedIndividuals % 2 == 1)       error("String_Node_Str" + "String_Node_Str");
    }
  }
  int numberOfNewIndividuals;
  if (elitism)   numberOfNewIndividuals=numberOfSelectedIndividuals + 1;
 else   numberOfNewIndividuals=numberOfSelectedIndividuals;
  if (numberOfIndividuals < 2)   error("String_Node_Str");
  if (numberOfSelectedIndividuals % 2 == 1)   error("String_Node_Str");
  if ((numberOfSelectedIndividuals < 2) || (numberOfSelectedIndividuals > numberOfIndividuals))   error("String_Node_Str" + numberOfIndividuals);
  fitnessComparator=new Comparator<Program>(){
    public int compare(    Program p1,    Program p2){
      double diff=p1.getFitness() - p2.getFitness();
      if (diff > 0)       return 1;
 else       if (diff < 0)       return -1;
 else       return 0;
    }
  }
;
  createIndividuals();
  fittestIndividual=getFittestIndividual();
  fittestIndividualGeneration=0;
  System.out.println("String_Node_Str");
  printStatistics(fittestIndividual);
  int[] selectedIndividuals=new int[numberOfSelectedIndividuals];
  Program[] newIndividuals=new Program[numberOfNewIndividuals];
  Program[] tmp=new Program[2];
  long startTime=System.currentTimeMillis();
  int generation=0;
  do {
    if (selectionType == SelectionType.RANK_SELECTION || algorithmType == AlgorithmType.STEADY_STATE)     Arrays.sort(individuals,fitnessComparator);
    boolean showIndividuals=false;
    if (showIndividuals) {
      System.out.println("String_Node_Str" + generation);
      for (      Program p : individuals) {
        System.out.println(p.getFitness() + "String_Node_Str" + p.getTree());
      }
      System.out.println("String_Node_Str");
    }
    selectedIndividuals=selectIndividuals(generation);
    for (int i=0; i < numberOfSelectedIndividuals; i++) {
      double rand=Math.random();
      double crossoverBoundary=crossoverProbability;
      double mutationBoundary=crossoverBoundary + mutationProbability;
      double hillClimbingBoundary=mutationBoundary + hillClimbingProbability;
      double refinementBoundary=hillClimbingBoundary + refinementProbability;
      if (rand < crossoverBoundary && i + 1 != numberOfSelectedIndividuals) {
        tmp=GPUtilities.crossover(learningProblem,individuals[selectedIndividuals[i]],individuals[selectedIndividuals[i + 1]]);
        newIndividuals[i]=tmp[0];
        newIndividuals[i + 1]=tmp[1];
      }
 else       if (rand >= crossoverBoundary && rand < mutationBoundary) {
        newIndividuals[i]=GPUtilities.mutation(learningProblem,individuals[selectedIndividuals[i]]);
      }
 else       if (rand >= mutationBoundary && rand < hillClimbingBoundary) {
        newIndividuals[i]=GPUtilities.hillClimbing(learningProblem,individuals[selectedIndividuals[i]]);
      }
 else       if (rand >= hillClimbingBoundary && rand < refinementBoundary) {
        newIndividuals[i]=psi.applyOperator(individuals[selectedIndividuals[i]]);
      }
 else {
        newIndividuals[i]=individuals[selectedIndividuals[i]];
      }
    }
    Program chr=getFittestIndividual();
    if (chr.getFitness() > fittestIndividual.getFitness()) {
      fittestIndividual=chr;
      fittestIndividualGeneration=generation;
    }
    if (elitism)     newIndividuals[numberOfNewIndividuals - 1]=fittestIndividual;
    if (algorithmType == AlgorithmType.STEADY_STATE)     System.arraycopy(newIndividuals,0,individuals,0,numberOfNewIndividuals);
 else     System.arraycopy(newIndividuals,0,individuals,0,numberOfIndividuals);
    if (generation % 5 == 0) {
      System.out.println("String_Node_Str" + generation);
      printStatistics(fittestIndividual);
    }
    for (int i=0; i < numberOfIndividuals; i++) {
      if (individuals[i].getTree().getLength() > Config.GP.maxConceptLength) {
        System.out.println("String_Node_Str" + Config.GP.maxConceptLength + "String_Node_Str");
        individuals[i]=GPUtilities.createProgram(learningProblem,new Top());
      }
    }
    generation++;
  }
 while ((useFixedNumberOfGenerations && generation < generations) || (!useFixedNumberOfGenerations && (generation - fittestIndividualGeneration < postConvergenceGenerations)));
  long endTime=System.currentTimeMillis();
  bestScore=fittestIndividual.getScore();
  bestConcept=fittestIndividual.getTree();
  boolean betterValueFoundInPsiCache=false;
  double bestValue=bestScore.getScore();
  if (Config.algorithm == Config.Algorithm.HYBRID_GP) {
    Set<Entry<Concept,Score>> entrySet=psi.evalCache.entrySet();
    for (    Entry<Concept,Score> entry : entrySet) {
      Score tmpScore=entry.getValue();
      Concept c=entry.getKey();
      tmpScore=tmpScore.getModifiedLengthScore(c.getLength());
      double tmpScoreValue=tmpScore.getScore();
      if (tmpScoreValue > bestValue) {
        bestValue=tmpScoreValue;
        betterValueFoundInPsiCache=true;
        bestScore=tmpScore;
        bestConcept=c;
      }
    }
  }
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + generation);
  System.out.println("String_Node_Str" + fittestIndividualGeneration + "String_Node_Str");
  System.out.println("String_Node_Str" + (endTime - startTime));
  System.out.println("String_Node_Str" + GPUtilities.fitnessEvaluations);
  if (Config.algorithm == Config.Algorithm.HYBRID_GP) {
    System.out.println("String_Node_Str" + psi.getNrOfRequests() + "String_Node_Str"+ GPUtilities.crossover+ "String_Node_Str"+ GPUtilities.mutation+ "String_Node_Str"+ GPUtilities.hillClimbing+ "String_Node_Str");
  }
  System.out.println();
  printStatistics(fittestIndividual);
  System.out.println(fittestIndividual.getScore());
  if (betterValueFoundInPsiCache) {
    System.out.println("String_Node_Str");
    System.out.println(bestConcept);
    int misClassifications=bestScore.getNotCoveredPositives().size() + bestScore.getCoveredNegatives().size();
    System.out.println("String_Node_Str" + misClassifications + "String_Node_Str"+ bestConcept.getLength());
  }
}

Fixed version (ground truth):
public void start(){
  psi=new Psi(learningProblem);
  System.out.println();
  System.out.println("String_Node_Str");
  System.out.println();
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + algorithmType);
  System.out.print("String_Node_Str" + selectionType);
  if (elitism)   System.out.println("String_Node_Str");
 else   System.out.println();
  System.out.println("String_Node_Str" + numberOfIndividuals);
  if (algorithmType == AlgorithmType.STEADY_STATE)   System.out.println("String_Node_Str" + numberOfSelectedIndividuals);
  System.out.println("String_Node_Str" + df.format(crossoverProbability * 100) + "String_Node_Str");
  System.out.println("String_Node_Str" + df.format(mutationProbability * 100) + "String_Node_Str");
  System.out.println("String_Node_Str" + df.format(hillClimbingProbability * 100) + "String_Node_Str");
  System.out.println("String_Node_Str" + df.format(refinementProbability * 100) + "String_Node_Str");
  System.out.println("String_Node_Str" + postConvergenceGenerations);
  System.out.println();
  individuals=new Program[numberOfIndividuals];
  if (algorithmType == AlgorithmType.GENERATIONAL) {
    if (elitism) {
      numberOfSelectedIndividuals=numberOfIndividuals - 1;
      if (numberOfSelectedIndividuals % 2 == 1)       error("String_Node_Str" + "String_Node_Str");
    }
 else {
      numberOfSelectedIndividuals=numberOfIndividuals;
      if (numberOfSelectedIndividuals % 2 == 1)       error("String_Node_Str" + "String_Node_Str");
    }
  }
  int numberOfNewIndividuals;
  if (elitism)   numberOfNewIndividuals=numberOfSelectedIndividuals + 1;
 else   numberOfNewIndividuals=numberOfSelectedIndividuals;
  if (numberOfIndividuals < 2)   error("String_Node_Str");
  if (numberOfSelectedIndividuals % 2 == 1)   error("String_Node_Str");
  if ((numberOfSelectedIndividuals < 2) || (numberOfSelectedIndividuals > numberOfIndividuals))   error("String_Node_Str" + numberOfIndividuals);
  fitnessComparator=new Comparator<Program>(){
    public int compare(    Program p1,    Program p2){
      double diff=p1.getFitness() - p2.getFitness();
      if (diff > 0)       return 1;
 else       if (diff < 0)       return -1;
 else       return 0;
    }
  }
;
  startTime=System.nanoTime();
  createIndividuals();
  fittestIndividual=getFittestIndividual();
  fittestIndividualGeneration=0;
  System.out.println("String_Node_Str");
  printStatistics(fittestIndividual);
  int[] selectedIndividuals=new int[numberOfSelectedIndividuals];
  Program[] newIndividuals=new Program[numberOfNewIndividuals];
  Program[] tmp=new Program[2];
  int generation=0;
  do {
    if (selectionType == SelectionType.RANK_SELECTION || algorithmType == AlgorithmType.STEADY_STATE)     Arrays.sort(individuals,fitnessComparator);
    boolean showIndividuals=false;
    if (showIndividuals) {
      System.out.println("String_Node_Str" + generation);
      for (      Program p : individuals) {
        System.out.println(p.getFitness() + "String_Node_Str" + p.getTree());
      }
      System.out.println("String_Node_Str");
    }
    selectedIndividuals=selectIndividuals(generation);
    for (int i=0; i < numberOfSelectedIndividuals; i++) {
      double rand=Math.random();
      double crossoverBoundary=crossoverProbability;
      double mutationBoundary=crossoverBoundary + mutationProbability;
      double hillClimbingBoundary=mutationBoundary + hillClimbingProbability;
      double refinementBoundary=hillClimbingBoundary + refinementProbability;
      if (rand < crossoverBoundary && i + 1 != numberOfSelectedIndividuals) {
        tmp=GPUtilities.crossover(learningProblem,individuals[selectedIndividuals[i]],individuals[selectedIndividuals[i + 1]]);
        newIndividuals[i]=tmp[0];
        newIndividuals[i + 1]=tmp[1];
        i++;
      }
 else       if (rand >= crossoverBoundary && rand < mutationBoundary) {
        newIndividuals[i]=GPUtilities.mutation(learningProblem,individuals[selectedIndividuals[i]]);
      }
 else       if (rand >= mutationBoundary && rand < hillClimbingBoundary) {
        newIndividuals[i]=GPUtilities.hillClimbing(learningProblem,individuals[selectedIndividuals[i]]);
      }
 else       if (rand >= hillClimbingBoundary && rand < refinementBoundary) {
        newIndividuals[i]=psi.applyOperator(individuals[selectedIndividuals[i]]);
      }
 else {
        newIndividuals[i]=individuals[selectedIndividuals[i]];
      }
    }
    Program chr=getFittestIndividual();
    if (chr.getFitness() > fittestIndividual.getFitness()) {
      fittestIndividual=chr;
      fittestIndividualGeneration=generation;
    }
    if (elitism)     newIndividuals[numberOfNewIndividuals - 1]=fittestIndividual;
    if (algorithmType == AlgorithmType.STEADY_STATE)     System.arraycopy(newIndividuals,0,individuals,0,numberOfNewIndividuals);
 else     System.arraycopy(newIndividuals,0,individuals,0,numberOfIndividuals);
    if (generation % 5 == 0) {
      System.out.println("String_Node_Str" + generation);
      printStatistics(fittestIndividual);
    }
    for (int i=0; i < numberOfIndividuals; i++) {
      if (individuals[i].getTree().getLength() > Config.GP.maxConceptLength) {
        System.out.println("String_Node_Str" + Config.GP.maxConceptLength + "String_Node_Str");
        individuals[i]=GPUtilities.createProgram(learningProblem,new Top());
      }
    }
    generation++;
  }
 while ((useFixedNumberOfGenerations && generation < generations) || (!useFixedNumberOfGenerations && (generation - fittestIndividualGeneration < postConvergenceGenerations)));
  long endTime=System.nanoTime();
  bestScore=fittestIndividual.getScore();
  bestConcept=fittestIndividual.getTree();
  boolean betterValueFoundInPsiCache=false;
  double bestValue=bestScore.getScore();
  if (Config.algorithm == Config.Algorithm.HYBRID_GP) {
    Set<Entry<Concept,Score>> entrySet=psi.evalCache.entrySet();
    for (    Entry<Concept,Score> entry : entrySet) {
      Score tmpScore=entry.getValue();
      Concept c=entry.getKey();
      tmpScore=tmpScore.getModifiedLengthScore(c.getLength());
      double tmpScoreValue=tmpScore.getScore();
      if (tmpScoreValue > bestValue) {
        bestValue=tmpScoreValue;
        betterValueFoundInPsiCache=true;
        bestScore=tmpScore;
        bestConcept=c;
      }
    }
  }
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + generation);
  System.out.println("String_Node_Str" + fittestIndividualGeneration + "String_Node_Str");
  System.out.println("String_Node_Str" + Helper.prettyPrintNanoSeconds(endTime - startTime));
  System.out.println("String_Node_Str" + GPUtilities.fitnessEvaluations);
  if (Config.algorithm == Config.Algorithm.HYBRID_GP) {
    System.out.println("String_Node_Str" + psi.getNrOfRequests() + "String_Node_Str"+ GPUtilities.crossover+ "String_Node_Str"+ GPUtilities.mutation+ "String_Node_Str"+ GPUtilities.hillClimbing+ "String_Node_Str");
  }
  System.out.println();
  printStatistics(fittestIndividual);
  System.out.println(fittestIndividual.getScore());
  if (betterValueFoundInPsiCache) {
    System.out.println("String_Node_Str");
    System.out.println(bestConcept);
    int misClassifications=bestScore.getNotCoveredPositives().size() + bestScore.getCoveredNegatives().size();
    System.out.println("String_Node_Str" + misClassifications + "String_Node_Str"+ bestConcept.getLength());
  }
}