nus-yam/ex-repair huggingface dataset:
Program: 131753
Project: 131753
Buggy source:
public double[][] getRegretCm(){
  try {
    double[][] featCounts=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      featCounts[c]=new double[idm.getNumParams(c)];
    }
    for (    LambdaVar triple : mp.lambdaVars) {
      double frac=cplex.getValue(triple.lambdaVar);
      int s=triple.s;
      int[] sentSol=triple.sentSol;
      for (int i=0; i < sentSol.length; i++) {
        int c=idm.getC(s,i);
        int m=idm.getM(s,i);
        featCounts[c][m]+=sentSol[i] * frac;
      }
    }
    double[][] objVals=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      objVals[c]=cplex.getValues(mp.objVars[c]);
    }
    double[][] regret=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      regret[c]=new double[idm.getNumParams(c)];
      for (int m=0; m < idm.getNumParams(c); m++) {
        regret[c][m]=objVals[c][m] - (logProbs[c][m] * featCounts[c][m]);
        if (!Utilities.gte(regret[c][m],0.0,1e-7)) {
          log.warn(String.format("String_Node_Str",c,m,regret[c][m]));
        }
      }
    }
    return regret;
  }
 catch (  IloException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public double[][] getRegretCm(){
  try {
    double[][] featCounts=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      featCounts[c]=new double[idm.getNumParams(c)];
    }
    for (    LambdaVar triple : mp.lambdaVars) {
      double frac=cplex.getValue(triple.lambdaVar);
      int s=triple.s;
      int[] sentSol=triple.sentSol;
      for (int i=0; i < sentSol.length; i++) {
        int c=idm.getC(s,i);
        int m=idm.getM(s,i);
        featCounts[c][m]+=sentSol[i] * frac;
      }
    }
    double[][] objVals=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      objVals[c]=cplex.getValues(mp.objVars[c]);
    }
    double[][] regret=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      regret[c]=new double[idm.getNumParams(c)];
      for (int m=0; m < idm.getNumParams(c); m++) {
        regret[c][m]=objVals[c][m] - (optimalLogProbs[c][m] * featCounts[c][m]);
        if (!Utilities.gte(regret[c][m],0.0,1e-7)) {
          log.warn(String.format("String_Node_Str",c,m,regret[c][m]));
        }
      }
    }
    return regret;
  }
 catch (  IloException e) {
    throw new RuntimeException(e);
  }
}
Program: 131756
Project: 131756
Buggy source:
public BnBDmvTrainer(double epsilon,DmvBoundsDeltaFactory brancher,DmvRelaxation relax,File tempDir){
  this.epsilon=epsilon;
  this.bnbSolver=new LazyBranchAndBoundSolver();
  this.brancher=brancher;
  if (relax == null) {
    relax=new DmvDantzigWolfeRelaxation(null,100,new CutCountComputer());
  }
  this.relax=relax;
  this.tempDir=tempDir;
}

Fixed version (ground truth):
public BnBDmvTrainer(double epsilon,DmvBoundsDeltaFactory brancher,DmvRelaxation relax,File tempDir){
  this.epsilon=epsilon;
  this.bnbSolver=new LazyBranchAndBoundSolver();
  this.brancher=brancher;
  this.relax=relax;
  this.tempDir=tempDir;
}
Program: 131760
Project: 131760
Buggy source:
@Override public double getStopWeight(Triple<Label,String,Boolean> triple){
  Map<Boolean,Integer> map=stopCounts.get(triple);
  double numStop;
  double numNotStop;
  if (map != null) {
    numStop=Utilities.safeGet(map,Boolean.TRUE);
    numNotStop=Utilities.safeGet(map,Boolean.FALSE);
  }
 else {
    numStop=0;
    numNotStop=0;
  }
  double weight=(numStop + lambda) / (numStop + numNotStop + 2 * lambda);
  return weight;
}

Fixed version (ground truth):
@Override public double getStopWeight(Triple<Label,String,Boolean> triple){
  Map<Boolean,Integer> map=stopCounts.get(triple);
  double numStop;
  double numNotStop;
  if (map != null) {
    numStop=Utilities.safeGet(map,Boolean.TRUE);
    numNotStop=Utilities.safeGet(map,Boolean.FALSE);
  }
 else {
    numStop=0;
    numNotStop=0;
    if (lambda == 0) {
      return 0.5;
    }
  }
  double weight=(numStop + lambda) / (numStop + numNotStop + 2 * lambda);
  return weight;
}
Program: 131761
Project: 131761
Buggy source:
@Override public LabeledMultinomial<Label> getChooseMulti(Pair<Label,String> pair,List<Label> children){
  LabeledMultinomial<Label> mult=new LabeledMultinomial<Label>();
  for (  Label child : children) {
    int c=tagAlphabet.lookupObject(child);
    if (child.equals(WallDepTreeNode.WALL_LABEL)) {
      mult.put(child,0.0);
    }
 else     if (pair.get1().equals(WallDepTreeNode.WALL_LABEL)) {
      mult.put(child,Utilities.exp(dpm.root[c]));
    }
 else {
      int p=tagAlphabet.lookupObject(pair.get1());
      int dir=pair.get2().equals("String_Node_Str") ? Constants.LEFT : Constants.RIGHT;
      int cv=0;
      mult.put(child,Utilities.exp(dpm.child[c][p][dir][cv]));
    }
  }
  return mult;
}

Fixed version (ground truth):
@Override public LabeledMultinomial<Label> getChooseMulti(Pair<Label,String> pair,List<Label> children){
  LabeledMultinomial<Label> mult=new LabeledMultinomial<Label>();
  for (  Label child : children) {
    int c=tagAlphabet.lookupObject(child);
    if (pair.get1().equals(WallDepTreeNode.WALL_LABEL)) {
      mult.put(child,Utilities.exp(dpm.root[c]));
    }
 else {
      int p=tagAlphabet.lookupObject(pair.get1());
      int dir=pair.get2().equals("String_Node_Str") ? Constants.LEFT : Constants.RIGHT;
      int cv=0;
      mult.put(child,Utilities.exp(dpm.child[c][p][dir][cv]));
    }
  }
  return mult;
}
Program: 131762
Project: 131762
Buggy source:
public Model getInstance(Set<Label> vocab,boolean oneRoot){
  DmvModel dmv=new DmvModel();
  for (  Label label : vocab) {
    for (    String lr : leftRight) {
      for (      boolean adj : adjacent) {
        Triple<Label,String,Boolean> triple=new Triple<Label,String,Boolean>(label,lr,adj);
        double weight;
        weight=weightGen.getStopWeight(triple);
        dmv.putStopWeight(triple,weight);
      }
    }
  }
  List<Label> vocabList=new ArrayList<Label>(vocab);
  for (  Label parent : vocabList) {
    for (    String lr : leftRight) {
      Pair<Label,String> pair=new Pair<Label,String>(parent,lr);
      dmv.setChooseWeights(parent,lr,weightGen.getChooseMulti(pair,vocabList));
    }
  }
  if (oneRoot) {
    dmv.putStopWeight(WallDepTreeNode.WALL_LABEL,"String_Node_Str",true,1.0);
    dmv.putStopWeight(WallDepTreeNode.WALL_LABEL,"String_Node_Str",false,1.0);
    dmv.putStopWeight(WallDepTreeNode.WALL_LABEL,"String_Node_Str",true,0.0);
    dmv.putStopWeight(WallDepTreeNode.WALL_LABEL,"String_Node_Str",false,1.0);
  }
  return dmv;
}

