Program: 131203
Project: 131203
Buggy source:
public void testPartitionWithAdditionalVariableHelper(Algebra s,boolean normalizeMessages){
  double[] root=new double[]{1,2};
  double[][] child=new double[][]{{0,3},{4,0}};
  FgAndLinks fgl=getFgl(root,child);
  FactorGraph fg=fgl.fg;
  LinkVar[] rootVars=fgl.rootVars;
  LinkVar[][] childVars=fgl.childVars;
  int n=fgl.n;
  Var roleVar=new Var(VarType.PREDICTED,2,"String_Node_Str",Lists.getList("String_Node_Str","String_Node_Str"));
  ExplicitFactor roleFac=new ExplicitFactor(new VarSet(roleVar,childVars[0][1]));
  roleFac.setValue(0,2);
  roleFac.setValue(1,3);
  roleFac.setValue(2,5);
  roleFac.setValue(3,7);
  System.out.println(roleFac);
  roleFac.convertRealToLog();
  fg.addFactor(roleFac);
  ErmaBpPrm prm=new ErmaBpPrm();
  prm.maxIterations=1;
  prm.s=s;
  prm.schedule=BpScheduleType.TREE_LIKE;
  prm.updateOrder=BpUpdateOrder.SEQUENTIAL;
  prm.normalizeMessages=normalizeMessages;
  ErmaBp bp=new ErmaBp(fg,prm);
  bp.run();
  BfsMpSchedule schedule=new BfsMpSchedule(fg);
  System.out.println();
  for (  Object edge : schedule.getOrder()) {
    System.out.println(edge.toString());
  }
  System.out.println();
  for (int i=-1; i < n; i++) {
    for (int j=0; j < n; j++) {
      if (i != j) {
        System.out.format("String_Node_Str",i,j,getExpectedCount(bp,rootVars,childVars,i,j));
      }
    }
  }
  double Z=3 * 3 + 3 * 7 + 8 * 2 + 8 * 5;
  assertEquals(Z,bp.getPartition(),1e-3);
  assertEquals((3 * 3 + 3 * 7) / Z,getExpectedCount(bp,rootVars,childVars,-1,0),1e-3);
  assertEquals((8 * 2 + 8 * 5) / Z,getExpectedCount(bp,rootVars,childVars,1,0),1e-3);
  BruteForceInferencer bf=new BruteForceInferencer(fg,s);
  bf.run();
  ErmaBpForwardTest.assertEqualMarginals(fg,bf,bp,1e-10);
}

Fixed version (ground truth):
public void testPartitionWithAdditionalVariableHelper(Algebra s,boolean normalizeMessages){
  double[] root=new double[]{1,2};
  double[][] child=new double[][]{{0,3},{4,0}};
  FgAndLinks fgl=getFgl(root,child);
  FactorGraph fg=fgl.fg;
  LinkVar[] rootVars=fgl.rootVars;
  LinkVar[][] childVars=fgl.childVars;
  int n=fgl.n;
  Var roleVar=new Var(VarType.PREDICTED,2,"String_Node_Str",Lists.getList("String_Node_Str","String_Node_Str"));
  ExplicitFactor roleFac=new ExplicitFactor(new VarSet(roleVar,childVars[0][1]));
  roleFac.setValue(0,2);
  roleFac.setValue(1,5);
  roleFac.setValue(2,3);
  roleFac.setValue(3,7);
  System.out.println(roleFac);
  roleFac.convertRealToLog();
  fg.addFactor(roleFac);
  ErmaBpPrm prm=new ErmaBpPrm();
  prm.maxIterations=1;
  prm.s=s;
  prm.schedule=BpScheduleType.TREE_LIKE;
  prm.updateOrder=BpUpdateOrder.SEQUENTIAL;
  prm.normalizeMessages=normalizeMessages;
  ErmaBp bp=new ErmaBp(fg,prm);
  bp.run();
  BfsMpSchedule schedule=new BfsMpSchedule(fg);
  System.out.println();
  for (  Object edge : schedule.getOrder()) {
    System.out.println(edge.toString());
  }
  System.out.println();
  for (int i=-1; i < n; i++) {
    for (int j=0; j < n; j++) {
      if (i != j) {
        System.out.format("String_Node_Str",i,j,getExpectedCount(bp,rootVars,childVars,i,j));
      }
    }
  }
  double Z=3 * 3 + 3 * 7 + 8 * 2 + 8 * 5;
  assertEquals(Z,bp.getPartition(),1e-3);
  assertEquals((3 * 3 + 3 * 7) / Z,getExpectedCount(bp,rootVars,childVars,-1,0),1e-3);
  assertEquals((8 * 2 + 8 * 5) / Z,getExpectedCount(bp,rootVars,childVars,1,0),1e-3);
  BruteForceInferencer bf=new BruteForceInferencer(fg,s);
  bf.run();
  ErmaBpForwardTest.assertEqualMarginals(fg,bf,bp,1e-10);
}