Program: 131563
Project: 131563
Buggy source:
public SrlFactorGraph(SrlFactorGraphPrm prm,int n,Set<Integer> knownPreds,List<String> roleStateNames){
  super();
  this.prm=prm;
  this.n=n;
  roleVars=new RoleVar[n][n];
  if (prm.roleStructure == RoleStructure.PREDS_GIVEN) {
    for (    int i : knownPreds) {
      for (int j=0; j < n; j++) {
        if (i == j && !prm.allowPredArgSelfLoops) {
          continue;
        }
        roleVars[i][j]=createRoleVar(i,j,knownPreds,roleStateNames);
      }
    }
  }
 else   if (prm.roleStructure == RoleStructure.ALL_PAIRS) {
    for (int i=0; i < n; i++) {
      for (int j=0; j < n; j++) {
        if (i == j && !prm.allowPredArgSelfLoops) {
          continue;
        }
        roleVars[i][j]=createRoleVar(i,j,knownPreds,roleStateNames);
      }
    }
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + prm.roleStructure);
  }
  if (prm.useProjDepTreeFactor && prm.linkVarType != VarType.OBSERVED) {
    log.trace("String_Node_Str");
    ProjDepTreeFactor treeFactor=new ProjDepTreeFactor(n,prm.linkVarType);
    rootVars=treeFactor.getRootVars();
    childVars=treeFactor.getChildVars();
    addFactor(treeFactor);
  }
 else   if (prm.linkVarType == VarType.OBSERVED || prm.alwaysIncludeLinkVars) {
    log.trace("String_Node_Str");
    rootVars=new LinkVar[n];
    childVars=new LinkVar[n][n];
    for (int i=-1; i < n; i++) {
      for (int j=0; j < n; j++) {
        if (prm.linkVarType == VarType.OBSERVED && roleVars[i][j] == null) {
          continue;
        }
        if (i != j) {
          if (i == -1) {
            rootVars[j]=createLinkVar(i,j);
          }
 else {
            childVars[i][j]=createLinkVar(i,j);
          }
        }
      }
    }
  }
 else {
    rootVars=new LinkVar[n];
    childVars=new LinkVar[n][n];
    log.trace("String_Node_Str");
    prm.unaryFactors=true;
  }
  for (int i=-1; i < n; i++) {
    for (int j=0; j < n; j++) {
      if (i == -1) {
        if (prm.unaryFactors && prm.linkVarType != VarType.OBSERVED && rootVars[j] != null) {
          addFactor(new SrlFactor(new VarSet(rootVars[j]),SrlFactorTemplate.LINK_UNARY));
        }
      }
 else {
        if (prm.unaryFactors && roleVars[i][j] != null) {
          addFactor(new SrlFactor(new VarSet(roleVars[i][j]),SrlFactorTemplate.ROLE_UNARY));
        }
        if (prm.unaryFactors && prm.linkVarType != VarType.OBSERVED && childVars[i][j] != null) {
          addFactor(new SrlFactor(new VarSet(childVars[i][j]),SrlFactorTemplate.LINK_UNARY));
        }
        if (roleVars[i][j] != null && childVars[i][j] != null) {
          addFactor(new SrlFactor(new VarSet(roleVars[i][j],childVars[i][j]),SrlFactorTemplate.LINK_ROLE_BINARY));
        }
      }
    }
  }
}

Fixed version (ground truth):
public SrlFactorGraph(SrlFactorGraphPrm prm,int n,Set<Integer> knownPreds,List<String> roleStateNames){
  super();
  this.prm=prm;
  this.n=n;
  roleVars=new RoleVar[n][n];
  if (prm.roleStructure == RoleStructure.PREDS_GIVEN) {
    for (    int i : knownPreds) {
      for (int j=0; j < n; j++) {
        if (i == j && !prm.allowPredArgSelfLoops) {
          continue;
        }
        roleVars[i][j]=createRoleVar(i,j,knownPreds,roleStateNames);
      }
    }
  }
 else   if (prm.roleStructure == RoleStructure.ALL_PAIRS) {
    for (int i=0; i < n; i++) {
      for (int j=0; j < n; j++) {
        if (i == j && !prm.allowPredArgSelfLoops) {
          continue;
        }
        roleVars[i][j]=createRoleVar(i,j,knownPreds,roleStateNames);
      }
    }
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + prm.roleStructure);
  }
  if (prm.useProjDepTreeFactor && prm.linkVarType != VarType.OBSERVED) {
    log.trace("String_Node_Str");
    ProjDepTreeFactor treeFactor=new ProjDepTreeFactor(n,prm.linkVarType);
    rootVars=treeFactor.getRootVars();
    childVars=treeFactor.getChildVars();
    addFactor(treeFactor);
  }
 else   if (prm.linkVarType == VarType.OBSERVED || prm.alwaysIncludeLinkVars) {
    log.trace("String_Node_Str");
    rootVars=new LinkVar[n];
    childVars=new LinkVar[n][n];
    for (int i=-1; i < n; i++) {
      for (int j=0; j < n; j++) {
        if (prm.linkVarType == VarType.OBSERVED && (i == -1 || roleVars[i][j] == null)) {
          continue;
        }
        if (i != j) {
          if (i == -1) {
            rootVars[j]=createLinkVar(i,j);
          }
 else {
            childVars[i][j]=createLinkVar(i,j);
          }
        }
      }
    }
  }
 else {
    rootVars=new LinkVar[n];
    childVars=new LinkVar[n][n];
    log.trace("String_Node_Str");
    prm.unaryFactors=true;
  }
  for (int i=-1; i < n; i++) {
    for (int j=0; j < n; j++) {
      if (i == -1) {
        if (prm.unaryFactors && prm.linkVarType != VarType.OBSERVED && rootVars[j] != null) {
          addFactor(new SrlFactor(new VarSet(rootVars[j]),SrlFactorTemplate.LINK_UNARY));
        }
      }
 else {
        if (prm.unaryFactors && roleVars[i][j] != null) {
          addFactor(new SrlFactor(new VarSet(roleVars[i][j]),SrlFactorTemplate.ROLE_UNARY));
        }
        if (prm.unaryFactors && prm.linkVarType != VarType.OBSERVED && childVars[i][j] != null) {
          addFactor(new SrlFactor(new VarSet(childVars[i][j]),SrlFactorTemplate.LINK_UNARY));
        }
        if (roleVars[i][j] != null && childVars[i][j] != null) {
          addFactor(new SrlFactor(new VarSet(roleVars[i][j],childVars[i][j]),SrlFactorTemplate.LINK_ROLE_BINARY));
        }
      }
    }
  }
}