nus-yam/ex-repair huggingface dataset:
Program: 131697
Project: 131697
Buggy source:
public Factor(double g,int[] Gind,double[] Gval){
  this.g=g;
  this.G=new FastSparseVector(Gind,Gval);
}

Fixed version (ground truth):
public Factor(double g,int[] Gind,double[] Gval,IloLPMatrix mat){
  this.g=g;
  this.G=new FastSparseVector(Gind,Gval);
  this.mat=mat;
}
Program: 131698
Project: 131698
Buggy source:
/** 
 * Create numRows RowFactors starting from the startRow'th row of mat and add these rows to factors.
 * @return The number of new factors added to factors.
 */
public static int addRowFactors(int startRow,int numRows,IloLPMatrix mat,List<Factor> factors) throws IloException {
  int numNewFactors=0;
  double[] lb=new double[numRows];
  double[] ub=new double[numRows];
  int[][] Aind=new int[numRows][];
  double[][] Aval=new double[numRows][];
  mat.getRows(startRow,numRows,lb,ub,Aind,Aval);
  for (int rowIdx=0; rowIdx < numRows; rowIdx++) {
    if (lb[rowIdx] == ub[rowIdx]) {
      factors.add(new RowFactor(ub[rowIdx],Aind[rowIdx],Aval[rowIdx],rowIdx,RowFactorType.EQ));
      numNewFactors++;
    }
 else {
      if (lb[rowIdx] != Rlt.CPLEX_NEG_INF) {
        double[] vals=Utilities.copyOf(Aval[rowIdx]);
        Vectors.scale(vals,-1.0);
        factors.add(new RowFactor(-lb[rowIdx],Aind[rowIdx],vals,rowIdx,RowFactorType.LOWER));
        numNewFactors++;
      }
      if (ub[rowIdx] != Rlt.CPLEX_POS_INF) {
        factors.add(new RowFactor(ub[rowIdx],Aind[rowIdx],Aval[rowIdx],rowIdx,RowFactorType.UPPER));
        numNewFactors++;
      }
    }
  }
  return numNewFactors;
}

Fixed version (ground truth):
/** 
 * Create numRows RowFactors starting from the startRow'th row of mat and add these rows to factors.
 * @return The number of new factors added to factors.
 */
public static int addRowFactors(int startRow,int numRows,IloLPMatrix mat,List<Factor> factors) throws IloException {
  int numNewFactors=0;
  double[] lb=new double[numRows];
  double[] ub=new double[numRows];
  int[][] Aind=new int[numRows][];
  double[][] Aval=new double[numRows][];
  mat.getRows(startRow,numRows,lb,ub,Aind,Aval);
  for (int rowIdx=0; rowIdx < numRows; rowIdx++) {
    if (lb[rowIdx] == ub[rowIdx]) {
      factors.add(new RowFactor(ub[rowIdx],Aind[rowIdx],Aval[rowIdx],rowIdx,RowFactorType.EQ,mat));
      numNewFactors++;
    }
 else {
      if (CPLEX_NEG_INF_CUTOFF < lb[rowIdx]) {
        double[] vals=Utilities.copyOf(Aval[rowIdx]);
        Vectors.scale(vals,-1.0);
        factors.add(new RowFactor(-lb[rowIdx],Aind[rowIdx],vals,rowIdx,RowFactorType.LOWER,mat));
        numNewFactors++;
      }
      if (ub[rowIdx] < CPLEX_POS_INF_CUTOFF) {
        factors.add(new RowFactor(ub[rowIdx],Aind[rowIdx],Aval[rowIdx],rowIdx,RowFactorType.UPPER,mat));
        numNewFactors++;
      }
    }
  }
  return numNewFactors;
}
Program: 131701
Project: 131701
Buggy source:
@Test public void testEarlyStopping(){
  Logger.getRootLogger().setLevel(Level.TRACE);
  DmvModel dmvModel=SimpleStaticDmvModel.getAltThreePosTagInstance();
  DmvDepTreeGenerator generator=new DmvDepTreeGenerator(dmvModel,Prng.nextInt(1000000));
  DepTreebank treebank=generator.getTreebank(50);
  DmvTrainCorpus corpus=new DmvTrainCorpus(treebank,0.0);
  double incumbentScore=-1.2;
  DmvRltRelaxation relax=getLp(corpus,1);
  DmvSolution initSol=DmvDantzigWolfeRelaxationTest.getInitFeasSol(corpus);
  double offsetProb=0.5;
  double probOfSkip=0.5;
  LocalBnBDmvTrainer.setBoundsFromInitSol(relax,initSol,offsetProb,probOfSkip);
  RelaxedDmvSolution relaxSol=(RelaxedDmvSolution)relax.solveRelaxation(incumbentScore);
  Assert.assertTrue(relaxSol.getScore() <= incumbentScore);
}

Fixed version (ground truth):
@Test public void testEarlyStopping(){
  DmvModel dmvModel=SimpleStaticDmvModel.getAltThreePosTagInstance();
  DmvDepTreeGenerator generator=new DmvDepTreeGenerator(dmvModel,Prng.nextInt(1000000));
  DepTreebank treebank=generator.getTreebank(50);
  DmvTrainCorpus corpus=new DmvTrainCorpus(treebank,0.0);
  double incumbentScore=-1.2;
  DmvRltRelaxation relax=getLp(corpus,1);
  DmvSolution initSol=DmvDantzigWolfeRelaxationTest.getInitFeasSol(corpus);
  double offsetProb=0.5;
  double probOfSkip=0.5;
  LocalBnBDmvTrainer.setBoundsFromInitSol(relax,initSol,offsetProb,probOfSkip);
  RelaxedDmvSolution relaxSol=(RelaxedDmvSolution)relax.solveRelaxation(incumbentScore);
  Assert.assertTrue(relaxSol.getScore() <= incumbentScore);
}
Program: 131704
Project: 131704
Buggy source:
@Test public void testSemiSupervisedOnSynthetic(){
  DmvModel dmvModel=SimpleStaticDmvModel.getThreePosTagInstance();
  DmvTrainCorpus trainCorpus=DmvCkyParserTest.getSyntheticCorpus(dmvModel);
  DmvDantzigWolfeRelaxation dw=getDw(trainCorpus,10);
  DmvSolution initBoundsSol=LocalBnBDmvTrainer.getInitSol(InitSol.VITERBI_EM,trainCorpus,dw,null,null);
  LocalBnBDmvTrainer.setBoundsFromInitSol(dw,initBoundsSol,0.1,0.0);
  RelaxedDmvSolution relaxSol=(RelaxedDmvSolution)dw.solveRelaxation();
  assertEquals(-14.813,relaxSol.getScore(),1e-3);
}

