Program: 9732
Project: 9732
Buggy source:
public CrossValidation(File file,int folds,boolean leaveOneOut,LearningAlgorithm la){
  DecimalFormat df=new DecimalFormat();
  ComponentManager cm=ComponentManager.getInstance();
  Start start=null;
  try {
    start=new Start(file);
  }
 catch (  ComponentInitException e) {
    e.printStackTrace();
  }
catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  ParseException e) {
    e.printStackTrace();
  }
  LearningProblem lp=start.getLearningProblem();
  List<Set<Individual>> trainingSetsPos=new LinkedList<Set<Individual>>();
  List<Set<Individual>> trainingSetsNeg=new LinkedList<Set<Individual>>();
  List<Set<Individual>> testSetsPos=new LinkedList<Set<Individual>>();
  List<Set<Individual>> testSetsNeg=new LinkedList<Set<Individual>>();
  if (lp instanceof PosNegLP) {
    Set<Individual> posExamples=((PosNegLP)lp).getPositiveExamples();
    List<Individual> posExamplesList=new LinkedList<Individual>(posExamples);
    Collections.shuffle(posExamplesList,new Random(1));
    Set<Individual> negExamples=((PosNegLP)lp).getNegativeExamples();
    List<Individual> negExamplesList=new LinkedList<Individual>(negExamples);
    Collections.shuffle(negExamplesList,new Random(2));
    if (!leaveOneOut && (posExamples.size() < folds && negExamples.size() < folds)) {
      System.out.println("String_Node_Str" + "String_Node_Str");
      System.exit(0);
    }
    if (leaveOneOut) {
      int nrOfExamples=posExamples.size() + negExamples.size();
      for (int i=0; i < nrOfExamples; i++) {
      }
      System.out.println("String_Node_Str");
      System.exit(1);
    }
 else {
      int[] splitsPos=calculateSplits(posExamples.size(),folds);
      int[] splitsNeg=calculateSplits(negExamples.size(),folds);
      for (int i=0; i < folds; i++) {
        Set<Individual> testPos=getTestingSet(posExamplesList,splitsPos,i);
        Set<Individual> testNeg=getTestingSet(negExamplesList,splitsNeg,i);
        testSetsPos.add(i,testPos);
        testSetsNeg.add(i,testNeg);
        trainingSetsPos.add(i,getTrainingSet(posExamples,testPos));
        trainingSetsNeg.add(i,getTrainingSet(negExamples,testNeg));
      }
    }
  }
 else   if (lp instanceof PosOnlyLP) {
    System.out.println("String_Node_Str");
    System.exit(0);
  }
 else {
    System.out.println("String_Node_Str" + lp + "String_Node_Str");
    System.exit(0);
  }
  for (int currFold=0; currFold < folds; currFold++) {
    try {
      start=new Start(file);
    }
 catch (    ComponentInitException e) {
      e.printStackTrace();
    }
catch (    FileNotFoundException e) {
      e.printStackTrace();
    }
catch (    ParseException e) {
      e.printStackTrace();
    }
    lp=start.getLearningProblem();
    Set<String> pos=Datastructures.individualSetToStringSet(trainingSetsPos.get(currFold));
    Set<String> neg=Datastructures.individualSetToStringSet(trainingSetsNeg.get(currFold));
    cm.applyConfigEntry(lp,"String_Node_Str",pos);
    cm.applyConfigEntry(lp,"String_Node_Str",neg);
    la=start.getLearningAlgorithm();
    try {
      lp.init();
      la.init();
    }
 catch (    ComponentInitException e) {
      e.printStackTrace();
    }
    long algorithmStartTime=System.nanoTime();
    la.start();
    long algorithmDuration=System.nanoTime() - algorithmStartTime;
    runtime.addNumber(algorithmDuration / (double)1000000000);
    Description concept=la.getCurrentlyBestDescription();
    ReasonerComponent rs=start.getReasonerComponent();
    Set<Individual> tmp=rs.hasType(concept,testSetsPos.get(currFold));
    Set<Individual> tmp2=Helper.difference(testSetsPos.get(currFold),tmp);
    Set<Individual> tmp3=rs.hasType(concept,testSetsNeg.get(currFold));
    System.out.println("String_Node_Str" + tmp2);
    System.out.println("String_Node_Str" + tmp3);
    int trainingCorrectPosClassified=getCorrectPosClassified(rs,concept,trainingSetsPos.get(currFold));
    int trainingCorrectNegClassified=getCorrectNegClassified(rs,concept,trainingSetsNeg.get(currFold));
    int trainingCorrectExamples=trainingCorrectPosClassified + trainingCorrectNegClassified;
    double trainingAccuracy=100 * ((double)trainingCorrectExamples / (trainingSetsPos.get(currFold).size() + trainingSetsNeg.get(currFold).size()));
    accuracyTraining.addNumber(trainingAccuracy);
    int correctPosClassified=getCorrectPosClassified(rs,concept,testSetsPos.get(currFold));
    int correctNegClassified=getCorrectNegClassified(rs,concept,testSetsNeg.get(currFold));
    int correctExamples=correctPosClassified + correctNegClassified;
    double currAccuracy=100 * ((double)correctExamples / (testSetsPos.get(currFold).size() + testSetsNeg.get(currFold).size()));
    accuracy.addNumber(currAccuracy);
    length.addNumber(concept.getLength());
    System.out.println("String_Node_Str" + currFold + "String_Node_Str"+ file+ "String_Node_Str");
    System.out.println("String_Node_Str" + pos.size() + "String_Node_Str"+ neg.size()+ "String_Node_Str");
    System.out.println("String_Node_Str" + correctPosClassified + "String_Node_Str"+ testSetsPos.get(currFold).size()+ "String_Node_Str"+ correctNegClassified+ "String_Node_Str"+ testSetsNeg.get(currFold).size()+ "String_Node_Str");
    System.out.println("String_Node_Str" + concept);
    System.out.println("String_Node_Str" + df.format(currAccuracy) + "String_Node_Str"+ df.format(trainingAccuracy)+ "String_Node_Str");
    System.out.println("String_Node_Str" + df.format(concept.getLength()));
    System.out.println("String_Node_Str" + df.format(algorithmDuration / (double)1000000000) + "String_Node_Str");
    rs.releaseKB();
    cm.freeAllComponents();
  }
  System.out.println();
  System.out.println("String_Node_Str" + folds + "String_Node_Str"+ file+ "String_Node_Str");
  System.out.println("String_Node_Str" + statOutput(df,runtime,"String_Node_Str"));
  System.out.println("String_Node_Str" + statOutput(df,length,"String_Node_Str"));
  System.out.println("String_Node_Str" + statOutput(df,accuracy,"String_Node_Str"));
  System.out.println("String_Node_Str" + statOutput(df,accuracyTraining,"String_Node_Str"));
}

