Program: 21550
Project: 21550
Buggy source:
private void setNodesAndParents() throws ExceptionHugin {
  List<Attribute> atts=new ArrayList<>();
  NodeList huginNodes=this.huginDBN.getNodes();
  int numNodes=huginNodes.size();
  for (int i=0; i < numNodes; i++) {
    Node n=(Node)huginNodes.get(i);
    if (n.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) != 0)     throw new IllegalArgumentException("String_Node_Str");
    if (n.getTemporalMaster() == null) {
      int numStates=(int)((DiscreteChanceNode)n).getNumberOfStates();
      atts.add(new Attribute(i,n.getName(),"String_Node_Str",StateSpaceType.FINITE_SET,numStates));
    }
  }
  Attributes attributes=new Attributes(atts);
  DynamicVariables dynamicVariables=new DynamicVariables(attributes);
  DynamicDAG dynamicDAG=new DynamicDAG(dynamicVariables);
  for (int i=0; i < numNodes; i++) {
    Node huginChild=(Node)huginNodes.get(i);
    if (huginChild.getTemporalMaster() == null) {
      Variable amidstChild=dynamicVariables.getVariableByName(huginChild.getName());
      NodeList huginParents=huginChild.getParents();
      for (int j=0; j < huginParents.size(); j++) {
        Node huginParent=(Node)huginParents.get(j);
        if (huginParent.getTemporalMaster() == null) {
          Variable amidstParent=dynamicVariables.getVariableByName(huginParent.getName());
          dynamicDAG.getParentSetTimeT(amidstChild).addParent(amidstParent);
        }
 else {
          Variable amidstClone=dynamicVariables.getTemporalClone(amidstChild);
          dynamicDAG.getParentSetTimeT(amidstChild).addParent(amidstClone);
        }
      }
    }
  }
  this.amidstDBN=DynamicBayesianNetwork.newDynamicBayesianNetwork(dynamicDAG);
}

Fixed version (ground truth):
private void setNodesAndParents() throws ExceptionHugin {
  List<Attribute> atts=new ArrayList<>();
  NodeList huginNodes=this.huginDBN.getNodes();
  int numNodes=huginNodes.size();
  for (int i=0; i < numNodes; i++) {
    Node n=(Node)huginNodes.get(i);
    if (n.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) != 0)     throw new IllegalArgumentException("String_Node_Str");
    if (n.getTemporalMaster() == null) {
      int numStates=(int)((DiscreteChanceNode)n).getNumberOfStates();
      atts.add(new Attribute(i,n.getName(),"String_Node_Str",StateSpaceType.FINITE_SET,numStates));
    }
  }
  Attributes attributes=new Attributes(atts);
  DynamicVariables dynamicVariables=new DynamicVariables(attributes);
  DynamicDAG dynamicDAG=new DynamicDAG(dynamicVariables);
  for (int i=0; i < numNodes; i++) {
    Node huginChild=(Node)huginNodes.get(i);
    if (huginChild.getTemporalMaster() == null) {
      Variable amidstChild=dynamicVariables.getVariableByName(huginChild.getName());
      NodeList huginParents=huginChild.getParents();
      ArrayList<Integer> multinomialParentsIndexes=new ArrayList();
      for (int j=0; j < huginParents.size(); j++) {
        Node huginParent=huginParents.get(j);
        if (huginParent.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) == 0) {
          multinomialParentsIndexes.add(j);
        }
      }
      Collections.reverse(multinomialParentsIndexes);
      ArrayList<Integer> parentsIndexes=new ArrayList();
      for (int j=0; j < huginParents.size(); j++) {
        Node huginParent=huginParents.get(j);
        if (huginParent.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) == 0) {
          parentsIndexes.add(multinomialParentsIndexes.get(0));
          multinomialParentsIndexes.remove(0);
        }
 else {
          parentsIndexes.add(j);
        }
      }
      for (int j=0; j < huginParents.size(); j++) {
        Node huginParent=(Node)huginParents.get(parentsIndexes.get(j));
        if (huginParent.getTemporalMaster() == null) {
          Variable amidstParent=dynamicVariables.getVariableByName(huginParent.getName());
          dynamicDAG.getParentSetTimeT(amidstChild).addParent(amidstParent);
        }
 else {
          Variable amidstClone=dynamicVariables.getTemporalClone(amidstChild);
          dynamicDAG.getParentSetTimeT(amidstChild).addParent(amidstClone);
        }
      }
    }
  }
  this.amidstDBN=DynamicBayesianNetwork.newDynamicBayesianNetwork(dynamicDAG);
}