Program: 21189
Project: 21189
Buggy source:
public double updateModelWithConceptDrift(DataOnMemory<DataInstance> batch){
  this.plateuStructure.setEvidence(batch.getList());
  if (firstBatch) {
    firstBatch=false;
    this.plateuStructure.runInference();
    posteriorT_1=this.plateuStructure.getPlateauNaturalParameterPosterior();
    this.plateuStructure.updateNaturalParameterPrior(posteriorT_1);
    return this.plateuStructure.getLogProbabilityOfEvidence();
  }
  for (int i=0; i < prior.getNumberOfBaseVectors(); i++) {
    for (int j=0; j < this.hppVal.length; j++) {
      this.ef_TExpQ[i].getNaturalParameters().set(j,this.ef_TExpP.getNaturalParameters().get(j));
    }
    this.ef_TExpQ[i].setUpperInterval(this.ef_TExpP.getUpperInterval());
    this.ef_TExpQ[i].setLowerInterval(this.ef_TExpP.getLowerInterval());
  }
  boolean convergence=false;
  double elbo=Double.NaN;
  double niter=0;
  while (!convergence && niter < 10) {
    double[] lambda=new double[prior.getNumberOfBaseVectors()];
    for (int i=0; i < lambda.length; i++) {
      lambda[i]=this.ef_TExpQ[i].getMomentParameters().get(0);
    }
    CompoundVector newPrior=Serialization.deepCopy(prior);
    for (int i=0; i < lambda.length; i++) {
      newPrior.getVectorByPosition(i).multiplyBy(1 - lambda[i]);
    }
    CompoundVector newPosterior=Serialization.deepCopy(posteriorT_1);
    for (int i=0; i < lambda.length; i++) {
      newPosterior.getVectorByPosition(i).multiplyBy(lambda[i]);
    }
    newPrior.sum(newPosterior);
    this.plateuStructure.updateNaturalParameterPrior(newPrior);
    this.plateuStructure.runInference();
    double newELBO=this.plateuStructure.getLogProbabilityOfEvidence();
    double[] kl_q_p0=new double[this.prior.getNumberOfBaseVectors()];
    int count=0;
    this.plateuStructure.updateNaturalParameterPrior(this.prior);
    for (    Node node : this.plateuStructure.getNonReplictedNodes().collect(Collectors.toList())) {
      Map<Variable,MomentParameters> momentParents=node.getMomentParents();
      kl_q_p0[count]=node.getQDist().kl(node.getPDist().getExpectedNaturalFromParents(momentParents),node.getPDist().getExpectedLogNormalizer(momentParents));
      count++;
    }
    double[] kl_q_pt_1=new double[this.prior.getNumberOfBaseVectors()];
    count=0;
    this.plateuStructure.updateNaturalParameterPrior(this.posteriorT_1);
    for (    Node node : this.plateuStructure.getNonReplictedNodes().collect(Collectors.toList())) {
      Map<Variable,MomentParameters> momentParents=node.getMomentParents();
      kl_q_pt_1[count]=node.getQDist().kl(node.getPDist().getExpectedNaturalFromParents(momentParents),node.getPDist().getExpectedLogNormalizer(momentParents));
      count++;
    }
    for (int i=0; i < ef_TExpQ.length; i++) {
      ef_TExpQ[i].getNaturalParameters().set(0,-kl_q_pt_1[i] + kl_q_p0[i] + this.ef_TExpP.getNaturalParameters().get(0));
      for (int j=1; j < this.hppVal.length; j++) {
        this.ef_TExpQ[i].getNaturalParameters().set(j,this.ef_TExpP.getNaturalParameters().get(j));
      }
      ef_TExpQ[i].fixNumericalInstability();
      ef_TExpQ[i].updateMomentFromNaturalParameters();
      newELBO-=this.ef_TExpQ[i].kl(this.ef_TExpP.getNaturalParameters(),this.ef_TExpP.computeLogNormalizer());
    }
    if (!Double.isNaN(elbo) && newELBO < elbo) {
      new IllegalStateException("String_Node_Str");
    }
    double percentageIncrease=100 * Math.abs((newELBO - elbo) / elbo);
    System.out.println("String_Node_Str" + niter + "String_Node_Str"+ newELBO+ "String_Node_Str"+ elbo+ "String_Node_Str"+ percentageIncrease+ "String_Node_Str"+ lambda[0]);
    if (!Double.isNaN(elbo) && percentageIncrease < this.plateuStructure.getVMP().getThreshold()) {
      convergence=true;
    }
    elbo=newELBO;
    niter++;
  }
  posteriorT_1=this.plateuStructure.getPlateauNaturalParameterPosterior();
  this.plateuStructure.updateNaturalParameterPrior(posteriorT_1);
  return elbo;
}

