Program: 131726
Project: 131726
Buggy source:
public Pair<RelaxStatus,Double> runDWAlgo(IloCplex cplex,MasterProblem mp,double upperBound) throws UnknownObjectException, IloException {
  if (!areFeasibleBounds(bounds)) {
    return new Pair<RelaxStatus,Double>(RelaxStatus.Infeasible,INTERNAL_WORST_SCORE);
  }
  RelaxStatus status=RelaxStatus.Unknown;
  DmvCkyParser parser=new DmvCkyParser();
  double lowerBound=INTERNAL_BEST_SCORE;
  TDoubleArrayList iterationLowerBounds=new TDoubleArrayList();
  TDoubleArrayList iterationObjVals=new TDoubleArrayList();
  WarmStart warmStart=null;
  int cut;
  int dwIter;
  for (dwIter=0, cut=0; ; dwIter++) {
    if (tempDir != null) {
      cplex.exportModel(new File(tempDir,String.format("String_Node_Str",dwIter)).getAbsolutePath());
    }
    if (warmStart != null) {
      setWarmStart(warmStart);
    }
    simplexTimer.start();
    cplex.solve();
    simplexTimer.stop();
    warmStart=getWarmStart();
    status=RelaxStatus.get(cplex.getStatus());
    log.trace("String_Node_Str" + cplex.getStatus());
    if (status == RelaxStatus.Infeasible) {
      lowerBound=INTERNAL_WORST_SCORE;
      return new Pair<RelaxStatus,Double>(status,lowerBound);
    }
    if (dwIter >= maxDwIterations) {
      break;
    }
    if (tempDir != null) {
      cplex.writeSolution(new File(tempDir,String.format("String_Node_Str",dwIter)).getAbsolutePath());
    }
    double objVal=cplex.getObjValue();
    log.trace("String_Node_Str" + objVal);
    double prevObjVal=iterationObjVals.size() > 0 ? iterationObjVals.get(iterationObjVals.size() - 1) : INTERNAL_WORST_SCORE;
    if (objVal > prevObjVal + OBJ_VAL_DECREASE_TOLERANCE) {
      log.warn("String_Node_Str" + prevObjVal + "String_Node_Str"+ objVal);
    }
    iterationObjVals.add(objVal);
    double[] pricesLower=cplex.getDuals(mp.lpMatrix,0,idm.getNumTotalParams());
    double[] pricesUpper=cplex.getDuals(mp.lpMatrix,idm.getNumTotalParams(),idm.getNumTotalParams());
    int numConds=idm.getNumConds();
    double[][] parseWeights=new double[numConds][];
    int j=0;
    for (int c=0; c < numConds; c++) {
      int numParams=idm.getNumParams(c);
      parseWeights[c]=new double[numParams];
      for (int m=0; m < numParams; m++) {
        parseWeights[c][m]=(pricesLower[j] * bounds.getLb(c,m) + pricesUpper[j] * bounds.getUb(c,m));
        j++;
      }
    }
    DepProbMatrix dpm=idm.getDepProbMatrix(parseWeights);
    double[] convexLambdaPrices=cplex.getDuals(mp.lambdaSumCons);
    double sumReducedCost=0.0;
    int numPositiveLambdaRedCosts=0;
    for (int s=0; s < sentences.size(); s++) {
      parsingTimer.start();
      Pair<DepTree,Double> pPair=parser.parse(sentences.get(s),dpm);
      parsingTimer.stop();
      DepTree tree=pPair.get1();
      double pReducedCost=-pPair.get2() - convexLambdaPrices[s];
      if (pReducedCost < NEGATIVE_REDUCED_COST_TOLERANCE) {
        if (addLambdaVar(s,tree)) {
          numPositiveLambdaRedCosts++;
        }
 else {
          log.warn(String.format("String_Node_Str",pReducedCost,s,tree.getParents().toString()));
        }
      }
      sumReducedCost+=pReducedCost;
    }
    lowerBound=objVal + sumReducedCost;
    iterationLowerBounds.add(lowerBound);
    if (numPositiveLambdaRedCosts > 0 && sumReducedCost > 1e-6) {
      log.warn("String_Node_Str" + sumReducedCost);
    }
    if (lowerBound >= upperBound) {
      break;
    }
 else     if (numPositiveLambdaRedCosts == 0) {
      lowerBound=cplex.getObjValue();
      status=RelaxStatus.Optimal;
      if (cut < maxCutRounds) {
        log.debug(String.format("String_Node_Str",cut,iterationObjVals));
        iterationObjVals.clear();
        double[][] params=new double[idm.getNumConds()][];
        for (int c=0; c < idm.getNumConds(); c++) {
          params[c]=cplex.getValues(mp.modelParamVars[c]);
        }
        int numNewStoConstraints=0;
        for (int c=0; c < idm.getNumConds(); c++) {
          Vectors.exp(params[c]);
          if (Vectors.sum(params[c]) > minSumForCuts) {
            numNewStoConstraints++;
            addSumToOneConstraint(c,params[c]);
          }
        }
        if (numNewStoConstraints == 0) {
          log.debug("String_Node_Str" + cut + "String_Node_Str");
          break;
        }
        log.debug("String_Node_Str" + numNewStoConstraints + "String_Node_Str"+ cut);
        cut++;
      }
 else {
        break;
      }
    }
 else {
      log.debug("String_Node_Str" + numPositiveLambdaRedCosts + "String_Node_Str");
    }
  }
  lowerBound=Vectors.max(iterationLowerBounds.toNativeArray());
  log.debug("String_Node_Str" + cut);
  log.debug("String_Node_Str" + dwIter);
  log.debug("String_Node_Str" + maxDwIterations);
  log.debug("String_Node_Str" + lowerBound);
  log.debug(String.format("String_Node_Str",cut,iterationObjVals));
  log.debug("String_Node_Str" + iterationLowerBounds);
  log.debug("String_Node_Str" + Time.totMs(simplexTimer));
  log.debug("String_Node_Str" + Time.totMs(parsingTimer));
  return new Pair<RelaxStatus,Double>(status,lowerBound);
}

