Program: 144108
Project: 144108
Buggy source:
public static void main(String[] args){
  int errorEstimationMethod=Integer.parseInt(args[0]);
  String filename="String_Node_Str";
  String separator="String_Node_Str";
  double[] classificationThresholds=new double[]{0.1,0.1,0.1,0.1};
  List<boolean[][]> functionOutputs=new ArrayList<>();
  List<boolean[]> trueLabels=new ArrayList<>();
  for (  File file : new File(filename).listFiles()) {
    if (file.isFile()) {
      DomainData data=parseLabeledDataFromCSVFile(file,separator,classificationThresholds);
      functionOutputs.add(data.functionOutputs);
      trueLabels.add(data.trueLabels);
    }
  }
  double[][] errorRates=new double[functionOutputs.size()][];
switch (errorEstimationMethod) {
case 0:
    for (int p=0; p < functionOutputs.size(); p++) {
      int numberOfFunctions=functionOutputs.get(p)[0].length;
      ErrorEstimationData errorEstimationData=new ErrorEstimationData.Builder(Arrays.asList(functionOutputs.get(p)),2,true).build();
      ErrorEstimation errorEstimation=new ErrorEstimation.Builder(errorEstimationData).optimizationSolverType(ErrorEstimationInternalSolver.IP_OPT).build();
      double[] allErrorRates=errorEstimation.solve().getErrorRates().array;
      errorRates[p]=new double[numberOfFunctions];
      System.arraycopy(allErrorRates,0,errorRates[p],0,numberOfFunctions);
    }
  break;
case 1:
ErrorEstimationSimpleGraphicalModel eesgm=new ErrorEstimationSimpleGraphicalModel(functionOutputs,1000);
eesgm.performGibbsSampling();
errorRates=eesgm.getErrorRatesMeans();
break;
case 2:
ErrorEstimationDomainsDPGraphicalModel eeddpgm=new ErrorEstimationDomainsDPGraphicalModel(functionOutputs,100,null);
eeddpgm.performGibbsSampling();
errorRates=eeddpgm.getErrorRatesMeans();
break;
case 3:
ErrorEstimationDomainsDPMixedGraphicalModel eeddpmgm=new ErrorEstimationDomainsDPMixedGraphicalModel(functionOutputs,20000,null);
eeddpmgm.performGibbsSampling();
errorRates=eeddpmgm.getErrorRatesMeans();
break;
case 4:
ErrorEstimationDomainsDPGraphicalModelComplicated eeddpgmc=new ErrorEstimationDomainsDPGraphicalModelComplicated(functionOutputs,1000,null);
eeddpgmc.performGibbsSampling();
errorRates=eeddpgmc.getErrorRatesMeans();
}
double[] mad=new double[functionOutputs.size()];
double madMean=0;
for (int p=0; p < functionOutputs.size(); p++) {
double[] realErrorRates=new double[errorRates[p].length];
for (int i=0; i < trueLabels.get(p).length; i++) {
for (int j=0; j < errorRates[p].length; j++) realErrorRates[j]+=(functionOutputs.get(p)[i][j] != trueLabels.get(p)[i]) ? 1 : 0;
}
mad[p]=0;
for (int j=0; j < errorRates[p].length; j++) {
realErrorRates[j]/=trueLabels.get(p).length;
mad[p]+=Math.abs(errorRates[p][j] - realErrorRates[j]);
}
mad[p]/=errorRates[p].length;
madMean+=mad[p];
System.out.println("String_Node_Str" + p + "String_Node_Str");
System.out.println("String_Node_Str");
System.out.print("String_Node_Str");
for (int j=0; j < realErrorRates.length; j++) if (j != realErrorRates.length - 1) System.out.print(realErrorRates[j] + "String_Node_Str");
 else System.out.print(realErrorRates[j] + "String_Node_Str");
System.out.print("String_Node_Str");
for (int j=0; j < errorRates[p].length; j++) if (j != errorRates[p].length - 1) System.out.print(errorRates[p][j] + "String_Node_Str");
 else System.out.print(errorRates[p][j] + "String_Node_Str");
}
madMean/=functionOutputs.size();
System.out.println("String_Node_Str");
System.out.println("String_Node_Str" + madMean);
System.out.println("String_Node_Str");
}