Fixed version (ground truth):
public Model getInstance(Set<Label> vocab,boolean oneRoot){
  DmvModel dmv=new DmvModel();
  for (  Label label : vocab) {
    for (    String lr : leftRight) {
      if (label.equals(WallDepTreeNode.WALL_LABEL) && lr.equals("String_Node_Str")) {
        continue;
      }
      for (      boolean adj : adjacent) {
        Triple<Label,String,Boolean> triple=new Triple<Label,String,Boolean>(label,lr,adj);
        double weight;
        weight=weightGen.getStopWeight(triple);
        dmv.putStopWeight(triple,weight);
      }
    }
  }
  List<Label> vocabList=new ArrayList<Label>(vocab);
  List<Label> childList=new ArrayList<Label>(vocabList);
  boolean containedWall=childList.remove(WallDepTreeNode.WALL_LABEL);
  assert(containedWall);
  for (  Label parent : vocabList) {
    for (    String lr : leftRight) {
      if (parent.equals(WallDepTreeNode.WALL_LABEL) && lr.equals("String_Node_Str")) {
        continue;
      }
      Pair<Label,String> pair=new Pair<Label,String>(parent,lr);
      dmv.setChooseWeights(parent,lr,weightGen.getChooseMulti(pair,childList));
    }
  }
  if (oneRoot) {
    dmv.putStopWeight(WallDepTreeNode.WALL_LABEL,"String_Node_Str",true,0.0);
    dmv.putStopWeight(WallDepTreeNode.WALL_LABEL,"String_Node_Str",false,1.0);
  }
  return dmv;
}
Program: 131763
Project: 131763
Buggy source:
private void recursivelyGenerate(ProjDepTreeNode parent){
  sampleChildren(parent,"String_Node_Str");
  sampleChildren(parent,"String_Node_Str");
  for (  DepTreeNode child : parent.getChildren()) {
    recursivelyGenerate((ProjDepTreeNode)child);
  }
}

Fixed version (ground truth):
private void recursivelyGenerate(ProjDepTreeNode parent){
  if (!parent.isWall()) {
    sampleChildren(parent,"String_Node_Str");
  }
  sampleChildren(parent,"String_Node_Str");
  for (  DepTreeNode child : parent.getChildren()) {
    recursivelyGenerate((ProjDepTreeNode)child);
  }
}
Program: 131764
Project: 131764
Buggy source:
public double[][] getRegretCm(){
  try {
    double[][] logProbs=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      logProbs[c]=cplex.getValues(mp.modelParamVars[c]);
    }
    double[][] featCounts=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      featCounts[c]=new double[idm.getNumParams(c)];
    }
    for (    LambdaVar triple : mp.lambdaVars) {
      double frac=cplex.getValue(triple.lambdaVar);
      int s=triple.s;
      int[] sentSol=triple.sentSol;
      for (int i=0; i < sentSol.length; i++) {
        int c=idm.getC(s,i);
        int m=idm.getM(s,i);
        featCounts[c][m]=sentSol[i] * frac;
      }
    }
    double[][] objVals=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      objVals[c]=cplex.getValues(mp.objVars[c]);
    }
    double[][] regret=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      regret[c]=new double[idm.getNumParams(c)];
      for (int m=0; m < idm.getNumParams(c); m++) {
        regret[c][m]=objVals[c][m] - (logProbs[c][m] * featCounts[c][m]);
      }
    }
    return regret;
  }
 catch (  IloException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public double[][] getRegretCm(){
  try {
    double[][] logProbs=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      logProbs[c]=cplex.getValues(mp.modelParamVars[c]);
    }
    double[][] featCounts=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      featCounts[c]=new double[idm.getNumParams(c)];
    }
    for (    LambdaVar triple : mp.lambdaVars) {
      double frac=cplex.getValue(triple.lambdaVar);
      int s=triple.s;
      int[] sentSol=triple.sentSol;
      for (int i=0; i < sentSol.length; i++) {
        int c=idm.getC(s,i);
        int m=idm.getM(s,i);
        featCounts[c][m]+=sentSol[i] * frac;
      }
    }
    double[][] objVals=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      objVals[c]=cplex.getValues(mp.objVars[c]);
    }
    double[][] regret=new double[idm.getNumConds()][];
    for (int c=0; c < idm.getNumConds(); c++) {
      regret[c]=new double[idm.getNumParams(c)];
      for (int m=0; m < idm.getNumParams(c); m++) {
        regret[c][m]=objVals[c][m] - (logProbs[c][m] * featCounts[c][m]);
        assert(Utilities.gte(regret[c][m],0.0));
      }
    }
    return regret;
  }
 catch (  IloException e) {
    throw new RuntimeException(e);
  }
}
Program: 131766
Project: 131766
Buggy source:
private void addParentChildLinksToNodes(){
  checkTree();
  for (int i=0; i < parents.length; i++) {
    NonprojDepTreeNode node=(NonprojDepTreeNode)getNodeByPosition(i);
    node.setParent((NonprojDepTreeNode)getNodeByPosition(parents[i]));
    for (int j=0; j < parents.length; j++) {
      if (parents[j] == i) {
        node.addChild((NonprojDepTreeNode)getNodeByPosition(j));
      }
    }
  }
}

Fixed version (ground truth):
private void addParentChildLinksToNodes(){
  checkTree();
  for (int i=0; i < parents.length; i++) {
    NonprojDepTreeNode child=(NonprojDepTreeNode)getNodeByPosition(i);
    NonprojDepTreeNode parent=(NonprojDepTreeNode)getNodeByPosition(parents[i]);
    child.setParent(parent);
    parent.addChild(child);
  }
}
Program: 131767
Project: 131767
Buggy source:
@Override public void train(SentenceCollection sentences){
  Model bestModel=null;
  double bestLogLikelihood=Double.NEGATIVE_INFINITY;
  for (int r=0; r < numRestarts; r++) {
    trainOnce(sentences);
    if (logLikelihood > bestLogLikelihood) {
      bestLogLikelihood=logLikelihood;
      bestModel=model;
    }
  }
  log.info("String_Node_Str" + bestLogLikelihood);
  model=bestModel;
  logLikelihood=bestLogLikelihood;
}