Fixed version (ground truth):
@Test public void testSemiSupervisedOnSynthetic(){
  DmvModel dmvModel=SimpleStaticDmvModel.getThreePosTagInstance();
  DmvTrainCorpus trainCorpus=DmvCkyParserTest.getSemiSupervisedSyntheticCorpus(dmvModel);
  DmvDantzigWolfeRelaxation dw=getDw(trainCorpus,10);
  DmvSolution initBoundsSol=LocalBnBDmvTrainer.getInitSol(InitSol.VITERBI_EM,trainCorpus,dw,null,null);
  LocalBnBDmvTrainer.setBoundsFromInitSol(dw,initBoundsSol,0.1,0.0);
  RelaxedDmvSolution relaxSol=(RelaxedDmvSolution)dw.solveRelaxation();
  assertEquals(-14.813,relaxSol.getScore(),1e-3);
}
Program: 131705
Project: 131705
Buggy source:
@Test public void testSemiSupervisedOnSynthetic(){
  DmvModel dmvModel=SimpleStaticDmvModel.getThreePosTagInstance();
  DmvTrainCorpus trainCorpus=DmvCkyParserTest.getSyntheticCorpus(dmvModel);
  DmvRltRelaxation dw=getLp(trainCorpus,10);
  DmvSolution initBoundsSol=LocalBnBDmvTrainer.getInitSol(InitSol.VITERBI_EM,trainCorpus,dw,null,null);
  LocalBnBDmvTrainer.setBoundsFromInitSol(dw,initBoundsSol,0.1,0.0);
  RelaxedDmvSolution relaxSol=(RelaxedDmvSolution)dw.solveRelaxation();
  assertEquals(-14.813,relaxSol.getScore(),1e-3);
}

Fixed version (ground truth):
@Test public void testSemiSupervisedOnSynthetic(){
  DmvModel dmvModel=SimpleStaticDmvModel.getThreePosTagInstance();
  DmvTrainCorpus trainCorpus=DmvCkyParserTest.getSemiSupervisedSyntheticCorpus(dmvModel);
  DmvRltRelaxation dw=getLp(trainCorpus,10);
  DmvSolution initBoundsSol=LocalBnBDmvTrainer.getInitSol(InitSol.VITERBI_EM,trainCorpus,dw,null,null);
  LocalBnBDmvTrainer.setBoundsFromInitSol(dw,initBoundsSol,0.1,0.0);
  RelaxedDmvSolution relaxSol=(RelaxedDmvSolution)dw.solveRelaxation();
  assertEquals(-14.813,relaxSol.getScore(),1e-3);
}
Program: 131706
Project: 131706
Buggy source:
public DmvSolution getProjectedDmvSolution(RelaxedDmvSolution relaxSol){
  if (!relaxSol.getStatus().hasSolution()) {
    return null;
  }
  double[][] logProbs=relaxSol.getLogProbs();
  for (int c=0; c < logProbs.length; c++) {
    double[] probs=Vectors.getExp(logProbs[c]);
    probs=Projections.getProjectedParams(probs);
    logProbs[c]=Vectors.getLog(probs);
  }
  IndexedDmvModel idm=dwRelax.getIdm();
  DepTreebank treebank=getProjectedParses(relaxSol.getTreebank());
  double score=dwRelax.computeTrueObjective(logProbs,treebank);
  DmvSolution sol=new DmvSolution(logProbs,idm,treebank,score);
  return sol;
}

Fixed version (ground truth):
public DmvSolution getProjectedDmvSolution(RelaxedDmvSolution relaxSol){
  if (!relaxSol.getStatus().hasSolution()) {
    return null;
  }
  double[][] logProbs=relaxSol.getLogProbs();
  for (int c=0; c < logProbs.length; c++) {
    double[] probs=Vectors.getExp(logProbs[c]);
    probs=Projections.getProjectedParams(probs);
    logProbs[c]=Vectors.getLog(probs);
  }
  DepTreebank treebank=getProjectedParses(relaxSol.getTreebank());
  double score=obj.computeTrueObjective(logProbs,treebank);
  DmvSolution sol=new DmvSolution(logProbs,idm,treebank,score);
  return sol;
}
Program: 131707
Project: 131707
Buggy source:
public DmvProjector(DmvTrainCorpus corpus,DmvRelaxation dwRelax){
  super();
  this.corpus=corpus;
  this.dwRelax=dwRelax;
}

Fixed version (ground truth):
public DmvProjector(DmvTrainCorpus corpus){
  super();
  this.corpus=corpus;
  this.idm=new IndexedDmvModel(this.corpus);
  this.obj=new DmvObjective(this.corpus);
}
Program: 131708
Project: 131708
Buggy source:
private DepTreebank getProjectedParses(RelaxedDepTreebank fracTreebank){
  double[][] fracRoots=fracTreebank.getFracRoots();
  double[][][] fracChildren=fracTreebank.getFracChildren();
  DepTreebank treebank=new DepTreebank(corpus.getLabelAlphabet());
  for (int s=0; s < fracChildren.length; s++) {
    if (corpus.isLabeled(s)) {
      treebank.add(corpus.getTree(s));
    }
 else {
      Sentence sentence=corpus.getSentence(s);
      double[] fracRoot=fracRoots[s];
      double[][] fracChild=fracChildren[s];
      DepTree tree=Projections.getProjectiveParse(sentence,fracRoot,fracChild);
      treebank.add(tree);
    }
  }
  return treebank;
}