Fixed version (ground truth):
public double updateModelWithConceptDrift(DataOnMemory<DataInstance> batch){
  this.plateuStructure.setEvidence(batch.getList());
  if (firstBatch) {
    firstBatch=false;
    this.plateuStructure.runInference();
    posteriorT_1=this.plateuStructure.getPlateauNaturalParameterPosterior();
    this.plateuStructure.updateNaturalParameterPrior(posteriorT_1);
    return this.plateuStructure.getLogProbabilityOfEvidence();
  }
  for (int i=0; i < prior.getNumberOfBaseVectors(); i++) {
    for (int j=0; j < this.hppVal.length; j++) {
      this.ef_TExpQ[i].getNaturalParameters().set(j,this.ef_TExpP.getNaturalParameters().get(j));
    }
    this.ef_TExpQ[i].setUpperInterval(this.ef_TExpP.getUpperInterval());
    this.ef_TExpQ[i].setLowerInterval(this.ef_TExpP.getLowerInterval());
    this.ef_TExpQ[i].updateMomentFromNaturalParameters();
  }
  boolean convergence=false;
  double elbo=Double.NaN;
  double niter=0;
  while (!convergence && niter < 10) {
    double[] lambda=new double[prior.getNumberOfBaseVectors()];
    for (int i=0; i < lambda.length; i++) {
      lambda[i]=this.ef_TExpQ[i].getMomentParameters().get(0);
    }
    CompoundVector newPrior=Serialization.deepCopy(prior);
    for (int i=0; i < lambda.length; i++) {
      newPrior.getVectorByPosition(i).multiplyBy(1 - lambda[i]);
    }
    CompoundVector newPosterior=Serialization.deepCopy(posteriorT_1);
    for (int i=0; i < lambda.length; i++) {
      newPosterior.getVectorByPosition(i).multiplyBy(lambda[i]);
    }
    newPrior.sum(newPosterior);
    this.plateuStructure.updateNaturalParameterPrior(newPrior);
    this.plateuStructure.runInference();
    double newELBO=this.plateuStructure.getLogProbabilityOfEvidence();
    double[] kl_q_p0=new double[this.prior.getNumberOfBaseVectors()];
    int count=0;
    this.plateuStructure.updateNaturalParameterPrior(this.prior);
    for (    Node node : this.plateuStructure.getNonReplictedNodes().collect(Collectors.toList())) {
      Map<Variable,MomentParameters> momentParents=node.getMomentParents();
      kl_q_p0[count]=node.getQDist().kl(node.getPDist().getExpectedNaturalFromParents(momentParents),node.getPDist().getExpectedLogNormalizer(momentParents));
      count++;
    }
    double[] kl_q_pt_1=new double[this.prior.getNumberOfBaseVectors()];
    count=0;
    this.plateuStructure.updateNaturalParameterPrior(this.posteriorT_1);
    for (    Node node : this.plateuStructure.getNonReplictedNodes().collect(Collectors.toList())) {
      Map<Variable,MomentParameters> momentParents=node.getMomentParents();
      kl_q_pt_1[count]=node.getQDist().kl(node.getPDist().getExpectedNaturalFromParents(momentParents),node.getPDist().getExpectedLogNormalizer(momentParents));
      count++;
    }
    for (int i=0; i < ef_TExpQ.length; i++) {
      ef_TExpQ[i].getNaturalParameters().set(0,-kl_q_pt_1[i] + kl_q_p0[i] + this.ef_TExpP.getNaturalParameters().get(0));
      for (int j=1; j < this.hppVal.length; j++) {
        this.ef_TExpQ[i].getNaturalParameters().set(j,this.ef_TExpP.getNaturalParameters().get(j));
      }
      ef_TExpQ[i].fixNumericalInstability();
      ef_TExpQ[i].updateMomentFromNaturalParameters();
      newELBO-=this.ef_TExpQ[i].kl(this.ef_TExpP.getNaturalParameters(),this.ef_TExpP.computeLogNormalizer());
    }
    if (!Double.isNaN(elbo) && newELBO < elbo) {
      new IllegalStateException("String_Node_Str");
    }
    double percentageIncrease=100 * Math.abs((newELBO - elbo) / elbo);
    System.out.println("String_Node_Str" + niter + "String_Node_Str"+ newELBO+ "String_Node_Str"+ elbo+ "String_Node_Str"+ percentageIncrease+ "String_Node_Str"+ lambda[0]);
    if (!Double.isNaN(elbo) && percentageIncrease < this.plateuStructure.getVMP().getThreshold()) {
      convergence=true;
    }
    elbo=newELBO;
    niter++;
  }
  posteriorT_1=this.plateuStructure.getPlateauNaturalParameterPosterior();
  this.plateuStructure.updateNaturalParameterPrior(posteriorT_1);
  return elbo;
}