Program: 131310
Project: 131310
Buggy source:
public void compareErmaMessagesWithExplicitTreeFactor(Algebra s,boolean normalizeMessages,boolean makeLoopy){
  ErmaBpPrm prm=new ErmaBpPrm();
  prm.s=s;
  prm.updateOrder=BpUpdateOrder.PARALLEL;
  prm.maxIterations=1;
  prm.normalizeMessages=normalizeMessages;
  FactorGraph fgExpl=get2WordSentFactorGraph(true,makeLoopy);
  ErmaBp bpExpl=new ErmaBp(fgExpl,prm);
  bpExpl.forward();
  FactorGraph fgDp=get2WordSentFactorGraph(false,makeLoopy);
  ErmaBp bpDp=new ErmaBp(fgDp,prm);
  bpDp.forward();
  System.out.println("String_Node_Str");
  assertEqualMessages(fgExpl,bpExpl.getMessages(),bpDp.getMessages());
  System.out.println("String_Node_Str");
  assertEqualVarTensors(bpExpl.getOutput().varBeliefs,bpDp.getOutput().varBeliefs);
  assertEqualVarTensors(bpExpl.getOutput().facBeliefs,bpDp.getOutput().facBeliefs);
  System.out.println("String_Node_Str" + bpExpl.getPartition());
  System.out.println("String_Node_Str" + bpDp.getPartition());
  assertEquals(bpExpl.getLogPartition(),bpDp.getLogPartition(),1e-10);
  for (int v=0; v < fgDp.getNumVars(); v++) {
    LinkVar link=(LinkVar)fgDp.getVar(v);
    double adj=0.0;
    if ((link.getParent() == -1 && link.getChild() == 1) || (link.getParent() == 1 && link.getChild() == 0)) {
      adj=1.0;
    }
    bpExpl.getOutputAdj().varBeliefs[v].setValue(LinkVar.TRUE,adj);
    bpDp.getOutputAdj().varBeliefs[v].setValue(LinkVar.TRUE,adj);
  }
  bpExpl.backward();
  bpDp.backward();
  System.out.println("String_Node_Str");
  assertEqualMessages(fgExpl,bpExpl.getMessagesAdj(),bpDp.getMessagesAdj());
  assertEqualVarTensors(bpExpl.getPotentialsAdj(),bpDp.getPotentialsAdj());
}

Fixed version (ground truth):
public void compareErmaMessagesWithExplicitTreeFactor(Algebra s,boolean normalizeMessages,boolean makeLoopy){
  ErmaBpPrm prm=new ErmaBpPrm();
  prm.s=s;
  prm.updateOrder=BpUpdateOrder.PARALLEL;
  prm.maxIterations=1;
  prm.normalizeMessages=normalizeMessages;
  FactorGraph fgExpl=get2WordSentFactorGraph(true,makeLoopy);
  ErmaBp bpExpl=new ErmaBp(fgExpl,prm);
  bpExpl.forward();
  FactorGraph fgDp=get2WordSentFactorGraph(false,makeLoopy);
  ErmaBp bpDp=new ErmaBp(fgDp,prm);
  bpDp.forward();
  System.out.println("String_Node_Str");
  assertEqualMessages(fgExpl,bpExpl.getMessages(),bpDp.getMessages());
  System.out.println("String_Node_Str");
  assertEqualVarTensors(bpExpl.getOutput().varBeliefs,bpDp.getOutput().varBeliefs);
  assertEqualVarTensors(bpExpl.getOutput().facBeliefs,bpDp.getOutput().facBeliefs);
  System.out.println("String_Node_Str" + bpExpl.getPartition());
  System.out.println("String_Node_Str" + bpDp.getPartition());
  assertEquals(bpExpl.getLogPartition(),bpDp.getLogPartition(),1e-10);
  for (int v=0; v < fgDp.getNumVars(); v++) {
    LinkVar link=(LinkVar)fgDp.getVar(v);
    double adj=0.0;
    if ((link.getParent() == -1 && link.getChild() == 1) || (link.getParent() == 1 && link.getChild() == 0)) {
      adj=1.0;
    }
    bpExpl.getOutputAdj().varBeliefs[v].setValue(LinkVar.TRUE,adj);
    bpDp.getOutputAdj().varBeliefs[v].setValue(LinkVar.TRUE,adj);
  }
  System.out.println("String_Node_Str");
  bpExpl.backward();
  System.out.println("String_Node_Str");
  bpDp.backward();
  System.out.println("String_Node_Str");
  assertEqualMessages(fgExpl,bpExpl.getMessagesAdj(),bpDp.getMessagesAdj());
  assertEqualVarTensors(bpExpl.getPotentialsAdj(),bpDp.getPotentialsAdj());
}