Fixed version (ground truth):
public Pair<RelaxStatus,Double> runDWAlgo(IloCplex cplex,MasterProblem mp,double upperBound) throws UnknownObjectException, IloException {
  if (!areFeasibleBounds(bounds)) {
    return new Pair<RelaxStatus,Double>(RelaxStatus.Infeasible,INTERNAL_WORST_SCORE);
  }
  RelaxStatus status=RelaxStatus.Unknown;
  DmvCkyParser parser=new DmvCkyParser();
  double lowerBound=INTERNAL_BEST_SCORE;
  TDoubleArrayList iterationLowerBounds=new TDoubleArrayList();
  TDoubleArrayList iterationObjVals=new TDoubleArrayList();
  WarmStart warmStart=null;
  int cut;
  int dwIter;
  for (dwIter=0, cut=0; ; dwIter++) {
    if (tempDir != null) {
      cplex.exportModel(new File(tempDir,String.format("String_Node_Str",dwIter)).getAbsolutePath());
    }
    if (warmStart != null) {
      setWarmStart(warmStart);
    }
    simplexTimer.start();
    cplex.solve();
    simplexTimer.stop();
    warmStart=getWarmStart();
    status=RelaxStatus.get(cplex.getStatus());
    log.trace("String_Node_Str" + cplex.getStatus());
    if (status == RelaxStatus.Infeasible) {
      lowerBound=INTERNAL_WORST_SCORE;
      return new Pair<RelaxStatus,Double>(status,lowerBound);
    }
    if (dwIter >= maxDwIterations) {
      break;
    }
    if (tempDir != null) {
      cplex.writeSolution(new File(tempDir,String.format("String_Node_Str",dwIter)).getAbsolutePath());
    }
    double objVal=cplex.getObjValue();
    log.trace("String_Node_Str" + objVal);
    double prevObjVal=iterationObjVals.size() > 0 ? iterationObjVals.get(iterationObjVals.size() - 1) : INTERNAL_WORST_SCORE;
    if (objVal > prevObjVal + OBJ_VAL_DECREASE_TOLERANCE) {
      log.warn("String_Node_Str" + prevObjVal + "String_Node_Str"+ objVal);
    }
    iterationObjVals.add(objVal);
    double[] pricesLower=cplex.getDuals(mp.lpMatrix,0,idm.getNumTotalParams());
    double[] pricesUpper=cplex.getDuals(mp.lpMatrix,idm.getNumTotalParams(),idm.getNumTotalParams());
    int numConds=idm.getNumConds();
    double[][] parseWeights=new double[numConds][];
    int j=0;
    for (int c=0; c < numConds; c++) {
      int numParams=idm.getNumParams(c);
      parseWeights[c]=new double[numParams];
      for (int m=0; m < numParams; m++) {
        parseWeights[c][m]=(pricesLower[j] * bounds.getLb(c,m) + pricesUpper[j] * bounds.getUb(c,m));
        j++;
      }
    }
    DepProbMatrix dpm=idm.getDepProbMatrix(parseWeights);
    double[] convexLambdaPrices=cplex.getDuals(mp.lambdaSumCons);
    double sumReducedCost=0.0;
    int numPositiveLambdaRedCosts=0;
    for (int s=0; s < sentences.size(); s++) {
      parsingTimer.start();
      Pair<DepTree,Double> pPair=parser.parse(sentences.get(s),dpm);
      parsingTimer.stop();
      DepTree tree=pPair.get1();
      double pReducedCost=-pPair.get2() - convexLambdaPrices[s];
      if (pReducedCost < NEGATIVE_REDUCED_COST_TOLERANCE) {
        if (addLambdaVar(s,tree)) {
          numPositiveLambdaRedCosts++;
        }
 else {
          log.warn(String.format("String_Node_Str",pReducedCost,s,tree.getParents().toString()));
        }
      }
      sumReducedCost+=pReducedCost;
    }
    lowerBound=objVal + sumReducedCost;
    iterationLowerBounds.add(lowerBound);
    if (numPositiveLambdaRedCosts > 0 && sumReducedCost > 1e-6) {
      log.warn("String_Node_Str" + sumReducedCost);
    }
    if (lowerBound >= upperBound) {
      status=RelaxStatus.Fathomed;
      break;
    }
 else     if (numPositiveLambdaRedCosts == 0) {
      lowerBound=cplex.getObjValue();
      status=RelaxStatus.Optimal;
      if (cut < maxCutRounds) {
        log.debug(String.format("String_Node_Str",cut,iterationObjVals));
        iterationObjVals.clear();
        double[][] params=new double[idm.getNumConds()][];
        for (int c=0; c < idm.getNumConds(); c++) {
          params[c]=cplex.getValues(mp.modelParamVars[c]);
        }
        int numNewStoConstraints=0;
        for (int c=0; c < idm.getNumConds(); c++) {
          Vectors.exp(params[c]);
          if (Vectors.sum(params[c]) > minSumForCuts) {
            numNewStoConstraints++;
            addSumToOneConstraint(c,params[c]);
          }
        }
        if (numNewStoConstraints == 0) {
          log.debug("String_Node_Str" + cut + "String_Node_Str");
          break;
        }
        log.debug("String_Node_Str" + numNewStoConstraints + "String_Node_Str"+ cut);
        cut++;
      }
 else {
        break;
      }
    }
 else {
      log.debug("String_Node_Str" + numPositiveLambdaRedCosts + "String_Node_Str");
    }
  }
  lowerBound=Vectors.max(iterationLowerBounds.toNativeArray());
  log.debug("String_Node_Str" + cut);
  log.debug("String_Node_Str" + dwIter);
  log.debug("String_Node_Str" + maxDwIterations);
  log.debug("String_Node_Str" + lowerBound);
  log.debug(String.format("String_Node_Str",cut,iterationObjVals));
  log.debug("String_Node_Str" + iterationLowerBounds);
  log.debug("String_Node_Str" + Time.totMs(simplexTimer));
  log.debug("String_Node_Str" + Time.totMs(parsingTimer));
  return new Pair<RelaxStatus,Double>(status,lowerBound);
}