Fixed version (ground truth):
@Override public void train(SentenceCollection sentences){
  double bestLogLikelihood=Double.NEGATIVE_INFINITY;
  Model bestModel=null;
  C bestCounts=null;
  for (int r=0; r < numRestarts; r++) {
    trainOnce(sentences);
    if (logLikelihood > bestLogLikelihood) {
      bestLogLikelihood=logLikelihood;
      bestModel=model;
      bestCounts=counts;
    }
  }
  log.info("String_Node_Str" + bestLogLikelihood);
  logLikelihood=bestLogLikelihood;
  model=bestModel;
  counts=bestCounts;
}
Program: 131769
Project: 131769
Buggy source:
private boolean addLambdaVar(IloMPModeler cplex,int s,DepTree tree) throws IloException {
  LambdaVar lvTemp=new LambdaVar(null,s,tree.getParents(),null,-1);
  if (mp.lambdaVarSet.contains(lvTemp)) {
    return false;
  }
  int[] sentSol=idm.getSentSol(sentences.get(s),s,tree);
  int numSentVars=idm.getNumSentVars(s);
  IloColumn lambdaCol=cplex.column(mp.objective,0.0);
  IloNumVar lambdaVar;
  if (mp.lambdaSumCons[s] == null) {
    lambdaVar=cplex.numVar(lambdaCol,0.0,Double.MAX_VALUE,String.format("String_Node_Str",s,numLambdas++));
    mp.lambdaSumCons[s]=cplex.addEq(lambdaVar,1.0,"String_Node_Str");
  }
 else {
    lambdaCol=lambdaCol.and(cplex.column(mp.lambdaSumCons[s],1.0));
    lambdaVar=cplex.numVar(lambdaCol,0.0,Double.MAX_VALUE,String.format("String_Node_Str",s,numLambdas++));
  }
  int[] ind=new int[numSentVars * 2];
  double[] val=new double[numSentVars * 2];
  int j=0;
  for (int i=0; i < numSentVars; i++) {
    int c=idm.getC(s,i);
    int m=idm.getM(s,i);
    ind[j]=mp.couplMatrix.getIndex(mp.couplConsLower[c][m]);
    val[j]=bounds.getLb(c,m) * sentSol[i];
    j++;
    ind[j]=mp.couplMatrix.getIndex(mp.couplConsUpper[c][m]);
    val[j]=bounds.getUb(c,m) * sentSol[i];
  }
  int colind=mp.couplMatrix.addColumn(lambdaVar,ind,val);
  LambdaVar lv=new LambdaVar(lambdaVar,s,tree.getParents(),sentSol,colind);
  mp.lambdaVars.add(lv);
  mp.lambdaVarSet.add(lv);
  return true;
}

Fixed version (ground truth):
private boolean addLambdaVar(IloMPModeler cplex,int s,DepTree tree) throws IloException {
  LambdaVar lvTemp=new LambdaVar(null,s,tree.getParents(),null,-1);
  if (mp.lambdaVarSet.contains(lvTemp)) {
    return false;
  }
  int[] sentSol=idm.getSentSol(sentences.get(s),s,tree);
  int numSentVars=idm.getNumSentVars(s);
  IloColumn lambdaCol=cplex.column(mp.objective,0.0);
  IloNumVar lambdaVar;
  if (mp.lambdaSumCons[s] == null) {
    lambdaVar=cplex.numVar(lambdaCol,0.0,Double.MAX_VALUE,String.format("String_Node_Str",s,numLambdas++));
    mp.lambdaSumCons[s]=cplex.addEq(lambdaVar,1.0,"String_Node_Str");
  }
 else {
    lambdaCol=lambdaCol.and(cplex.column(mp.lambdaSumCons[s],1.0));
    lambdaVar=cplex.numVar(lambdaCol,0.0,Double.MAX_VALUE,String.format("String_Node_Str",s,numLambdas++));
  }
  int[] ind=new int[numSentVars * 2];
  double[] val=new double[numSentVars * 2];
  int j=0;
  for (int i=0; i < numSentVars; i++) {
    int c=idm.getC(s,i);
    int m=idm.getM(s,i);
    ind[j]=mp.couplMatrix.getIndex(mp.couplConsLower[c][m]);
    val[j]=bounds.getLb(c,m) * sentSol[i];
    j++;
    ind[j]=mp.couplMatrix.getIndex(mp.couplConsUpper[c][m]);
    val[j]=bounds.getUb(c,m) * sentSol[i];
    j++;
  }
  int colind=mp.couplMatrix.addColumn(lambdaVar,ind,val);
  LambdaVar lv=new LambdaVar(lambdaVar,s,tree.getParents(),sentSol,colind);
  mp.lambdaVars.add(lv);
  mp.lambdaVarSet.add(lv);
  return true;
}
Program: 131770
Project: 131770
Buggy source:
@Test public void testTwo(){
  double epsilon=0.1;
  BnBDmvTrainer trainer=new BnBDmvTrainer(epsilon);
  trainer.setTempDir(new File("String_Node_Str"));
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  trainer.train(sentences);
}