Fixed version (ground truth):
public DepTreebank getProjectedParses(RelaxedDepTreebank fracTreebank){
  double[][] fracRoots=fracTreebank.getFracRoots();
  double[][][] fracChildren=fracTreebank.getFracChildren();
  DepTreebank treebank=new DepTreebank(corpus.getLabelAlphabet());
  for (int s=0; s < fracChildren.length; s++) {
    if (corpus.isLabeled(s)) {
      treebank.add(corpus.getTree(s));
    }
 else {
      Sentence sentence=corpus.getSentence(s);
      double[] fracRoot=fracRoots[s];
      double[][] fracChild=fracChildren[s];
      DepTree tree=Projections.getProjectiveParse(sentence,fracRoot,fracChild);
      treebank.add(tree);
    }
  }
  return treebank;
}
Program: 131709
Project: 131709
Buggy source:
@Test public void testSemiSupervisedOnSynthetic(){
  DmvModel dmvModel=SimpleStaticDmvModel.getThreePosTagInstance();
  DmvTrainCorpus trainCorpus=DmvCkyParserTest.getSyntheticCorpus(dmvModel);
  DmvRltRelaxation dw=getLp(trainCorpus,10);
  DmvSolution initBoundsSol=LocalBnBDmvTrainer.getInitSol(InitSol.VITERBI_EM,trainCorpus,dw,null,null);
  LocalBnBDmvTrainer.setBoundsFromInitSol(dw,initBoundsSol,0.1,0.0);
  RelaxedDmvSolution relaxSol=(RelaxedDmvSolution)dw.solveRelaxation();
  assertEquals(-14.813,relaxSol.getScore(),1e-3);
}

Fixed version (ground truth):
@Test public void testSemiSupervisedOnSynthetic(){
  DmvModel dmvModel=SimpleStaticDmvModel.getThreePosTagInstance();
  DmvTrainCorpus trainCorpus=DmvCkyParserTest.getSemiSupervisedSyntheticCorpus(dmvModel);
  DmvRltRelaxation dw=getLp(trainCorpus,10);
  DmvSolution initBoundsSol=LocalBnBDmvTrainer.getInitSol(InitSol.VITERBI_EM,trainCorpus,dw,null,null);
  LocalBnBDmvTrainer.setBoundsFromInitSol(dw,initBoundsSol,0.1,0.0);
  RelaxedDmvSolution relaxSol=(RelaxedDmvSolution)dw.solveRelaxation();
  assertEquals(-14.813,relaxSol.getScore(),1e-3);
}
Program: 131710
Project: 131710
Buggy source:
@Test public void testSemiSupervisedOnSynthetic(){
  DmvModel dmvModel=SimpleStaticDmvModel.getThreePosTagInstance();
  DmvTrainCorpus trainCorpus=DmvCkyParserTest.getSyntheticCorpus(dmvModel);
  DmvDantzigWolfeRelaxation dw=getDw(trainCorpus);
  RelaxedDmvSolution relaxSol=(RelaxedDmvSolution)dw.solveRelaxation();
  assertEquals(-14.866,relaxSol.getScore(),1e-3);
}

Fixed version (ground truth):
@Test public void testSemiSupervisedOnSynthetic(){
  DmvModel dmvModel=SimpleStaticDmvModel.getThreePosTagInstance();
  DmvTrainCorpus trainCorpus=DmvCkyParserTest.getSemiSupervisedSyntheticCorpus(dmvModel);
  DmvDantzigWolfeRelaxation dw=getDw(trainCorpus);
  RelaxedDmvSolution relaxSol=(RelaxedDmvSolution)dw.solveRelaxation();
  assertEquals(-14.866,relaxSol.getScore(),1e-3);
}
Program: 131711
Project: 131711
Buggy source:
public ViterbiEmDmvProjector(DmvTrainCorpus corpus,DmvRelaxation dwRelax,DmvSolution initFeasSol){
  dmvProjector=new DmvProjector(corpus,dwRelax);
  this.corpus=corpus;
  this.dwRelax=dwRelax;
  this.initFeasSol=initFeasSol;
}

Fixed version (ground truth):
public ViterbiEmDmvProjector(DmvTrainCorpus corpus,DmvRelaxation dwRelax,DmvSolution initFeasSol){
  dmvProjector=new DmvProjector(corpus);
  this.corpus=corpus;
  this.dwRelax=dwRelax;
  this.initFeasSol=initFeasSol;
}
Program: 131712
Project: 131712
Buggy source:
@Test public void testSemiSupervisedOnSynthetic(){
  DmvModel dmvModel=SimpleStaticDmvModel.getThreePosTagInstance();
  DmvTrainCorpus trainCorpus=getSyntheticCorpus(dmvModel);
  System.out.println(dmvModel.toString());
  System.out.println(trainCorpus);
  double expectedParseWeight=-31.278;
  getDpParses(dmvModel,trainCorpus,expectedParseWeight);
}

Fixed version (ground truth):
@Test public void testSemiSupervisedOnSynthetic(){
  DmvModel dmvModel=SimpleStaticDmvModel.getThreePosTagInstance();
  DmvTrainCorpus trainCorpus=getSemiSupervisedSyntheticCorpus(dmvModel);
  System.out.println(dmvModel.toString());
  System.out.println(trainCorpus);
  double expectedParseWeight=-31.278;
  getDpParses(dmvModel,trainCorpus,expectedParseWeight);
}
Program: 131713
Project: 131713
Buggy source:
/** 
 * Initializes from a fractional parse in order to project back into the feasible region.
 * @param fracRoot
 */
