Program: 131480
Project: 131480
Buggy source:
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() : FastMath.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);
        IntDoubleVectorSlice 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() : FastMath.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);
        IntDoubleVectorSlice 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() : FastMath.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);
        FeatureVector fv=ex.getObservationFeatures(a);
        numerator+=model.dot(fts.getTemplateId(f),goldConfig,fv);
      }
 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() : FastMath.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);
        FeatureVector fv=ex.getObservationFeatures(a);
        denominator+=model.dot(fts.getTemplateId(f),goldConfig,fv);
      }
 else {
        throw new UnsupportedFactorTypeException(f);
      }
    }
  }
  infLatPred.clear();
  double ll=numerator - denominator;
  if (ll > MAX_LOG_LIKELIHOOD) {
    log.warn("String_Node_Str" + ll);
  }
  return ll;
}