Fixed version (ground truth):
public static void main(String[] args){
  int errorEstimationMethod=Integer.parseInt(args[0]);
  String filename="String_Node_Str";
  String separator="String_Node_Str";
  double[] classificationThresholds=new double[]{0.1,0.1,0.1,0.1};
  List<boolean[][]> functionOutputs=new ArrayList<>();
  List<boolean[]> trueLabels=new ArrayList<>();
  for (  File file : new File(filename).listFiles()) {
    if (file.isFile()) {
      DomainData data=parseLabeledDataFromCSVFile(file,separator,classificationThresholds,1);
      functionOutputs.add(data.functionOutputs);
      trueLabels.add(data.trueLabels);
    }
  }
  double[][] errorRates=new double[functionOutputs.size()][];
switch (errorEstimationMethod) {
case 0:
    for (int p=0; p < functionOutputs.size(); p++) {
      int numberOfFunctions=functionOutputs.get(p)[0].length;
      ErrorEstimationData errorEstimationData=new ErrorEstimationData.Builder(Arrays.asList(functionOutputs.get(p)),2,true).build();
      ErrorEstimation errorEstimation=new ErrorEstimation.Builder(errorEstimationData).optimizationSolverType(ErrorEstimationInternalSolver.IP_OPT).build();
      double[] allErrorRates=errorEstimation.solve().getErrorRates().array;
      errorRates[p]=new double[numberOfFunctions];
      System.arraycopy(allErrorRates,0,errorRates[p],0,numberOfFunctions);
    }
  break;
case 1:
ErrorEstimationSimpleGraphicalModel eesgm=new ErrorEstimationSimpleGraphicalModel(functionOutputs,20000,100);
eesgm.performGibbsSampling();
errorRates=eesgm.getErrorRatesMeans();
break;
case 2:
ErrorEstimationDomainsDPGraphicalModel eeddpgm=new ErrorEstimationDomainsDPGraphicalModel(functionOutputs,10000,100,0.1);
eeddpgm.performGibbsSampling();
errorRates=eeddpgm.getErrorRatesMeans();
break;
case 3:
ErrorEstimationDomainsDPMixedGraphicalModel eeddpmgm=new ErrorEstimationDomainsDPMixedGraphicalModel(functionOutputs,100000,100,0.1);
eeddpmgm.performGibbsSampling();
errorRates=eeddpmgm.getErrorRatesMeans();
break;
case 4:
ErrorEstimationDomainsDPFinalGraphicalModel eeddpfgm=new ErrorEstimationDomainsDPFinalGraphicalModel(functionOutputs,20000,100,0.1);
eeddpfgm.performGibbsSampling();
errorRates=eeddpfgm.getErrorRatesMeans();
break;
case 5:
ErrorEstimationDomainsDPGraphicalModelComplicated eeddpgmc=new ErrorEstimationDomainsDPGraphicalModelComplicated(functionOutputs,1000,null);
eeddpgmc.performGibbsSampling();
errorRates=eeddpgmc.getErrorRatesMeans();
}
double[] mad=new double[functionOutputs.size()];
double madMean=0;
for (int p=0; p < functionOutputs.size(); p++) {
double[] realErrorRates=new double[errorRates[p].length];
for (int i=0; i < trueLabels.get(p).length; i++) {
for (int j=0; j < errorRates[p].length; j++) realErrorRates[j]+=(functionOutputs.get(p)[i][j] != trueLabels.get(p)[i]) ? 1 : 0;
}
mad[p]=0;
for (int j=0; j < errorRates[p].length; j++) {
realErrorRates[j]/=trueLabels.get(p).length;
mad[p]+=Math.abs(errorRates[p][j] - realErrorRates[j]);
}
mad[p]/=errorRates[p].length;
madMean+=mad[p];
System.out.println("String_Node_Str" + p + "String_Node_Str");
System.out.println("String_Node_Str");
System.out.print("String_Node_Str");
for (int j=0; j < realErrorRates.length; j++) if (j != realErrorRates.length - 1) System.out.print(realErrorRates[j] + "String_Node_Str");
 else System.out.print(realErrorRates[j] + "String_Node_Str");
System.out.print("String_Node_Str");
for (int j=0; j < errorRates[p].length; j++) if (j != errorRates[p].length - 1) System.out.print(errorRates[p][j] + "String_Node_Str");
 else System.out.print(errorRates[p][j] + "String_Node_Str");
}
madMean/=functionOutputs.size();
System.out.println("String_Node_Str");
System.out.println("String_Node_Str" + madMean);
System.out.println("String_Node_Str");
}