Program: 131481
Project: 131481
Buggy source:
private double getMarginalLogLikelihoodForExample(int i){
  FgExample ex=data.get(i);
  FeatureTemplateList fts=data.getTemplates();
  FgInferencer infLat=infLatList.get(i);
  FactorGraph fgLat=ex.updateFgLat(model,infLat.isLogDomain());
  infLat.run();
  double numerator=infLat.isLogDomain() ? infLat.getPartition() : Utilities.log(infLat.getPartition());
  for (int a=0; a < fgLat.getNumFactors(); a++) {
    Factor f=fgLat.getFactor(a);
    if (f.getVars().size() == 0) {
      if (f instanceof ExpFamFactor) {
        int goldConfig=ex.getGoldConfigIdxPred(a);
        double[] params=model.getParams(fts.getTemplateId(f),goldConfig);
        numerator+=ex.getObservationFeatures(a).dot(params);
      }
 else {
        throw new UnsupportedFactorTypeException(f);
      }
    }
  }
  infLat.clear();
  FgInferencer infLatPred=infLatPredList.get(i);
  FactorGraph fgLatPred=ex.updateFgLatPred(model,infLatPred.isLogDomain());
  infLatPred.run();
  double denominator=infLatPred.isLogDomain() ? infLatPred.getPartition() : Utilities.log(infLatPred.getPartition());
  for (int a=0; a < fgLatPred.getNumFactors(); a++) {
    Factor f=fgLatPred.getFactor(a);
    if (f.getVars().size() == 0) {
      if (f instanceof ExpFamFactor) {
        int goldConfig=ex.getGoldConfigIdxPred(a);
        double[] params=model.getParams(fts.getTemplateId(f),goldConfig);
        denominator+=ex.getObservationFeatures(a).dot(params);
      }
 else {
        throw new UnsupportedFactorTypeException(f);
      }
    }
  }
  infLatPred.clear();
  double ll=numerator - denominator;
  if (ll > MAX_LOG_LIKELIHOOD) {
    log.warn("String_Node_Str" + ll);
  }
  return ll;
}

Fixed version (ground truth):
private double getMarginalLogLikelihoodForExample(int i){
  FgExample ex=data.get(i);
  FeatureTemplateList fts=data.getTemplates();
  FgInferencer infLat=getInfLat(ex);
  FactorGraph fgLat=ex.updateFgLat(model,infLat.isLogDomain());
  infLat.run();
  double numerator=infLat.isLogDomain() ? infLat.getPartition() : Utilities.log(infLat.getPartition());
  for (int a=0; a < fgLat.getNumFactors(); a++) {
    Factor f=fgLat.getFactor(a);
    if (f.getVars().size() == 0) {
      if (f instanceof ExpFamFactor) {
        int goldConfig=ex.getGoldConfigIdxPred(a);
        double[] params=model.getParams(fts.getTemplateId(f),goldConfig);
        numerator+=ex.getObservationFeatures(a).dot(params);
      }
 else {
        throw new UnsupportedFactorTypeException(f);
      }
    }
  }
  infLat.clear();
  FgInferencer infLatPred=getInfLatPred(ex);
  FactorGraph fgLatPred=ex.updateFgLatPred(model,infLatPred.isLogDomain());
  infLatPred.run();
  double denominator=infLatPred.isLogDomain() ? infLatPred.getPartition() : Utilities.log(infLatPred.getPartition());
  for (int a=0; a < fgLatPred.getNumFactors(); a++) {
    Factor f=fgLatPred.getFactor(a);
    if (f.getVars().size() == 0) {
      if (f instanceof ExpFamFactor) {
        int goldConfig=ex.getGoldConfigIdxPred(a);
        double[] params=model.getParams(fts.getTemplateId(f),goldConfig);
        denominator+=ex.getObservationFeatures(a).dot(params);
      }
 else {
        throw new UnsupportedFactorTypeException(f);
      }
    }
  }
  infLatPred.clear();
  double ll=numerator - denominator;
  if (ll > MAX_LOG_LIKELIHOOD) {
    log.warn("String_Node_Str" + ll);
  }
  return ll;
}