private void cacheModel(double[] fracRoot,double[][] fracChild){
  int[] i2tag=depInst.postags;
  for (int c=0; c < i2tag.length; c++) {
    root[c]=Utilities.log(fracRoot[c]);
    for (int p=0; p < i2tag.length; p++) {
      if (c == p)       continue;
      if (nontermMap.childValency > 1) {
        throw new IllegalStateException("String_Node_Str");
      }
      child[c][p][0]=Utilities.log(fracChild[p][c]);
    }
    for (int dir=0; dir < 2; dir++) {
      for (int v=0; v < nontermMap.decisionValency; v++) {
        for (int choice=0; choice < 2; choice++) {
          decision[c][dir][v][choice]=0.0;
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Initializes from a fractional parse in order to project back into the feasible region.
 * @param fracRoot
 */
private void cacheModel(double[] fracRoot,double[][] fracChild){
  int[] i2tag=depInst.postags;
  for (int c=0; c < i2tag.length; c++) {
    root[c]=Utilities.logForIlp(fracRoot[c]);
    for (int p=0; p < i2tag.length; p++) {
      if (c == p)       continue;
      if (nontermMap.childValency > 1) {
        throw new IllegalStateException("String_Node_Str");
      }
      child[c][p][0]=Utilities.logForIlp(fracChild[p][c]);
    }
    for (int dir=0; dir < 2; dir++) {
      for (int v=0; v < nontermMap.decisionValency; v++) {
        for (int choice=0; choice < 2; choice++) {
          decision[c][dir][v][choice]=0.0;
        }
      }
    }
  }
}
Program: 131715
Project: 131715
Buggy source:
@Test public void testBoundsOnlyYieldConvexEnvelope() throws IloException {
  double x1Lb=2;
  double x1Ub=3;
  double x2Lb=5;
  double x2Ub=7;
  IloCplex cplex=new IloCplex();
  cplex.setParam(IntParam.RootAlg,IloCplex.Algorithm.Primal);
  IloNumVar x1=cplex.numVar(x1Lb,x1Ub,"String_Node_Str");
  IloNumVar x2=cplex.numVar(x2Lb,x2Ub,"String_Node_Str");
  IloNumVar[] vars=new IloNumVar[]{x1,x2};
  IloLPMatrix mat=cplex.LPMatrix("String_Node_Str");
  mat.addCols(vars);
  RltProgram rlt=Rlt.getFirstOrderRlt(cplex,mat);
  IloLPMatrix rltMat=rlt.getRltMatrix();
  cplex.add(rltMat);
  System.out.println(rltMat);
  String rltMatStr=rltMat.toString();
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertEquals(16,rltMat.getNrows());
}

Fixed version (ground truth):
@Test public void testBoundsOnlyYieldConvexEnvelope() throws IloException {
  double x1Lb=2;
  double x1Ub=3;
  double x2Lb=5;
  double x2Ub=7;
  IloCplex cplex=new IloCplex();
  cplex.setParam(IntParam.RootAlg,IloCplex.Algorithm.Primal);
  IloNumVar x1=cplex.numVar(x1Lb,x1Ub,"String_Node_Str");
  IloNumVar x2=cplex.numVar(x2Lb,x2Ub,"String_Node_Str");
  IloNumVar[] vars=new IloNumVar[]{x1,x2};
  IloLPMatrix mat=cplex.LPMatrix("String_Node_Str");
  mat.addCols(vars);
  RltProgram rlt=Rlt.getFirstOrderRlt(cplex,mat);
  IloLPMatrix rltMat=rlt.getRltMatrix();
  cplex.add(rltMat);
  System.out.println(rltMat);
  String rltMatStr=rltMat.toString();
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertEquals(10,rltMat.getNrows());
}
Program: 131716
Project: 131716
Buggy source:
@Test public void testGetConvexEnvelope() throws IloException {
  double x1Lb=2;
  double x1Ub=3;
  double x2Lb=5;
  double x2Ub=7;
  IloCplex cplex=new IloCplex();
  cplex.setParam(IntParam.RootAlg,IloCplex.Algorithm.Primal);
  IloNumVar x1=cplex.numVar(x1Lb,x1Ub,"String_Node_Str");
  IloNumVar x2=cplex.numVar(x2Lb,x2Ub,"String_Node_Str");
  IloRange c1=cplex.le(cplex.sum(cplex.prod(-6,x1),cplex.prod(8,x2)),48);
  IloRange c2=cplex.le(cplex.sum(cplex.prod(3,x1),cplex.prod(8,x2)),120);
  IloNumVar[] vars=new IloNumVar[]{x1,x2};
  IloRange[] cons=new IloRange[]{c1,c2};
  IloLPMatrix mat=cplex.LPMatrix("String_Node_Str");
  mat.addCols(vars);
  mat.addRows(cons);
  RltProgram rlt=Rlt.getConvexConcaveEnvelope(cplex,mat);
  IloLPMatrix rltMat=rlt.getRltMatrix();
  cplex.add(rltMat);
  System.out.println(rltMat);
  String rltMatStr=rltMat.toString();
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertEquals(16,rltMat.getNrows());
}

Fixed version (ground truth):
@Test public void testGetConvexEnvelope() throws IloException {
  double x1Lb=2;
  double x1Ub=3;
  double x2Lb=5;
  double x2Ub=7;
  IloCplex cplex=new IloCplex();
  cplex.setParam(IntParam.RootAlg,IloCplex.Algorithm.Primal);
  IloNumVar x1=cplex.numVar(x1Lb,x1Ub,"String_Node_Str");
  IloNumVar x2=cplex.numVar(x2Lb,x2Ub,"String_Node_Str");
  IloRange c1=cplex.le(cplex.sum(cplex.prod(-6,x1),cplex.prod(8,x2)),48);
  IloRange c2=cplex.le(cplex.sum(cplex.prod(3,x1),cplex.prod(8,x2)),120);
  IloNumVar[] vars=new IloNumVar[]{x1,x2};
  IloRange[] cons=new IloRange[]{c1,c2};
  IloLPMatrix mat=cplex.LPMatrix("String_Node_Str");
  mat.addCols(vars);
  mat.addRows(cons);
  RltProgram rlt=Rlt.getConvexConcaveEnvelope(cplex,mat);
  IloLPMatrix rltMat=rlt.getRltMatrix();
  cplex.add(rltMat);
  System.out.println(rltMat);
  String rltMatStr=rltMat.toString();
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertTrue(rltMatStr.contains("String_Node_Str"));
  assertEquals(10,rltMat.getNrows());
}
Program: 131718
Project: 131718
Buggy source:
@Override protected void evalIncumbent(Solution incumbentSolution,double incumbentScore){
  if (evaluator != null && incumbentSolution != null) {
    log.info("String_Node_Str" + incumbentScore);
    DmvSolution sol=(DmvSolution)incumbentSolution;
    log.info("String_Node_Str" + evaluator.evaluate(sol.getTreebank()));
  }
}

Fixed version (ground truth):
@Override protected void evalIncumbent(Solution incumbentSolution){
  if (evaluator != null && incumbentSolution != null) {
    DmvSolution sol=(DmvSolution)incumbentSolution;
    log.info("String_Node_Str" + sol.getScore());
    log.info("String_Node_Str" + evaluator.evaluate(sol.getTreebank()));
  }
}
Program: 131720
Project: 131720
Buggy source:
/** 
 * Override this method.
 */
protected void evalIncumbent(Solution incumbentSolution,double incumbentScore){
  return;
}

Fixed version (ground truth):
/** 
 * Override this method.
 */
protected void evalIncumbent(Solution incumbentSolution){
  return;
}
Program: 131721
Project: 131721
Buggy source:
@Override public VariableId select(DmvProblemNode node){
  VariableId regretVarId=regretFactory.select(node);
  IndexedDmvModel idm=node.getIdm();
  DmvBounds origBounds=node.getBounds();
  double parentBound=node.getOptimisticBound();
  double maxScore=EPSILON * EPSILON;
  int maxC=-1;
  int maxM=-1;
  for (int c=0; c < idm.getNumConds(); c++) {
    for (int m=0; m < idm.getNumParams(c); m++) {
      if (!origBounds.canBranch(c,m)) {
        continue;
      }
      node.setAsActiveNode();
      List<DmvBoundsDelta> deltas=varSplitter.split(origBounds,new VariableId(c,m));
      List<ProblemNode> children=node.branch(deltas);
      assert(children.size() == 2);
      DmvProblemNode child1=(DmvProblemNode)children.get(0);
      child1.setAsActiveNode();
      double c1Bound=child1.getOptimisticBound();
      DmvProblemNode child2=(DmvProblemNode)children.get(0);
      child2.setAsActiveNode();
      double c2Bound=child2.getOptimisticBound();
      double c1Delta=parentBound - c1Bound;
      double c2Delta=parentBound - c2Bound;
      double score=Math.max(c1Delta,EPSILON) * Math.max(c2Delta,EPSILON);
      if (score > maxScore) {
        maxScore=score;
        maxC=c;
        maxM=m;
      }
      String name=idm.getName(c,m);
      log.trace(String.format("String_Node_Str",c,m,name,score));
    }
  }
  node.setAsActiveNode();
  if (maxC == -1 || maxM == -1) {
    return regretVarId;
  }
  String name=idm.getName(maxC,maxM);
  log.info(String.format("String_Node_Str",maxC,maxM,name,maxScore));
  return new VariableId(maxC,maxM);
}

Fixed version (ground truth):
@Override public VariableId select(DmvProblemNode node){
  VariableId regretVarId=regretFactory.select(node);
  IndexedDmvModel idm=node.getIdm();
  DmvBounds origBounds=node.getBounds();
  double maxScore=EPSILON * EPSILON;
  int maxC=-1;
  int maxM=-1;
  for (int c=0; c < idm.getNumConds(); c++) {
    for (int m=0; m < idm.getNumParams(c); m++) {
      if (!origBounds.canBranch(c,m)) {
        continue;
      }
      double score=getStrongScore(node,c,m);
      if (score > maxScore) {
        maxScore=score;
        maxC=c;
        maxM=m;
      }
    }
  }
  if (maxC == -1 || maxM == -1) {
    return regretVarId;
  }
  String name=idm.getName(maxC,maxM);
  log.info(String.format("String_Node_Str",maxC,maxM,name,maxScore));
  return new VariableId(maxC,maxM);
}
Program: 131724
Project: 131724
Buggy source:
private void addSetContraints(int setSize,int c) throws IloException {
  double[] ones=new double[setSize];
  Arrays.fill(ones,1.0);
  int numParams=idm.getNumParams(c);
  int counter=0;
  for (  int[] paramIndices : Sets.getSets(setSize,numParams)) {
    assert(paramIndices.length == setSize);
    IloNumVar[] paramVars=new IloNumVar[setSize];
    for (int i=0; i < setSize; i++) {
      int m=paramIndices[i];
      paramVars[i]=mp.modelParamVars[c][m];
    }
    IloLinearNumExpr vectorExpr=cplex.scalProd(ones,paramVars);
    IloRange constraint=cplex.le(vectorExpr,1.0,String.format("String_Node_Str",c,counter++));
    mp.lpMatrix.addRow(constraint);
  }
}

Fixed version (ground truth):
private void addSetContraints(int setSize,int c) throws IloException {
  double[] ones=new double[setSize];
  Arrays.fill(ones,1.0);
  int numParams=idm.getNumParams(c);
  int counter=0;
  setSize=Math.min(setSize,numParams);
  for (  int[] paramIndices : Sets.getSets(setSize,numParams)) {
    assert(paramIndices.length == setSize);
    IloNumVar[] paramVars=new IloNumVar[setSize];
    for (int i=0; i < setSize; i++) {
      int m=paramIndices[i];
      paramVars[i]=mp.modelParamVars[c][m];
    }
    IloLinearNumExpr vectorExpr=cplex.scalProd(ones,paramVars);
    IloRange constraint=cplex.le(vectorExpr,1.0,String.format("String_Node_Str",c,counter++));
    mp.lpMatrix.addRow(constraint);
  }
}
Program: 131725
Project: 131725
Buggy source:
public static List<int[]> getSets(int setSize,int numParams){
  List<HashSet<Integer>> hss=getSetsHelper(setSize,numParams);
  List<int[]> sets=new ArrayList<int[]>(hss.size());
  for (  HashSet<Integer> set : hss) {
    sets.add(asArray(set));
  }
  return sets;
}

Fixed version (ground truth):
public static List<int[]> getSets(int setSize,int numParams){
  if (setSize > numParams) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  List<HashSet<Integer>> hss=getSetsHelper(setSize,numParams);
  List<int[]> sets=new ArrayList<int[]>(hss.size());
  for (  HashSet<Integer> set : hss) {
    sets.add(asArray(set));
  }
  return sets;
}
Program: 131727
Project: 131727
Buggy source:
private void applyDelta(DmvBoundsDelta delta){
  try {
    int c=delta.getC();
    int m=delta.getM();
    double origLb=bounds.getLb(c,m);
    double origUb=bounds.getUb(c,m);
    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.lpMatrix.getIndex(mp.couplConsLower[c][m]);
    int upCmInd=mp.lpMatrix.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.lpMatrix.setNZs(rowind.toNativeArray(),colind.toNativeArray(),val.toNativeArray());
    }
  }
 catch (  IloException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
private void applyDelta(DmvBoundsDelta delta){
}
Program: 131730
Project: 131730
Buggy source:
public static RelaxStatus get(Status status){
  if (status == Status.Infeasible || status == Status.InfeasibleOrUnbounded || status == Status.Unbounded) {
    return Infeasible;
  }
 else {
    return Feasible;
  }
}

Fixed version (ground truth):
public static RelaxStatus get(Status status){
  if (status == Status.Infeasible || status == Status.InfeasibleOrUnbounded || status == Status.Unbounded || status == Status.Bounded) {
    return Infeasible;
  }
 else   if (status == Status.Error || status == Status.Unknown) {
    return Unknown;
  }
 else {
    return Feasible;
  }
}
Program: 131732
Project: 131732
Buggy source:
@Before public void setUp(){
  Prng.seed(1234567890);
}

Fixed version (ground truth):
@Before public void setUp(){
  Prng.seed(1234567890);
  DmvProblemNode.clearActiveNode();
}
Program: 131733
Project: 131733
Buggy source:
@Test public void testTwo(){
  double epsilon=0.1;
  BnBDmvTrainer trainer=new BnBDmvTrainer(epsilon,getDefaultBrancher(),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):
@Test public void testTwo(){
  double epsilon=0.4;
  BnBDmvTrainer trainer=new BnBDmvTrainer(epsilon,getDefaultBrancher(),new File("String_Node_Str"));
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  trainer.train(sentences);
}
Program: 131734
Project: 131734
Buggy source:
@Test public void testSynthetic(){
  double epsilon=0.1;
  BnBDmvTrainer trainer=new BnBDmvTrainer(epsilon,getDefaultBrancher());
  DmvModel dmvModel=SimpleStaticDmvModel.getThreePosTagInstance();
  DmvDepTreeGenerator generator=new DmvDepTreeGenerator(dmvModel,Prng.nextInt(1000000));
  DepTreebank treebank=generator.getTreebank(10);
  System.out.println(treebank);
  System.out.println(dmvModel);
  SentenceCollection sentences=treebank.getSentences();
  trainer.train(sentences);
}

Fixed version (ground truth):
public void testSynthetic(){
  double epsilon=0.9;
  DmvDantzigWolfeRelaxation dwRelax=new DmvDantzigWolfeRelaxation(null,1,new CutCountComputer());
  dwRelax.setMaxDwIterations(3);
  BnBDmvTrainer trainer=new BnBDmvTrainer(epsilon,getDefaultBrancher(),dwRelax);
  DmvModel dmvModel=SimpleStaticDmvModel.getThreePosTagInstance();
  DmvDepTreeGenerator generator=new DmvDepTreeGenerator(dmvModel,Prng.nextInt(1000000));
  DepTreebank treebank=generator.getTreebank(10);
  System.out.println(treebank);
  System.out.println(dmvModel);
  SentenceCollection sentences=treebank.getSentences();
  trainer.train(sentences);
}
Program: 131736
Project: 131736
Buggy source:
public void init(SentenceCollection sentences,DmvSolution initFeasSol){
  try {
    this.sentences=sentences;
    this.idm=new IndexedDmvModel(sentences);
    this.bounds=new DmvBounds(this.idm);
    this.cplex=new IloCplex();
    this.mp=buildModel(cplex,initFeasSol.getTreebank());
    setCplexParams(cplex);
  }
 catch (  IloException e) {
    if (e instanceof ilog.cplex.CpxException) {
      ilog.cplex.CpxException cpxe=(ilog.cplex.CpxException)e;
      System.err.println("String_Node_Str" + cpxe.getStatus());
      System.err.println("String_Node_Str" + cpxe.getMessage());
    }
    throw new RuntimeException(e);
  }
catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void init(DmvSolution initFeasSol){
  try {
    this.bounds=new DmvBounds(this.idm);
    this.cplex=new IloCplex();
    this.mp=buildModel(cplex,initFeasSol.getTreebank());
    setCplexParams(cplex);
  }
 catch (  IloException e) {
    if (e instanceof ilog.cplex.CpxException) {
      ilog.cplex.CpxException cpxe=(ilog.cplex.CpxException)e;
      System.err.println("String_Node_Str" + cpxe.getStatus());
      System.err.println("String_Node_Str" + cpxe.getMessage());
    }
    throw new RuntimeException(e);
  }
catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 131739
Project: 131739
Buggy source:
public void init(SentenceCollection sentences,DmvSolution initFeasSol){
  try {
    this.sentences=sentences;
    this.idm=new IndexedDmvModel(sentences);
    this.bounds=new DmvBounds(this.idm);
    this.cplex=new IloCplex();
    this.mp=buildModel(cplex,initFeasSol);
    setCplexParams(cplex);
  }
 catch (  IloException e) {
    if (e instanceof ilog.cplex.CpxException) {
      ilog.cplex.CpxException cpxe=(ilog.cplex.CpxException)e;
      System.err.println("String_Node_Str" + cpxe.getStatus());
      System.err.println("String_Node_Str" + cpxe.getMessage());
    }
    throw new RuntimeException(e);
  }
catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void init(DmvSolution initFeasSol){
  try {
    this.bounds=new DmvBounds(this.idm);
    this.cplex=new IloCplex();
    this.mp=buildModel(cplex,initFeasSol);
    setCplexParams(cplex);
  }
 catch (  IloException e) {
    if (e instanceof ilog.cplex.CpxException) {
      ilog.cplex.CpxException cpxe=(ilog.cplex.CpxException)e;
      System.err.println("String_Node_Str" + cpxe.getStatus());
      System.err.println("String_Node_Str" + cpxe.getMessage());
    }
    throw new RuntimeException(e);
  }
catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 131741
Project: 131741
Buggy source:
@Test public void testCutsOnManyPosTags(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  DmvDantzigWolfeRelaxationResolution dw=getDw(sentences,15);
  RelaxedDmvSolution relaxSol=dw.solveRelaxation();
  assertEquals(0.0,relaxSol.getScore(),1e-11);
  double[][] logProbs=relaxSol.getLogProbs();
  for (int c=0; c < logProbs.length; c++) {
    Vectors.exp(logProbs[c]);
    System.out.println(dw.getIdm().getName(c,0) + "String_Node_Str" + Vectors.sum(logProbs[c]));
    Assert.assertTrue(Vectors.sum(logProbs[c]) <= DmvDantzigWolfeRelaxation.DEFAULT_MIN_SUM_FOR_CUTS);
  }
}

Fixed version (ground truth):
@Test public void testCutsOnManyPosTags(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  DmvDantzigWolfeRelaxationResolution dw=getDw(sentences,15);
  RelaxedDmvSolution relaxSol=dw.solveRelaxation();
  assertEquals(0.0,relaxSol.getScore(),DEFAULT_SOLUTION_TOLERANCE);
  double[][] logProbs=relaxSol.getLogProbs();
  for (int c=0; c < logProbs.length; c++) {
    Vectors.exp(logProbs[c]);
    System.out.println(dw.getIdm().getName(c,0) + "String_Node_Str" + Vectors.sum(logProbs[c]));
    Assert.assertTrue(Vectors.sum(logProbs[c]) <= DmvDantzigWolfeRelaxation.DEFAULT_MIN_SUM_FOR_CUTS);
  }
}
Program: 131742
Project: 131742
Buggy source:
@Test public void testAdditionalCuttingPlanes(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  int maxCuts=5;
  double[] maxSums=new double[maxCuts];
  double prevSum=Double.POSITIVE_INFINITY;
  for (int numCuts=1; numCuts < maxCuts; numCuts++) {
    Prng.seed(12345);
    DmvDantzigWolfeRelaxationResolution dw=getDw(sentences,numCuts);
    RelaxedDmvSolution relaxSol=dw.solveRelaxation();
    assertEquals(0.0,relaxSol.getScore(),1e-11);
    double maxSum=0.0;
    double[][] logProbs=relaxSol.getLogProbs();
    for (int c=0; c < logProbs.length; c++) {
      Vectors.exp(logProbs[c]);
      double sum=Vectors.sum(logProbs[c]);
      if (sum > maxSum) {
        maxSum=sum;
      }
    }
    maxSums[numCuts]=maxSum;
    System.out.println("String_Node_Str" + Arrays.toString(maxSums));
    Assert.assertTrue(maxSum <= prevSum);
    prevSum=maxSum;
  }
  System.out.println("String_Node_Str" + Arrays.toString(maxSums));
}

Fixed version (ground truth):
@Test public void testAdditionalCuttingPlanes(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  int maxCuts=5;
  double[] maxSums=new double[maxCuts];
  double prevSum=Double.POSITIVE_INFINITY;
  for (int numCuts=1; numCuts < maxCuts; numCuts++) {
    Prng.seed(12345);
    DmvDantzigWolfeRelaxationResolution dw=getDw(sentences,numCuts);
    RelaxedDmvSolution relaxSol=dw.solveRelaxation();
    assertEquals(0.0,relaxSol.getScore(),DEFAULT_SOLUTION_TOLERANCE);
    double maxSum=0.0;
    double[][] logProbs=relaxSol.getLogProbs();
    for (int c=0; c < logProbs.length; c++) {
      Vectors.exp(logProbs[c]);
      double sum=Vectors.sum(logProbs[c]);
      if (sum > maxSum) {
        maxSum=sum;
      }
    }
    maxSums[numCuts]=maxSum;
    System.out.println("String_Node_Str" + Arrays.toString(maxSums));
    Assert.assertTrue(maxSum <= prevSum);
    prevSum=maxSum;
  }
  System.out.println("String_Node_Str" + Arrays.toString(maxSums));
}
Program: 131743
Project: 131743
Buggy source:
@Test public void testTwoSentences(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  DmvDantzigWolfeRelaxationResolution dw=getDw(sentences);
  RelaxedDmvSolution relaxSol=dw.solveRelaxation();
  assertEquals(0.0,relaxSol.getScore(),1e-11);
  double[][] logProbs=relaxSol.getLogProbs();
  for (int c=0; c < logProbs.length; c++) {
    Vectors.exp(logProbs[c]);
    System.out.println(dw.getIdm().getName(c,0) + "String_Node_Str" + Vectors.sum(logProbs[c]));
  }
}

Fixed version (ground truth):
@Test public void testTwoSentences(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  DmvDantzigWolfeRelaxationResolution dw=getDw(sentences);
  RelaxedDmvSolution relaxSol=dw.solveRelaxation();
  assertEquals(0.0,relaxSol.getScore(),DEFAULT_SOLUTION_TOLERANCE);
  double[][] logProbs=relaxSol.getLogProbs();
  for (int c=0; c < logProbs.length; c++) {
    Vectors.exp(logProbs[c]);
    System.out.println(dw.getIdm().getName(c,0) + "String_Node_Str" + Vectors.sum(logProbs[c]));
  }
}
Program: 131744
Project: 131744
Buggy source:
/** 
 * Helper function 
 * @return DW relaxation with 1 round of cuts, and 1 initial cut per parameter
 */
public static DmvDantzigWolfeRelaxationResolution getDw(SentenceCollection sentences,final int numCuts){
  DmvSolution initSol=getInitFeasSol(sentences);
  System.out.println(initSol);
  DmvDantzigWolfeRelaxationResolution dw=new DmvDantzigWolfeRelaxationResolution(new File("String_Node_Str"));
  dw.init(sentences,initSol);
  return dw;
}

Fixed version (ground truth):
/** 
 * Helper function 
 * @return DW relaxation with 1 round of cuts, and 1 initial cut per parameter
 */
public static DmvDantzigWolfeRelaxationResolution getDw(SentenceCollection sentences,final int numCuts){
  DmvSolution initSol=getInitFeasSol(sentences);
  System.out.println(initSol);
  DmvDantzigWolfeRelaxationResolution dw=new DmvDantzigWolfeRelaxationResolution(new File("String_Node_Str"));
  dw.setSentences(sentences);
  dw.init(initSol);
  return dw;
}
Program: 131745
Project: 131745
Buggy source:
@Test public void testThreeWordSentence(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  DmvDantzigWolfeRelaxationResolution dw=getDw(sentences);
  RelaxedDmvSolution relaxSol=dw.solveRelaxation();
  assertEquals(0.0,relaxSol.getScore(),1e-11);
  double[][] logProbs=relaxSol.getLogProbs();
  for (int c=0; c < logProbs.length; c++) {
    Vectors.exp(logProbs[c]);
    System.out.println(dw.getIdm().getName(c,0) + "String_Node_Str" + Vectors.sum(logProbs[c]));
    for (int m=0; m < logProbs[c].length; m++) {
    }
  }
}

Fixed version (ground truth):
@Test public void testThreeWordSentence(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  DmvDantzigWolfeRelaxationResolution dw=getDw(sentences);
  RelaxedDmvSolution relaxSol=dw.solveRelaxation();
  assertEquals(0.0,relaxSol.getScore(),DEFAULT_SOLUTION_TOLERANCE);
  double[][] logProbs=relaxSol.getLogProbs();
  for (int c=0; c < logProbs.length; c++) {
    Vectors.exp(logProbs[c]);
    System.out.println(dw.getIdm().getName(c,0) + "String_Node_Str" + Vectors.sum(logProbs[c]));
    for (int m=0; m < logProbs[c].length; m++) {
    }
  }
}
Program: 131746
Project: 131746
Buggy source:
@Test public void testBounds(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  DmvDantzigWolfeRelaxationResolution dw=getDw(sentences);
  DmvBounds bds=dw.getBounds();
  double origLower=bds.getLb(0,0);
  double origUpper=bds.getUb(0,0);
  double newL, newU;
  newL=Utilities.log(0.11);
  newU=Utilities.log(0.90);
  RelaxedDmvSolution relaxSol;
  relaxSol=testBoundsHelper(dw,origLower,origUpper,true);
  tempStaticLogProbs=relaxSol.getLogProbs();
  assertEquals(0.0,relaxSol.getScore(),1e-11);
  relaxSol=testBoundsHelper(dw,newL,newU,true);
  relaxSol=testBoundsHelper(dw,origLower,origUpper,true);
  assertEquals(0.0,relaxSol.getScore(),1e-7);
  assertEquals(origLower,bds.getLb(0,0),1e-7);
  assertEquals(origUpper,bds.getUb(0,0),1e-13);
}

Fixed version (ground truth):
@Test public void testBounds(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  sentences.addSentenceFromString("String_Node_Str");
  DmvDantzigWolfeRelaxationResolution dw=getDw(sentences);
  DmvBounds bds=dw.getBounds();
  double origLower=bds.getLb(0,0);
  double origUpper=bds.getUb(0,0);
  double newL, newU;
  newL=Utilities.log(0.11);
  newU=Utilities.log(0.90);
  RelaxedDmvSolution relaxSol;
  relaxSol=testBoundsHelper(dw,origLower,origUpper,true);
  tempStaticLogProbs=relaxSol.getLogProbs();
  assertEquals(0.0,relaxSol.getScore(),DEFAULT_SOLUTION_TOLERANCE);
  relaxSol=testBoundsHelper(dw,newL,newU,true);
  relaxSol=testBoundsHelper(dw,origLower,origUpper,true);
  assertEquals(0.0,relaxSol.getScore(),1e-7);
  assertEquals(origLower,bds.getLb(0,0),1e-7);
  assertEquals(origUpper,bds.getUb(0,0),1e-13);
}
Program: 131747
Project: 131747
Buggy source:
@Test public void testOneWordSentence(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  DmvDantzigWolfeRelaxationResolution dw=getDw(sentences);
  RelaxedDmvSolution relaxSol=dw.solveRelaxation();
  assertEquals(0.0,relaxSol.getScore(),1e-11);
  double[][] logProbs=relaxSol.getLogProbs();
  for (int c=0; c < logProbs.length; c++) {
    Vectors.exp(logProbs[c]);
    System.out.println(dw.getIdm().getName(c,0) + "String_Node_Str" + Vectors.sum(logProbs[c]));
    for (int m=0; m < logProbs[c].length; m++) {
    }
  }
}

Fixed version (ground truth):
@Test public void testOneWordSentence(){
  SentenceCollection sentences=new SentenceCollection();
  sentences.addSentenceFromString("String_Node_Str");
  DmvDantzigWolfeRelaxationResolution dw=getDw(sentences);
  RelaxedDmvSolution relaxSol=dw.solveRelaxation();
  assertEquals(0.0,relaxSol.getScore(),DEFAULT_SOLUTION_TOLERANCE);
  double[][] logProbs=relaxSol.getLogProbs();
  for (int c=0; c < logProbs.length; c++) {
    Vectors.exp(logProbs[c]);
    System.out.println(dw.getIdm().getName(c,0) + "String_Node_Str" + Vectors.sum(logProbs[c]));
    for (int m=0; m < logProbs[c].length; m++) {
    }
  }
}
Program: 131748
Project: 131748
Buggy source:
/** 
 * Helper function 
 * @return DW relaxation with 1 round of cuts, and 1 initial cut per parameter
 */
public static DmvDantzigWolfeRelaxation getDw(SentenceCollection sentences,final int numCuts){
  DmvSolution initSol=getInitFeasSol(sentences);
  System.out.println(initSol);
  CutCountComputer ccc=new CutCountComputer(){
    @Override public int getNumCuts(    int numParams){
      return numCuts;
    }
  }
;
  DmvDantzigWolfeRelaxation dw=new DmvDantzigWolfeRelaxation(new File("String_Node_Str"),numCuts,ccc);
  dw.init(sentences,initSol);
  return dw;
}

Fixed version (ground truth):
/** 
 * Helper function 
 * @return DW relaxation with 1 round of cuts, and 1 initial cut per parameter
 */
public static DmvDantzigWolfeRelaxation getDw(SentenceCollection sentences,final int numCuts){
  DmvSolution initSol=getInitFeasSol(sentences);
  System.out.println(initSol);
  CutCountComputer ccc=new CutCountComputer(){
    @Override public int getNumCuts(    int numParams){
      return numCuts;
    }
  }
;
  DmvDantzigWolfeRelaxation dw=new DmvDantzigWolfeRelaxation(new File("String_Node_Str"),numCuts,ccc);
  dw.setSentences(sentences);
  dw.init(initSol);
  return dw;
}
Program: 131751
Project: 131751
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);
  }
}