Fixed version (ground truth):
public void testTwo(){
  double epsilon=0.1;
  BnBDmvTrainer trainer=new BnBDmvTrainer(epsilon);
  trainer.setTempDir(new File("String_Node_Str"));
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  trainer.train(sentences);
}
Program: 131772
Project: 131772
Buggy source:
private void applyDelta(DmvBoundsDelta delta){
  try {
    int c=delta.getC();
    int m=delta.getM();
    double origLb=mp.modelParamVars[c][m].getLB();
    double origUb=mp.modelParamVars[c][m].getUB();
    double newLb=origLb;
    double newUb=origUb;
    if (delta.getLu() == Lu.LOWER) {
      newLb=origLb + delta.getDelta();
    }
 else     if (delta.getLu() == Lu.UPPER) {
      newUb=origUb + delta.getDelta();
    }
 else {
      throw new IllegalStateException();
    }
    bounds.set(c,m,newLb,newUb);
    mp.modelParamVars[c][m].setLB(newLb);
    mp.modelParamVars[c][m].setUB(newUb);
    TIntArrayList rowind=new TIntArrayList();
    TIntArrayList colind=new TIntArrayList();
    TDoubleArrayList val=new TDoubleArrayList();
    int lowCmInd=mp.couplMatrix.getIndex(mp.couplConsLower[c][m]);
    int upCmInd=mp.couplMatrix.getIndex(mp.couplConsUpper[c][m]);
    for (    LambdaVar lv : mp.lambdaVars) {
      int i=idm.getSi(lv.s,c,m);
      if (i != -1) {
        rowind.add(lowCmInd);
        colind.add(lv.colind);
        val.add(bounds.getLb(c,m) * lv.sentSol[i]);
        rowind.add(upCmInd);
        colind.add(lv.colind);
        val.add(bounds.getUb(c,m) * lv.sentSol[i]);
      }
    }
    if (rowind.size() > 0) {
      mp.couplMatrix.setNZs(rowind.toNativeArray(),colind.toNativeArray(),val.toNativeArray());
    }
  }
 catch (  IloException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
private void applyDelta(DmvBoundsDelta delta){
  try {
    int c=delta.getC();
    int m=delta.getM();
    double origLb=mp.modelParamVars[c][m].getLB();
    double origUb=mp.modelParamVars[c][m].getUB();
    double newLb=origLb;
    double newUb=origUb;
    if (delta.getLu() == Lu.LOWER) {
      newLb=origLb + delta.getDelta();
    }
 else     if (delta.getLu() == Lu.UPPER) {
      newUb=origUb + delta.getDelta();
    }
 else {
      throw new IllegalStateException();
    }
    assert(newLb <= newUb);
    bounds.set(c,m,newLb,newUb);
    mp.modelParamVars[c][m].setLB(newLb);
    mp.modelParamVars[c][m].setUB(newUb);
    TIntArrayList rowind=new TIntArrayList();
    TIntArrayList colind=new TIntArrayList();
    TDoubleArrayList val=new TDoubleArrayList();
    int lowCmInd=mp.couplMatrix.getIndex(mp.couplConsLower[c][m]);
    int upCmInd=mp.couplMatrix.getIndex(mp.couplConsUpper[c][m]);
    for (    LambdaVar lv : mp.lambdaVars) {
      int i=idm.getSi(lv.s,c,m);
      if (i != -1) {
        rowind.add(lowCmInd);
        colind.add(lv.colind);
        val.add(bounds.getLb(c,m) * lv.sentSol[i]);
        rowind.add(upCmInd);
        colind.add(lv.colind);
        val.add(bounds.getUb(c,m) * lv.sentSol[i]);
      }
    }
    if (rowind.size() > 0) {
      mp.couplMatrix.setNZs(rowind.toNativeArray(),colind.toNativeArray(),val.toNativeArray());
    }
  }
 catch (  IloException e) {
    throw new RuntimeException(e);
  }
}
Program: 131773
Project: 131773
Buggy source:
@Override public List<DmvBoundsDelta> getDmvBounds(DmvProblemNode node){
  DmvBounds origBounds=node.getBounds();
  RelaxedDmvSolution relaxSol=node.getRelaxedSolution();
  double[][] regret=node.getRegretCm();
  IntTuple max=Utilities.getArgmax(regret);
  int c=max.get(0);
  int m=max.get(1);
  String name=node.getIdm().getName(c,m);
  log.info(String.format("String_Node_Str",c,m,name,regret[c][m]));
  return splitAtMidPoint(origBounds,c,m,relaxSol.getLogProbs()[c][m]);
}

Fixed version (ground truth):
@Override public List<DmvBoundsDelta> getDmvBounds(DmvProblemNode node){
  DmvBounds origBounds=node.getBounds();
  double[][] regret=node.getRegretCm();
  IntTuple max=Utilities.getArgmax(regret);
  int c=max.get(0);
  int m=max.get(1);
  String name=node.getIdm().getName(c,m);
  log.info(String.format("String_Node_Str",c,m,name,regret[c][m]));
  return splitHalfProbSpace(origBounds,c,m);
}
Program: 131774
Project: 131774
Buggy source:
public DepTreebank getTreebank(int numTrees){
  DepTreebank treebank=new DepTreebank();
  for (int i=0; i < numTrees; i++) {
    ProjDepTreeNode wall=new ProjDepTreeNode(WallDepTreeNode.WALL_LABEL);
    recursivelyGenerate(wall);
    treebank.add(new DepTree(wall));
  }
  return treebank;
}

Fixed version (ground truth):
public DepTreebank getTreebank(int numTrees){
  DepTreebank treebank=new DepTreebank();
  for (int i=0; i < numTrees; i++) {
    ProjDepTreeNode wall=new ProjWallDepTreeNode();
    recursivelyGenerate(wall);
    treebank.add(new DepTree(wall));
  }
  return treebank;
}
Program: 131775
Project: 131775
Buggy source:
/** 
 * Returns the Process which contains the exit code.
 */
public static Process runProcess(String[] cmdArray,File logFile,File dir){
  try {
    ProcessBuilder pb=new ProcessBuilder(cmdArray);
    pb.redirectErrorStream(true);
    pb.directory(dir);
    Process proc=pb.start();
    if (logFile != null) {
      InputStream inputStream=new BufferedInputStream(proc.getInputStream());
      BufferedOutputStream out=new BufferedOutputStream(new FileOutputStream(logFile));
      int read=0;
      byte[] bytes=new byte[1024];
      while ((read=inputStream.read(bytes)) != -1) {
        out.write(bytes,0,read);
      }
      inputStream.close();
      out.flush();
      out.close();
    }
    proc.waitFor();
    return proc;
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str" + cmdToString(cmdArray) + "String_Node_Str"+ Files.tail(logFile),e);
  }
}

Fixed version (ground truth):
/** 
 * Returns the Process which contains the exit code.
 */
public static Process runProcess(String[] cmdArray,File logFile,File dir){
  try {
    ProcessBuilder pb=new ProcessBuilder(cmdArray);
    pb.redirectErrorStream(true);
    pb.directory(dir);
    Process proc=pb.start();
    if (logFile != null) {
      InputStream inputStream=new BufferedInputStream(proc.getInputStream());
      BufferedOutputStream out=new BufferedOutputStream(new FileOutputStream(logFile));
      int read=0;
      byte[] bytes=new byte[1024];
      while ((read=inputStream.read(bytes)) != -1) {
        out.write(bytes,0,read);
      }
      inputStream.close();
      out.flush();
      out.close();
    }
    proc.waitFor();
    return proc;
  }
 catch (  Exception e) {
    String tail="String_Node_Str";
    try {
      tail=Files.tail(logFile);
    }
 catch (    Throwable t) {
    }
    throw new RuntimeException("String_Node_Str" + cmdToString(cmdArray) + "String_Node_Str"+ tail,e);
  }
}
Program: 131776
Project: 131776
Buggy source:
@Override public DepTree getViterbiParse(Sentence sentence,Model model){
  File tempDir=Files.createTempDir("String_Node_Str",workspace);
  File zimplFile=encode(tempDir,sentence,model);
  ZimplSolver solver=new ZimplSolver(tempDir,ilpSolverFactory.getInstance(tempDir));
  solver.solve(zimplFile);
  Map<String,Double> result=solver.getResult();
  DepTree tree=decode(sentence,result);
  return tree;
}

Fixed version (ground truth):
@Override public DepTree getViterbiParse(Sentence sentence,Model model){
  File tempDir=Files.createTempDir("String_Node_Str",workspace);
  File zimplFile=encode(tempDir,sentence,model);
  ZimplSolver solver=new ZimplSolver(tempDir,ilpSolverFactory.getInstance(tempDir));
  solver.solve(zimplFile);
  Map<String,Double> result=solver.getResult();
  parseWeight=solver.getObjective();
  DepTree tree=decode(sentence,result);
  return tree;
}
Program: 131777
Project: 131777
Buggy source:
@Override public Map<Quadruple<Label,String,Label,String>,Double> getCWDeltas(Map<Triple<Label,String,Label>,Double> chooseWeights){
  Map<Quadruple<Label,String,Label,String>,Double> cwDeltas=new HashMap<Quadruple<Label,String,Label,String>,Double>();
  for (  Entry<Triple<Label,String,Label>,Double> entry : chooseWeights.entrySet()) {
    Label parent=entry.getKey().get1();
    String lr=entry.getKey().get2();
    Label child=entry.getKey().get3();
    double weight=entry.getValue();
    for (int i=-numPerSide; i <= numPerSide; i++) {
      String deltaId="String_Node_Str" + Math.pow(factor,i);
      if (i == 1) {
        deltaId=FixedIntervalDeltaGenerator.IDENTITY_DELTA_ID;
      }
      Quadruple<Label,String,Label,String> key=new Quadruple<Label,String,Label,String>(parent,lr,child,deltaId);
      double newWeight=weight * Math.pow(factor,i);
      if (newWeight <= 1.0 && newWeight >= 0.0) {
        cwDeltas.put(key,newWeight);
      }
    }
  }
  return cwDeltas;
}

Fixed version (ground truth):
@Override public Map<Quadruple<Label,String,Label,String>,Double> getCWDeltas(Map<Triple<Label,String,Label>,Double> chooseWeights){
  Map<Quadruple<Label,String,Label,String>,Double> cwDeltas=super.getCWDeltas(chooseWeights);
  for (  Entry<Triple<Label,String,Label>,Double> entry : chooseWeights.entrySet()) {
    double weight=entry.getValue();
    for (int i=-numPerSide; i <= numPerSide; i++) {
      if (i == 1) {
        continue;
      }
      String deltaId="String_Node_Str" + Math.pow(factor,i);
      Quadruple<Label,String,Label,String> key=getDeltaKey(entry.getKey(),deltaId);
      double newWeight=weight * Math.pow(factor,i);
      if (newWeight <= 1.0 && newWeight >= 0.0) {
        cwDeltas.put(key,newWeight);
      }
    }
  }
  return cwDeltas;
}
Program: 131778
Project: 131778
Buggy source:
@Override public Map<Quadruple<Label,String,Label,String>,Double> getCWDeltas(Map<Triple<Label,String,Label>,Double> chooseWeights){
  Map<Quadruple<Label,String,Label,String>,Double> cwDeltas=new HashMap<Quadruple<Label,String,Label,String>,Double>();
  for (  Entry<Triple<Label,String,Label>,Double> entry : chooseWeights.entrySet()) {
    Label parent=entry.getKey().get1();
    String lr=entry.getKey().get2();
    Label child=entry.getKey().get3();
    double weight=entry.getValue();
    for (int i=-numPerSide; i <= numPerSide; i++) {
      String deltaId="String_Node_Str" + interval * i;
      if (i == 0) {
        deltaId=IDENTITY_DELTA_ID;
      }
      Quadruple<Label,String,Label,String> key=new Quadruple<Label,String,Label,String>(parent,lr,child,deltaId);
      double newWeight=weight + interval * i;
      if (newWeight <= 1.0 && newWeight >= 0.0) {
        cwDeltas.put(key,newWeight);
      }
    }
  }
  return cwDeltas;
}

Fixed version (ground truth):
@Override public Map<Quadruple<Label,String,Label,String>,Double> getCWDeltas(Map<Triple<Label,String,Label>,Double> chooseWeights){
  Map<Quadruple<Label,String,Label,String>,Double> cwDeltas=super.getCWDeltas(chooseWeights);
  for (  Entry<Triple<Label,String,Label>,Double> entry : chooseWeights.entrySet()) {
    double weight=entry.getValue();
    for (int i=-numPerSide; i <= numPerSide; i++) {
      if (i == 0) {
        continue;
      }
      String deltaId="String_Node_Str" + interval * i;
      Quadruple<Label,String,Label,String> key=getDeltaKey(entry.getKey(),deltaId);
      double newWeight=weight + interval * i;
      if (newWeight <= 1.0 && newWeight >= 0.0) {
        cwDeltas.put(key,newWeight);
      }
    }
  }
  return cwDeltas;
}
Program: 131779
Project: 131779
Buggy source:
@Override protected DepTreebank decode(SentenceCollection sentences,Map<String,Double> result){
  Map<String,Integer> cwDeltaCounts=new HashMap<String,Integer>();
  for (  Entry<String,Double> entry : result.entrySet()) {
    String zimplVar=entry.getKey();
    Double value=entry.getValue();
    String[] splits=zimplVarRegex.split(zimplVar);
    String varType=splits[0];
    if (varType.equals("String_Node_Str")) {
      String parentWord=splits[1];
      String lr=splits[2];
      String childWord=splits[3];
      String deltaId=splits[4];
      long longVal=Math.round(value);
      if (longVal == 1) {
        Utilities.increment(cwDeltaCounts,deltaId,1);
      }
    }
  }
  log.debug("String_Node_Str");
  for (  String deltaId : cwDeltaCounts.keySet()) {
    log.debug("String_Node_Str" + deltaId + "String_Node_Str"+ cwDeltaCounts.get(deltaId));
  }
  return super.decode(sentences,result);
}

Fixed version (ground truth):
@Override protected DepTreebank decode(SentenceCollection sentences,Map<String,Double> result){
  Map<String,Integer> cwDeltaCounts=new HashMap<String,Integer>();
  for (  Entry<String,Double> entry : result.entrySet()) {
    String zimplVar=entry.getKey();
    Double value=entry.getValue();
    String[] splits=zimplVarRegex.split(zimplVar);
    String varType=splits[0];
    if (varType.equals("String_Node_Str")) {
      String deltaId=splits[splits.length - 1];
      long longVal=Math.round(value);
      if (longVal == 1) {
        Utilities.increment(cwDeltaCounts,deltaId,1);
      }
    }
  }
  log.debug("String_Node_Str");
  for (  String deltaId : cwDeltaCounts.keySet()) {
    log.debug("String_Node_Str" + deltaId + "String_Node_Str"+ cwDeltaCounts.get(deltaId));
  }
  return super.decode(sentences,result);
}
Program: 131781
Project: 131781
Buggy source:
@Override public void solve(File lpFile){
  result=null;
  File solFile=new File(tempDir,lpFile.getName().replace("String_Node_Str","String_Node_Str"));
  String[] cmdArray=new String[]{gurobiBinary,"String_Node_Str" + solFile.getAbsolutePath(),"String_Node_Str" + numThreads,"String_Node_Str" + tempDir.getAbsolutePath(),"String_Node_Str" + workMemMegs / 1024.0,lpFile.getAbsolutePath()};
  File gurobiLog=new File(tempDir,"String_Node_Str");
  Command.runCommand(cmdArray,gurobiLog,tempDir);
  Matcher objValMatcher=Files.getFirstMatch(gurobiLog,Pattern.compile("String_Node_Str"));
  objective=Double.parseDouble(objValMatcher.group(1));
  try {
    result=readGurobiSol(solFile);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
@Override public boolean solve(File lpFile){
  result=null;
  File solFile=new File(tempDir,lpFile.getName().replace("String_Node_Str","String_Node_Str"));
  String[] cmdArray=new String[]{gurobiBinary,"String_Node_Str" + solFile.getAbsolutePath(),"String_Node_Str" + numThreads,"String_Node_Str" + tempDir.getAbsolutePath(),"String_Node_Str" + workMemMegs / 1024.0,lpFile.getAbsolutePath()};
  File gurobiLog=new File(tempDir,"String_Node_Str");
  Command.runCommand(cmdArray,gurobiLog,tempDir);
  if (!Files.fileContains(gurobiLog,"String_Node_Str")) {
    return false;
  }
  Matcher objValMatcher=Files.getFirstMatch(gurobiLog,Pattern.compile("String_Node_Str"));
  objective=Double.parseDouble(objValMatcher.group(1));
  try {
    result=readGurobiSol(solFile);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
  return true;
}
Program: 131783
Project: 131783
Buggy source:
void solve(File lpFile);

Fixed version (ground truth):
boolean solve(File lpFile);
Program: 131784
Project: 131784
Buggy source:
@Override public void solve(File lpFile){
  result=new HashMap<String,Double>();
  File gurobiLog=new File(tempDir,"String_Node_Str");
  try {
    GRBEnv env=new GRBEnv(gurobiLog.getAbsolutePath());
    GRBModel model=new GRBModel(env,lpFile.getAbsolutePath());
    model.optimize();
    objective=model.get(GRB.DoubleAttr.ObjVal);
    for (    GRBVar var : model.getVars()) {
      String gurobiVar=var.get(GRB.StringAttr.VarName);
      double value=var.get(GRB.DoubleAttr.X);
      result.put(gurobiVar,value);
    }
  }
 catch (  GRBException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
@Override public boolean solve(File lpFile){
  result=new HashMap<String,Double>();
  File gurobiLog=new File(tempDir,"String_Node_Str");
  try {
    GRBEnv env=new GRBEnv(gurobiLog.getAbsolutePath());
    GRBModel model=new GRBModel(env,lpFile.getAbsolutePath());
    model.optimize();
    if (model.get(GRB.IntAttr.Status) != GRB.OPTIMAL) {
      return false;
    }
    objective=model.get(GRB.DoubleAttr.ObjVal);
    for (    GRBVar var : model.getVars()) {
      String gurobiVar=var.get(GRB.StringAttr.VarName);
      double value=var.get(GRB.DoubleAttr.X);
      result.put(gurobiVar,value);
    }
    return true;
  }
 catch (  GRBException e) {
    throw new RuntimeException(e);
  }
}
Program: 131785
Project: 131785
Buggy source:
private void runZimpl(String type,int verbosity){
  String[] cmdArray=new String[]{zimplBinary,"String_Node_Str","String_Node_Str","String_Node_Str",outputPrefix,"String_Node_Str",type,"String_Node_Str" + String.valueOf(verbosity),zimplFile.getAbsolutePath()};
  File zimplLog=new File(tempDir,"String_Node_Str");
  Command.runCommand(cmdArray,zimplLog,tempDir);
}

Fixed version (ground truth):
private void runZimpl(String type,int verbosity){
  String[] cmdArray=new String[]{zimplBinary,"String_Node_Str","String_Node_Str","String_Node_Str",outputPrefix,"String_Node_Str",type,"String_Node_Str","String_Node_Str","String_Node_Str" + String.valueOf(verbosity),zimplFile.getAbsolutePath()};
  File zimplLog=new File(tempDir,"String_Node_Str");
  Command.runCommand(cmdArray,zimplLog,tempDir);
}
Program: 131786
Project: 131786
Buggy source:
public void solve(File zimplFile){
  result=new HashMap<String,Double>();
  ZimplRunner zimplRunner=new ZimplRunner(zimplFile,tempDir);
  zimplRunner.runZimpl();
  File lpFile=zimplRunner.getLpFile();
  File tblFile=zimplRunner.getTblFile();
  ilpSolver.solve(lpFile);
  objective=ilpSolver.getObjective();
  Map<String,Double> solMap=ilpSolver.getResult();
  try {
    Map<String,String> tblMap=readTblMap(tblFile);
    for (    Entry<String,Double> entry : solMap.entrySet()) {
      String gurobiVar=entry.getKey();
      Double value=entry.getValue();
      value=value == -0.0 ? 0.0 : value;
      String zimplVar=tblMap.get(gurobiVar);
      result.put(zimplVar,value);
    }
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void solve(File zimplFile){
  result=new HashMap<String,Double>();
  ZimplRunner zimplRunner=new ZimplRunner(zimplFile,tempDir);
  zimplRunner.runZimpl();
  File lpFile=zimplRunner.getLpFile();
  File tblFile=zimplRunner.getTblFile();
  if (!ilpSolver.solve(lpFile)) {
    throw new RuntimeException("String_Node_Str");
  }
  objective=ilpSolver.getObjective();
  Map<String,Double> solMap=ilpSolver.getResult();
  try {
    Map<String,String> tblMap=readTblMap(tblFile);
    for (    Entry<String,Double> entry : solMap.entrySet()) {
      String gurobiVar=entry.getKey();
      Double value=entry.getValue();
      value=value == -0.0 ? 0.0 : value;
      String zimplVar=tblMap.get(gurobiVar);
      result.put(zimplVar,value);
    }
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 131787
Project: 131787
Buggy source:
public static DepTreebank getParses(Model model,SentenceCollection sentences,IlpFormulation formulation,DeltaGenerator deltaGen,double expectedParseWeight){
  IlpSolverFactory factory=new IlpSolverFactory(IlpSolverId.GUROBI_CL,2,128);
  IlpViterbiParserWithDeltas parser=new IlpViterbiParserWithDeltas(formulation,factory,deltaGen);
  DepTreebank trees=parser.getViterbiParse(sentences,model);
  for (  DepTree depTree : trees) {
    System.out.println(depTree);
  }
  Assert.assertEquals(expectedParseWeight,parser.getLastParseWeight(),1E-13);
  return trees;
}

Fixed version (ground truth):
public static DepTreebank getParses(Model model,SentenceCollection sentences,IlpFormulation formulation,DeltaGenerator deltaGen,double expectedParseWeight){
  IlpSolverFactory factory=new IlpSolverFactory(IlpSolverId.GUROBI_CL,2,128);
  IlpViterbiParserWithDeltas parser=new MockIlpViterbiParserWithDeltas(formulation,factory,deltaGen);
  DepTreebank trees=parser.getViterbiParse(sentences,model);
  for (  DepTree depTree : trees) {
    System.out.println(depTree);
  }
  Assert.assertEquals(expectedParseWeight,parser.getLastParseWeight(),1E-13);
  return trees;
}
Program: 131788
Project: 131788
Buggy source:
@Test public void testProjAndNonprojDeltaParsers(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.add(IlpViterbiParserTest.getSentenceFromString("String_Node_Str"));
  sentences.add(IlpViterbiParserTest.getSentenceFromString("String_Node_Str"));
  ModelFactory modelFactory=new DmvModelFactory(new RandomWeightGenerator(lambda));
  Model model=modelFactory.getInstance(sentences);
  double expectedParseWeight;
  DeltaGenerator deltaGen;
  expectedParseWeight=-140.25513195;
  deltaGen=new FixedIntervalDeltaGenerator(0.1,1);
  DepTreebank npFlowTrees=getParses(model,sentences,IlpFormulation.FLOW_NONPROJ,deltaGen,expectedParseWeight);
  expectedParseWeight=-171.80570295;
  deltaGen=new FactorDeltaGenerator(1.1,2);
  DepTreebank pFlowTrees=getParses(model,sentences,IlpFormulation.FLOW_PROJ,deltaGen,expectedParseWeight);
}

Fixed version (ground truth):
@Test public void testProjAndNonprojDeltaParsers(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.add(IlpViterbiParserTest.getSentenceFromString("String_Node_Str"));
  sentences.add(IlpViterbiParserTest.getSentenceFromString("String_Node_Str"));
  ModelFactory modelFactory=new DmvModelFactory(new RandomWeightGenerator(lambda));
  Model model=modelFactory.getInstance(sentences);
  double expectedParseWeight;
  DeltaGenerator deltaGen;
  expectedParseWeight=-35.35388011;
  deltaGen=new FixedIntervalDeltaGenerator(0.1,1);
  DepTreebank npFlowTrees=getParses(model,sentences,IlpFormulation.FLOW_NONPROJ,deltaGen,expectedParseWeight);
  expectedParseWeight=-39.12828011;
  deltaGen=new FactorDeltaGenerator(1.1,2);
  DepTreebank pFlowTrees=getParses(model,sentences,IlpFormulation.FLOW_PROJ,deltaGen,expectedParseWeight);
}
Program: 131789
Project: 131789
Buggy source:
@Test public void testIdentityDeltaGen(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.add(IlpViterbiParserTest.getSentenceFromString("String_Node_Str"));
  sentences.add(IlpViterbiParserTest.getSentenceFromString("String_Node_Str"));
  ModelFactory modelFactory=new DmvModelFactory(new RandomWeightGenerator(lambda));
  Model model=modelFactory.getInstance(sentences);
  double expectedParseWeight=-40.56204981;
  DeltaGenerator deltaGen;
  deltaGen=new FactorDeltaGenerator(1.1,2);
  DepTreebank treesStandard=IlpViterbiParserTest.getParses(model,sentences,IlpFormulation.FLOW_NONPROJ,expectedParseWeight);
  deltaGen=new IdentityDeltaGenerator();
  DepTreebank treesDelta=getParses(model,sentences,IlpFormulation.FLOW_NONPROJ,deltaGen,expectedParseWeight);
  for (int i=0; i < treesStandard.size(); i++) {
    assertArrayEquals(treesStandard.get(i).getParents(),treesDelta.get(i).getParents());
  }
}

Fixed version (ground truth):
@Test public void testIdentityDeltaGen(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.add(IlpViterbiParserTest.getSentenceFromString("String_Node_Str"));
  sentences.add(IlpViterbiParserTest.getSentenceFromString("String_Node_Str"));
  ModelFactory modelFactory=new DmvModelFactory(new RandomWeightGenerator(lambda));
  Model model=modelFactory.getInstance(sentences);
  double expectedParseWeight=-40.56204981;
  DeltaGenerator deltaGen;
  DepTreebank treesStandard=IlpViterbiParserTest.getParses(model,sentences,IlpFormulation.FLOW_NONPROJ,expectedParseWeight);
  deltaGen=new IdentityDeltaGenerator();
  DepTreebank treesDelta=getParses(model,sentences,IlpFormulation.FLOW_NONPROJ,deltaGen,expectedParseWeight);
  for (int i=0; i < treesStandard.size(); i++) {
    assertArrayEquals(treesStandard.get(i).getParents(),treesDelta.get(i).getParents());
  }
}
Program: 131790
Project: 131790
Buggy source:
@Override public double getStopWeight(Triple<Label,String,Boolean> triple){
  return Prng.random.nextDouble();
}

Fixed version (ground truth):
@Override public double getStopWeight(Triple<Label,String,Boolean> triple){
  double stop=0.0;
  while (stop == 0.0) {
    stop=Prng.random.nextDouble();
  }
  return stop;
}
Program: 131791
Project: 131791
Buggy source:
@Override public double[] getChooseMulti(Pair<Label,String> pair,List<Label> children){
  return Multinomials.randomMultinomial(children.size());
}

Fixed version (ground truth):
@Override public double[] getChooseMulti(Pair<Label,String> pair,List<Label> children){
  double[] chooseMulti=Multinomials.randomMultinomial(children.size());
  for (int i=0; i < chooseMulti.length; i++) {
    chooseMulti[i]+=lambda;
  }
  Multinomials.normalizeProps(chooseMulti);
  return chooseMulti;
}
Program: 131792
Project: 131792
Buggy source:
@Test public void testFirstSentenceFromWsj(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.add(getSentenceFromString("String_Node_Str"));
  ModelFactory modelFactory=new DmvModelFactory(new RandomWeightGenerator());
  Model model=modelFactory.getInstance(sentences);
  Stopwatch timer;
  timer=new Stopwatch();
  timer.start();
  DepTreebank flowTrees=getParses(model,sentences,IlpFormulation.FLOW_PROJ);
  timer.stop();
  System.out.println(timer.getAverageDuration().getDurationInMilliseconds());
  timer=new Stopwatch();
  timer.start();
  DepTreebank mflowTrees=getParses(model,sentences,IlpFormulation.FLOW_PROJ);
  timer.stop();
  System.out.println(timer.getAverageDuration().getDurationInMilliseconds());
  timer=new Stopwatch();
  timer.start();
  DepTreebank expTrees=getParses(model,sentences,IlpFormulation.EXPLICIT_PROJ);
  timer.stop();
  System.out.println(timer.getAverageDuration().getDurationInMilliseconds());
  for (int i=0; i < expTrees.size(); i++) {
    assertArrayEquals(expTrees.get(i).getParents(),mflowTrees.get(i).getParents());
    assertArrayEquals(expTrees.get(i).getParents(),flowTrees.get(i).getParents());
  }
  timer=new Stopwatch();
  timer.start();
  DepTreebank dpTrees=getParses(model,sentences,IlpFormulation.DP_PROJ);
  timer.stop();
  System.out.println(timer.getAverageDuration().getDurationInMilliseconds());
  for (int i=0; i < expTrees.size(); i++) {
    assertArrayEquals(expTrees.get(i).getParents(),dpTrees.get(i).getParents());
  }
}

Fixed version (ground truth):
@Test public void testFirstSentenceFromWsj(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.add(getSentenceFromString("String_Node_Str"));
  ModelFactory modelFactory=new DmvModelFactory(new RandomWeightGenerator(lambda));
  Model model=modelFactory.getInstance(sentences);
  Stopwatch timer;
  timer=new Stopwatch();
  timer.start();
  DepTreebank flowTrees=getParses(model,sentences,IlpFormulation.FLOW_PROJ);
  timer.stop();
  System.out.println(timer.getAverageDuration().getDurationInMilliseconds());
  timer=new Stopwatch();
  timer.start();
  DepTreebank mflowTrees=getParses(model,sentences,IlpFormulation.FLOW_PROJ);
  timer.stop();
  System.out.println(timer.getAverageDuration().getDurationInMilliseconds());
  timer=new Stopwatch();
  timer.start();
  DepTreebank expTrees=getParses(model,sentences,IlpFormulation.EXPLICIT_PROJ);
  timer.stop();
  System.out.println(timer.getAverageDuration().getDurationInMilliseconds());
  for (int i=0; i < expTrees.size(); i++) {
    assertArrayEquals(expTrees.get(i).getParents(),mflowTrees.get(i).getParents());
    assertArrayEquals(expTrees.get(i).getParents(),flowTrees.get(i).getParents());
  }
  timer=new Stopwatch();
  timer.start();
  DepTreebank dpTrees=getParses(model,sentences,IlpFormulation.DP_PROJ);
  timer.stop();
  System.out.println(timer.getAverageDuration().getDurationInMilliseconds());
  for (int i=0; i < expTrees.size(); i++) {
    assertArrayEquals(expTrees.get(i).getParents(),dpTrees.get(i).getParents());
  }
}
Program: 131793
Project: 131793
Buggy source:
@Test public void testProjParses(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.add(getSentenceFromString("String_Node_Str"));
  ModelFactory modelFactory=new DmvModelFactory(new RandomWeightGenerator());
  Model model=modelFactory.getInstance(sentences);
  DepTreebank flowTrees=getParses(model,sentences,IlpFormulation.FLOW_PROJ);
  DepTreebank mflowTrees=getParses(model,sentences,IlpFormulation.MFLOW_PROJ);
  DepTreebank expTrees=getParses(model,sentences,IlpFormulation.EXPLICIT_PROJ);
  DepTreebank dpTrees=getParses(model,sentences,IlpFormulation.DP_PROJ);
  for (int i=0; i < dpTrees.size(); i++) {
    assertArrayEquals(expTrees.get(i).getParents(),dpTrees.get(i).getParents());
    assertArrayEquals(flowTrees.get(i).getParents(),dpTrees.get(i).getParents());
    assertArrayEquals(mflowTrees.get(i).getParents(),dpTrees.get(i).getParents());
  }
}

Fixed version (ground truth):
@Test public void testProjParses(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.add(getSentenceFromString("String_Node_Str"));
  ModelFactory modelFactory=new DmvModelFactory(new RandomWeightGenerator(lambda));
  Model model=modelFactory.getInstance(sentences);
  DepTreebank flowTrees=getParses(model,sentences,IlpFormulation.FLOW_PROJ);
  DepTreebank mflowTrees=getParses(model,sentences,IlpFormulation.MFLOW_PROJ);
  DepTreebank expTrees=getParses(model,sentences,IlpFormulation.EXPLICIT_PROJ);
  DepTreebank dpTrees=getParses(model,sentences,IlpFormulation.DP_PROJ);
  for (int i=0; i < dpTrees.size(); i++) {
    assertArrayEquals(expTrees.get(i).getParents(),dpTrees.get(i).getParents());
    assertArrayEquals(flowTrees.get(i).getParents(),dpTrees.get(i).getParents());
    assertArrayEquals(mflowTrees.get(i).getParents(),dpTrees.get(i).getParents());
  }
}
Program: 131794
Project: 131794
Buggy source:
@Test public void testNonProj(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.add(getSentenceFromString("String_Node_Str"));
  ModelFactory modelFactory=new DmvModelFactory(new RandomWeightGenerator());
  Model model=modelFactory.getInstance(sentences);
  DepTreebank flowTrees=getParses(model,sentences,IlpFormulation.FLOW_NONPROJ);
  DepTreebank mflowTrees=getParses(model,sentences,IlpFormulation.MFLOW_NONPROJ);
  for (int i=0; i < flowTrees.size(); i++) {
    assertArrayEquals(flowTrees.get(i).getParents(),mflowTrees.get(i).getParents());
  }
}

Fixed version (ground truth):
@Test public void testNonProj(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.add(getSentenceFromString("String_Node_Str"));
  ModelFactory modelFactory=new DmvModelFactory(new RandomWeightGenerator(lambda));
  Model model=modelFactory.getInstance(sentences);
  DepTreebank flowTrees=getParses(model,sentences,IlpFormulation.FLOW_NONPROJ);
  DepTreebank mflowTrees=getParses(model,sentences,IlpFormulation.MFLOW_NONPROJ);
  for (int i=0; i < flowTrees.size(); i++) {
    assertArrayEquals(flowTrees.get(i).getParents(),mflowTrees.get(i).getParents());
  }
}
Program: 131796
Project: 131796
Buggy source:
private Map<Label,Map<Label,Integer>> getChooseCounts(DepTreebank treebank){
  Map<Label,Map<Label,Integer>> chooseCounts=new HashMap<Label,Map<Label,Integer>>();
  for (  DepTree tree : treebank) {
    for (    DepTreeNode parentNode : tree) {
      Label parent=parentNode.getLabel();
      for (      DepTreeNode childNode : parentNode.getChildren()) {
        Label child=childNode.getLabel();
        Utilities.increment(chooseCounts,parent,child,1);
      }
    }
  }
  return chooseCounts;
}

Fixed version (ground truth):
private Map<Pair<Label,String>,Map<Label,Integer>> getChooseCounts(DepTreebank treebank){
  Map<Pair<Label,String>,Map<Label,Integer>> chooseCounts=new HashMap<Pair<Label,String>,Map<Label,Integer>>();
  for (  DepTree tree : treebank) {
    for (    DepTreeNode parentNode : tree) {
      Label parent=parentNode.getLabel();
      for (      String lr : DmvModelFactory.leftRight) {
        List<DepTreeNode> sideChildren=parentNode.getChildrenToSide(lr);
        Pair<Label,String> pair=new Pair<Label,String>(parent,lr);
        for (        DepTreeNode childNode : sideChildren) {
          Label child=childNode.getLabel();
          Utilities.increment(chooseCounts,pair,child,1);
        }
      }
    }
  }
  return chooseCounts;
}
Program: 131797
Project: 131797
Buggy source:
public MLWeightGenerator(Map<Label,Map<Label,Integer>> chooseCounts,Map<Triple<Label,String,Boolean>,Map<Boolean,Integer>> stopCounts,double lambda){
  this.chooseCounts=chooseCounts;
  this.stopCounts=stopCounts;
  this.lambda=lambda;
}

Fixed version (ground truth):
public MLWeightGenerator(Map<Pair<Label,String>,Map<Label,Integer>> chooseCounts,Map<Triple<Label,String,Boolean>,Map<Boolean,Integer>> stopCounts,double lambda){
  this.chooseCounts=chooseCounts;
  this.stopCounts=stopCounts;
  this.lambda=lambda;
}