Program: 21387
Project: 21387
Buggy source:
public double propagateAndTest(Queue<DataOnMemory<DataInstance>> data,BayesianNetwork bn){
  HashMap<Integer,Multinomial> posteriors=new HashMap<>();
  InferenceAlgorithmForBN vmp=new VMP();
  ArrayList<Prediction> predictions=new ArrayList<>();
  while (!data.isEmpty()) {
    Prediction prediction=null;
    Multinomial posterior=null;
    DataOnMemory<DataInstance> batch=data.poll();
    int currentMonthIndex=(int)batch.getDataInstance(0).getValue(TIME_ID);
    for (    DataInstance instance : batch) {
      int clientID=(int)instance.getValue(SEQUENCE_ID);
      double classValue=instance.getValue(classVariable);
      if (!nonDeterministic && (defaultingClients.get(clientID) != null) && (defaultingClients.get(clientID) - currentMonthIndex >= 12)) {
        prediction=new NominalPrediction(classValue,new double[]{0.0,1.0});
        posterior=new Multinomial(classVariable);
        posterior.setProbabilityOfState(DEFAULTER_VALUE_INDEX,1.0);
        posterior.setProbabilityOfState(NON_DEFAULTER_VALUE_INDEX,0.0);
      }
 else {
        bn.setConditionalDistribution(classVariable_PM,posteriors.get(clientID));
        vmp.setModel(bn);
        double classValue_PM=instance.getValue(classVariable_PM);
        instance.setValue(classVariable,Utils.missingValue());
        instance.setValue(classVariable_PM,Utils.missingValue());
        vmp.setEvidence(instance);
        vmp.runInference();
        posterior=vmp.getPosterior(classVariable);
        instance.setValue(classVariable,classValue);
        instance.setValue(classVariable_PM,classValue_PM);
        if (data.isEmpty()) {
          prediction=new NominalPrediction(classValue,posterior.getProbabilities());
          predictions.add(prediction);
        }
      }
      if (classValue == DEFAULTER_VALUE_INDEX) {
        defaultingClients.putIfAbsent(clientID,currentMonthIndex);
      }
      if (data.isEmpty()) {
        ThresholdCurve thresholdCurve=new ThresholdCurve();
        Instances tcurve=thresholdCurve.getCurve(predictions);
        if (usePRCArea)         return ThresholdCurve.getPRCArea(tcurve);
 else         return ThresholdCurve.getROCArea(tcurve);
      }
      Multinomial multi_PM=posterior.toEFUnivariateDistribution().deepCopy(classVariable_PM).toUnivariateDistribution();
      if (classValue == DEFAULTER_VALUE_INDEX) {
        multi_PM.setProbabilityOfState(DEFAULTER_VALUE_INDEX,1.0);
        multi_PM.setProbabilityOfState(NON_DEFAULTER_VALUE_INDEX,0);
      }
      posteriors.put(clientID,multi_PM);
    }
  }
  throw new UnsupportedOperationException("String_Node_Str");
}

Fixed version (ground truth):
public double propagateAndTest(Queue<DataOnMemory<DataInstance>> data,BayesianNetwork bn){
  HashMap<Integer,Multinomial> posteriors=new HashMap<>();
  InferenceAlgorithmForBN vmp=new VMP();
  ArrayList<Prediction> predictions=new ArrayList<>();
  for (int i=0; i < NbrClients; i++) {
    Multinomial uniform=new Multinomial(classVariable_PM);
    uniform.setProbabilityOfState(DEFAULTER_VALUE_INDEX,0.5);
    uniform.setProbabilityOfState(NON_DEFAULTER_VALUE_INDEX,0.5);
    posteriors.put(i,uniform);
  }
  Iterator<DataOnMemory<DataInstance>> iterator=data.iterator();
  while (iterator.hasNext()) {
    Prediction prediction=null;
    Multinomial posterior=null;
    DataOnMemory<DataInstance> batch=iterator.next();
    int currentMonthIndex=(int)batch.getDataInstance(0).getValue(TIME_ID);
    for (    DataInstance instance : batch) {
      int clientID=(int)instance.getValue(SEQUENCE_ID);
      double classValue=instance.getValue(classVariable);
      if (!nonDeterministic && (defaultingClients.get(clientID) != null) && (defaultingClients.get(clientID) - currentMonthIndex >= 12)) {
        prediction=new NominalPrediction(classValue,new double[]{0.0,1.0});
        posterior=new Multinomial(classVariable);
        posterior.setProbabilityOfState(DEFAULTER_VALUE_INDEX,1.0);
        posterior.setProbabilityOfState(NON_DEFAULTER_VALUE_INDEX,0.0);
      }
 else {
        bn.setConditionalDistribution(classVariable_PM,posteriors.get(clientID));
        vmp.setModel(bn);
        double classValue_PM=instance.getValue(classVariable_PM);
        instance.setValue(classVariable,Utils.missingValue());
        instance.setValue(classVariable_PM,Utils.missingValue());
        vmp.setEvidence(instance);
        vmp.runInference();
        posterior=vmp.getPosterior(classVariable);
        instance.setValue(classVariable,classValue);
        instance.setValue(classVariable_PM,classValue_PM);
        if (!iterator.hasNext()) {
          prediction=new NominalPrediction(classValue,posterior.getProbabilities());
          predictions.add(prediction);
        }
      }
      if (classValue == DEFAULTER_VALUE_INDEX) {
        defaultingClients.putIfAbsent(clientID,currentMonthIndex);
      }
      if (!iterator.hasNext()) {
        ThresholdCurve thresholdCurve=new ThresholdCurve();
        Instances tcurve=thresholdCurve.getCurve(predictions);
        if (usePRCArea)         return ThresholdCurve.getPRCArea(tcurve);
 else         return ThresholdCurve.getROCArea(tcurve);
      }
      Multinomial multi_PM=posterior.toEFUnivariateDistribution().deepCopy(classVariable_PM).toUnivariateDistribution();
      if (classValue == DEFAULTER_VALUE_INDEX) {
        multi_PM.setProbabilityOfState(DEFAULTER_VALUE_INDEX,1.0);
        multi_PM.setProbabilityOfState(NON_DEFAULTER_VALUE_INDEX,0);
      }
      posteriors.put(clientID,multi_PM);
    }
  }
  throw new UnsupportedOperationException("String_Node_Str");
}