Fixed version (ground truth):
public CrossValidation(File file,int folds,boolean leaveOneOut,LearningAlgorithm la){
  DecimalFormat df=new DecimalFormat();
  ComponentManager cm=ComponentManager.getInstance();
  Start start=null;
  try {
    start=new Start(file);
  }
 catch (  ComponentInitException e) {
    e.printStackTrace();
  }
catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  org.dllearner.confparser.ParseException e) {
    e.printStackTrace();
  }
  LearningProblem lp=start.getLearningProblem();
  List<Set<Individual>> trainingSetsPos=new LinkedList<Set<Individual>>();
  List<Set<Individual>> trainingSetsNeg=new LinkedList<Set<Individual>>();
  List<Set<Individual>> testSetsPos=new LinkedList<Set<Individual>>();
  List<Set<Individual>> testSetsNeg=new LinkedList<Set<Individual>>();
  if (lp instanceof PosNegLP) {
    Set<Individual> posExamples=((PosNegLP)lp).getPositiveExamples();
    List<Individual> posExamplesList=new LinkedList<Individual>(posExamples);
    Collections.shuffle(posExamplesList,new Random(1));
    Set<Individual> negExamples=((PosNegLP)lp).getNegativeExamples();
    List<Individual> negExamplesList=new LinkedList<Individual>(negExamples);
    Collections.shuffle(negExamplesList,new Random(2));
    if (!leaveOneOut && (posExamples.size() < folds && negExamples.size() < folds)) {
      System.out.println("String_Node_Str" + "String_Node_Str");
      System.exit(0);
    }
    if (leaveOneOut) {
      int nrOfExamples=posExamples.size() + negExamples.size();
      for (int i=0; i < nrOfExamples; i++) {
      }
      System.out.println("String_Node_Str");
      System.exit(1);
    }
 else {
      int[] splitsPos=calculateSplits(posExamples.size(),folds);
      int[] splitsNeg=calculateSplits(negExamples.size(),folds);
      for (int i=0; i < folds; i++) {
        Set<Individual> testPos=getTestingSet(posExamplesList,splitsPos,i);
        Set<Individual> testNeg=getTestingSet(negExamplesList,splitsNeg,i);
        testSetsPos.add(i,testPos);
        testSetsNeg.add(i,testNeg);
        trainingSetsPos.add(i,getTrainingSet(posExamples,testPos));
        trainingSetsNeg.add(i,getTrainingSet(negExamples,testNeg));
      }
    }
  }
 else   if (lp instanceof PosOnlyLP) {
    System.out.println("String_Node_Str");
    System.exit(0);
  }
 else {
    System.out.println("String_Node_Str" + lp + "String_Node_Str");
    System.exit(0);
  }
  for (int currFold=0; currFold < folds; currFold++) {
    try {
      start=new Start(file);
    }
 catch (    ComponentInitException e) {
      e.printStackTrace();
    }
catch (    FileNotFoundException e) {
      e.printStackTrace();
    }
catch (    org.dllearner.confparser.ParseException e) {
      e.printStackTrace();
    }
    lp=start.getLearningProblem();
    Set<String> pos=Datastructures.individualSetToStringSet(trainingSetsPos.get(currFold));
    Set<String> neg=Datastructures.individualSetToStringSet(trainingSetsNeg.get(currFold));
    cm.applyConfigEntry(lp,"String_Node_Str",pos);
    cm.applyConfigEntry(lp,"String_Node_Str",neg);
    la=start.getLearningAlgorithm();
    try {
      lp.init();
      la.init();
    }
 catch (    ComponentInitException e) {
      e.printStackTrace();
    }
    long algorithmStartTime=System.nanoTime();
    la.start();
    long algorithmDuration=System.nanoTime() - algorithmStartTime;
    runtime.addNumber(algorithmDuration / (double)1000000000);
    Description concept=la.getCurrentlyBestDescription();
    ReasonerComponent rs=start.getReasonerComponent();
    Set<Individual> tmp=rs.hasType(concept,testSetsPos.get(currFold));
    Set<Individual> tmp2=Helper.difference(testSetsPos.get(currFold),tmp);
    Set<Individual> tmp3=rs.hasType(concept,testSetsNeg.get(currFold));
    System.out.println("String_Node_Str" + tmp2);
    System.out.println("String_Node_Str" + tmp3);
    int trainingCorrectPosClassified=getCorrectPosClassified(rs,concept,trainingSetsPos.get(currFold));
    int trainingCorrectNegClassified=getCorrectNegClassified(rs,concept,trainingSetsNeg.get(currFold));
    int trainingCorrectExamples=trainingCorrectPosClassified + trainingCorrectNegClassified;
    double trainingAccuracy=100 * ((double)trainingCorrectExamples / (trainingSetsPos.get(currFold).size() + trainingSetsNeg.get(currFold).size()));
    accuracyTraining.addNumber(trainingAccuracy);
    int correctPosClassified=getCorrectPosClassified(rs,concept,testSetsPos.get(currFold));
    int correctNegClassified=getCorrectNegClassified(rs,concept,testSetsNeg.get(currFold));
    int correctExamples=correctPosClassified + correctNegClassified;
    double currAccuracy=100 * ((double)correctExamples / (testSetsPos.get(currFold).size() + testSetsNeg.get(currFold).size()));
    accuracy.addNumber(currAccuracy);
    length.addNumber(concept.getLength());
    System.out.println("String_Node_Str" + currFold + "String_Node_Str"+ file+ "String_Node_Str");
    System.out.println("String_Node_Str" + pos.size() + "String_Node_Str"+ neg.size()+ "String_Node_Str");
    System.out.println("String_Node_Str" + correctPosClassified + "String_Node_Str"+ testSetsPos.get(currFold).size()+ "String_Node_Str"+ correctNegClassified+ "String_Node_Str"+ testSetsNeg.get(currFold).size()+ "String_Node_Str");
    System.out.println("String_Node_Str" + concept);
    System.out.println("String_Node_Str" + df.format(currAccuracy) + "String_Node_Str"+ df.format(trainingAccuracy)+ "String_Node_Str");
    System.out.println("String_Node_Str" + df.format(concept.getLength()));
    System.out.println("String_Node_Str" + df.format(algorithmDuration / (double)1000000000) + "String_Node_Str");
    rs.releaseKB();
    cm.freeAllComponents();
  }
  System.out.println();
  System.out.println("String_Node_Str" + folds + "String_Node_Str"+ file+ "String_Node_Str");
  System.out.println("String_Node_Str" + statOutput(df,runtime,"String_Node_Str"));
  System.out.println("String_Node_Str" + statOutput(df,length,"String_Node_Str"));
  System.out.println("String_Node_Str" + statOutput(df,accuracy,"String_Node_Str"));
  System.out.println("String_Node_Str" + statOutput(df,accuracyTraining,"String_Node_Str"));
}