Program: 131262
Project: 131262
Buggy source:
/** 
 * Compares marginals and MBR decode for different numbers of BP iterations. Prng.seed(12345); 2 iters vs. 10 iters: Errors: marginals=93 parents=36 5 iters vs. 10 iters: Errors: marginals=14 parents=2 6 iters vs. 10 iters: Errors: marginals=8 parents=2 9 iters vs. 10 iters: Errors: marginals=1 parents=0 Prng.seed(123456789101112l); 2 iters vs. 10 iters: Errors: marginals=94 parents=51 5 iters vs. 10 iters: Errors: marginals=61 parents=23 6 iters vs. 10 iters: Errors: marginals=42 parents=11 9 iters vs. 10 iters: Errors: marginals=35 parents=16
 */
@Test public void testEqualMarginalsAndParentsNumBpIters(){
  AnnoSentenceCollection sents=AnnoSentenceReaderSpeedTest.readPtbYmConllx();
  int numParams=1000000;
  FgModel model=new FgModel(numParams);
  Prng.seed(123456789101112l);
  model.setRandomStandardNormal();
  CorpusStatistics cs=new CorpusStatistics(new CorpusStatisticsPrm());
  cs.init(sents);
  FeatureNames alphabet=new FeatureNames();
  boolean onlyFast=true;
  int s=0;
  int n=0;
  int numSentsWithDiffMargs=0;
  int numSentsWithDiffParents=0;
  Timer t=new Timer();
  t.start();
  for (  AnnoSentence sent : sents) {
    if (sent.size() > 10) {
      continue;
    }
    FactorGraph fg1, fg2;
    ErmaBp bp1, bp2;
    int[] parents1, parents2;
{
      UFgExample ex=get2ndOrderFg(sent,cs,alphabet,numParams,onlyFast);
      fg1=ex.getFgLatPred();
      fg1.updateFromModel(model);
      bp1=DepParseInferenceSpeedTest.runBp(fg1,6);
      DepParseDecoder decode=new DepParseDecoder();
      parents1=decode.decode(bp1,ex,sent);
    }
{
      UFgExample ex=get2ndOrderFg(sent,cs,alphabet,numParams,onlyFast);
      fg2=ex.getFgLatPred();
      fg2.updateFromModel(model);
      bp2=DepParseInferenceSpeedTest.runBp(fg2,10);
      DepParseDecoder decode=new DepParseDecoder();
      parents2=decode.decode(bp2,ex,sent);
    }
    try {
      assertEqualMarginals(fg1,bp1,fg2,bp2,1);
    }
 catch (    AssertionError e) {
      numSentsWithDiffMargs++;
    }
    try {
      assertArrayEquals(parents1,parents2);
    }
 catch (    AssertionError e) {
      numSentsWithDiffParents++;
    }
    n+=sent.size();
    if (s++ % 1 == 0) {
      t.stop();
      System.out.println(String.format("String_Node_Str",s,n,n / t.totSec()));
      t.start();
    }
    if (s > 102) {
      break;
    }
  }
  t.stop();
  System.out.printf("String_Node_Str",numSentsWithDiffMargs,numSentsWithDiffParents);
  System.out.println("String_Node_Str" + t.totSec());
  System.out.println("String_Node_Str" + (sents.getNumTokens() / t.totSec()));
}

Fixed version (ground truth):
/** 
 * Compares marginals and MBR decode for different numbers of BP iterations. Prng.seed(12345); 2 iters vs. 10 iters: Errors: marginals=93 parents=36 5 iters vs. 10 iters: Errors: marginals=14 parents=2 6 iters vs. 10 iters: Errors: marginals=8 parents=2 9 iters vs. 10 iters: Errors: marginals=1 parents=0 Prng.seed(123456789101112l); 2 iters vs. 10 iters: Errors: marginals=94 parents=51 5 iters vs. 10 iters: Errors: marginals=61 parents=23 6 iters vs. 10 iters: Errors: marginals=42 parents=11 9 iters vs. 10 iters: Errors: marginals=35 parents=16
 */
@Test public void testEqualMarginalsAndParentsNumBpIters(){
  AnnoSentenceCollection sents=AnnoSentenceReaderSpeedTest.readPtbYmConllx();
  int numParams=1000000;
  FgModel model=new FgModel(numParams);
  Prng.seed(123456789101112l);
  model.setRandomStandardNormal();
  CorpusStatistics cs=new CorpusStatistics(new CorpusStatisticsPrm());
  cs.init(sents);
  FeatureNames alphabet=new FeatureNames();
  boolean onlyFast=true;
  int s=0;
  int n=0;
  int numSentsWithDiffMargs=0;
  int numSentsWithDiffParents=0;
  Timer t=new Timer();
  t.start();
  for (  AnnoSentence sent : sents) {
    if (sent.size() > 10) {
      continue;
    }
    FactorGraph fg1, fg2;
    ErmaBp bp1, bp2;
    int[] parents1, parents2;
{
      UFgExample ex=get2ndOrderFg(sent,cs,alphabet,numParams,onlyFast);
      fg1=ex.getFgLatPred();
      fg1.updateFromModel(model);
      bp1=DepParseInferenceSpeedTest.runBp(fg1,5);
      DepParseDecoder decode=new DepParseDecoder();
      parents1=decode.decode(bp1,ex,sent);
    }
{
      UFgExample ex=get2ndOrderFg(sent,cs,alphabet,numParams,onlyFast);
      fg2=ex.getFgLatPred();
      fg2.updateFromModel(model);
      bp2=DepParseInferenceSpeedTest.runBp(fg2,10);
      DepParseDecoder decode=new DepParseDecoder();
      parents2=decode.decode(bp2,ex,sent);
    }
    try {
      assertEqualMarginals(fg1,bp1,fg2,bp2,1);
    }
 catch (    AssertionError e) {
      numSentsWithDiffMargs++;
    }
    try {
      assertArrayEquals(parents1,parents2);
    }
 catch (    AssertionError e) {
      numSentsWithDiffParents++;
    }
    n+=sent.size();
    if (s++ % 1 == 0) {
      t.stop();
      System.out.println(String.format("String_Node_Str",s,n,n / t.totSec()));
      t.start();
    }
    if (s > 102) {
      break;
    }
  }
  t.stop();
  System.out.printf("String_Node_Str",numSentsWithDiffMargs,numSentsWithDiffParents);
  System.out.println("String_Node_Str" + t.totSec());
  System.out.println("String_Node_Str" + (sents.getNumTokens() / t.totSec()));
}