Program: 131155
Project: 131155
Buggy source:
public static FactorGraph read(BufferedReader in){
  try {
    log.debug("String_Node_Str");
    IntObjectHashMap<Var> vars=new IntObjectHashMap<Var>();
    List<Factor> factors=new ArrayList<>();
    List<String> buffer=new ArrayList<String>();
    int numFactors=Integer.valueOf(readNextLineTrimmed(in,buffer));
    readNextLineTrimmed(in,buffer);
    for (int i=0; i < numFactors; i++) {
      int numVars=Integer.valueOf(readNextLineTrimmed(in,buffer));
      int[] varIds=toIntArray(readNextLineTrimmed(in,buffer));
      if (numVars != varIds.length) {
        String msg=String.format("String_Node_Str",i,numVars,varIds.length);
        throw new IllegalStateException(msg);
      }
      ArrayUtils.reverse(varIds);
      int[] dims=toIntArray(readNextLineTrimmed(in,buffer));
      if (numVars != dims.length) {
        String msg=String.format("String_Node_Str",i,numVars,dims.length);
        throw new IllegalStateException(msg);
      }
      ArrayUtils.reverse(dims);
      VarSet vs=new VarSet();
      for (int v=0; v < numVars; v++) {
        if (!vars.containsKey(varIds[v])) {
          vars.put(varIds[v],new Var(VarType.PREDICTED,dims[v],"String_Node_Str" + varIds[v],null));
        }
        vs.add(vars.get(varIds[v]));
      }
      int[] iv2vs=new int[numVars];
      Arrays.fill(iv2vs,-1);
      for (int v=0; v < vs.size(); v++) {
        iv2vs[v]=vs.indexOf(vars.get(varIds[v]));
      }
      int numNonZeros=Integer.valueOf(readNextLineTrimmed(in,buffer));
      Tensor srcFac=new Tensor(RealAlgebra.getInstance(),dims);
      for (int j=0; j < numNonZeros; j++) {
        String[] pair=whitespace.split(readNextLineTrimmed(in,buffer));
        int idx=Integer.valueOf(pair[0]);
        double val=Double.valueOf(pair[1]);
        srcFac.setValue(idx,val);
      }
      ExplicitFactor dstFac=new ExplicitFactor(vs);
      DimIter iter=new DimIter(dims);
      while (iter.hasNext()) {
        int[] srcIdx=iter.next();
        int[] dstIdx=new int[srcIdx.length];
        for (int v=0; v < srcIdx.length; v++) {
          dstIdx[v]=srcIdx[iv2vs[v]];
        }
        double val=srcFac.get(srcIdx);
        dstFac.set(Math.log(val),dstIdx);
      }
      factors.add(dstFac);
      readNextLineTrimmed(in,buffer);
    }
    in.close();
    log.debug("String_Node_Str");
    FactorGraph fg=new FactorGraph();
    for (    Factor f : factors) {
      fg.addFactor(f);
    }
    return fg;
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public static FactorGraph read(BufferedReader in){
  try {
    log.debug("String_Node_Str");
    IntObjectHashMap<Var> vars=new IntObjectHashMap<Var>();
    List<Factor> factors=new ArrayList<>();
    List<String> buffer=new ArrayList<String>();
    int numFactors=Integer.valueOf(readNextLineTrimmed(in,buffer));
    readNextLineTrimmed(in,buffer);
    for (int i=0; i < numFactors; i++) {
      int numVars=Integer.valueOf(readNextLineTrimmed(in,buffer));
      int[] varIds=toIntArray(readNextLineTrimmed(in,buffer));
      if (numVars != varIds.length) {
        String msg=String.format("String_Node_Str",i,numVars,varIds.length);
        throw new IllegalStateException(msg);
      }
      int[] dims=toIntArray(readNextLineTrimmed(in,buffer));
      if (numVars != dims.length) {
        String msg=String.format("String_Node_Str",i,numVars,dims.length);
        throw new IllegalStateException(msg);
      }
      VarSet vs=new VarSet();
      Var[] varArray=new Var[numVars];
      for (int v=0; v < numVars; v++) {
        if (!vars.containsKey(varIds[v])) {
          Var newVar=new Var(VarType.PREDICTED,dims[v],"String_Node_Str" + varIds[v],null);
          vars.put(varIds[v],newVar);
        }
        Var thisVar=vars.get(varIds[v]);
        if (thisVar.getNumStates() != dims[v]) {
          String msg=String.format("String_Node_Str",varIds[v],thisVar.getNumStates(),dims[v]);
          throw new IllegalStateException(msg);
        }
        varArray[v]=thisVar;
        vs.add(thisVar);
      }
      int numNonZeros=Integer.valueOf(readNextLineTrimmed(in,buffer));
      ExplicitFactor dstFac=new ExplicitFactor(vs);
      dstFac.fill(Double.NEGATIVE_INFINITY);
      for (int j=0; j < numNonZeros; j++) {
        String[] pair=whitespace.split(readNextLineTrimmed(in,buffer));
        int libdaiIx=Integer.valueOf(pair[0]);
        int cix=libDaiIxToConfigId(libdaiIx,dims,varArray,vs);
        System.out.println("String_Node_Str");
        System.out.println(ArrayUtils.toString(varIds));
        System.out.println(ArrayUtils.toString(Tensor.unravelIndexMatlab(libdaiIx,dims)));
        System.out.println("String_Node_Str");
        System.out.println(ArrayUtils.toString(vs.stream().map(v -> v.getName()).toArray()));
        System.out.println(ArrayUtils.toString(Tensor.unravelIndex(cix,vs.getDims())));
        double val=Math.log(Double.valueOf(pair[1]));
        System.out.println(String.format("String_Node_Str",cix,val));
        dstFac.setValue(cix,val);
      }
      factors.add(dstFac);
      readNextLineTrimmed(in,buffer);
    }
    in.close();
    log.debug("String_Node_Str");
    FactorGraph fg=new FactorGraph();
    for (    Factor f : factors) {
      fg.addFactor(f);
    }
    return fg;
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}