Program: 131717
Project: 131717
Buggy source:
private ParsingProblem buildProgram(DmvTrainCorpus corpus,DmvModel model) throws IloException {
  ParsingProblem pp=new ParsingProblem();
  pp.arcRoot=new IloNumVar[corpus.size()][];
  pp.arcChild=new IloNumVar[corpus.size()][][];
  pp.flowRoot=new IloNumVar[corpus.size()][];
  pp.flowChild=new IloNumVar[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.arcRoot[s]=new IloNumVar[sent.size()];
    pp.arcChild[s]=new IloNumVar[sent.size()][sent.size()];
    pp.flowRoot[s]=new IloNumVar[sent.size()];
    pp.flowChild[s]=new IloNumVar[sent.size()][sent.size()];
    for (int c=0; c < sent.size(); c++) {
      pp.arcRoot[s][c]=cplex.numVar(0,1,String.format("String_Node_Str",s,c));
      pp.flowRoot[s][c]=cplex.numVar(0,sent.size(),String.format("String_Node_Str",s,c));
    }
    for (int p=0; p < sent.size(); p++) {
      for (int c=0; c < sent.size(); c++) {
        pp.arcChild[s][p][c]=cplex.numVar(0,1,String.format("String_Node_Str",s,p,c));
        pp.flowChild[s][p][c]=cplex.numVar(0,sent.size(),String.format("String_Node_Str",s,p,c));
      }
    }
  }
  pp.numToSide=new IloNumVar[corpus.size()][][];
  pp.genAdj=new IloNumVar[corpus.size()][][];
  pp.noGenAdj=new IloNumVar[corpus.size()][][];
  pp.numNonAdj=new IloNumVar[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.numToSide[s]=new IloNumVar[sent.size()][2];
    pp.genAdj[s]=new IloNumVar[sent.size()][2];
    pp.noGenAdj[s]=new IloNumVar[sent.size()][2];
    pp.numNonAdj[s]=new IloNumVar[sent.size()][2];
    for (int i=0; i < sent.size(); i++) {
      for (int side=0; side < 2; side++) {
        pp.numToSide[s][i][side]=cplex.numVar(0,sent.size(),String.format("String_Node_Str",s,i,side));
        pp.genAdj[s][i][side]=cplex.numVar(0,1,String.format("String_Node_Str",s,i,side));
        pp.noGenAdj[s][i][side]=cplex.numVar(0,1,String.format("String_Node_Str",s,i,side));
        pp.numNonAdj[s][i][side]=cplex.numVar(0,sent.size() - 1,String.format("String_Node_Str",s,i,side));
      }
    }
  }
  pp.oneArcPerWall=new IloRange[corpus.size()];
  for (int s=0; s < corpus.size(); s++) {
    double[] ones=new double[pp.arcRoot[s].length];
    Arrays.fill(ones,1.0);
    IloLinearNumExpr expr=cplex.scalProd(ones,pp.arcRoot[s]);
    pp.oneArcPerWall[s]=cplex.eq(expr,1.0,"String_Node_Str");
  }
  pp.oneParent=new IloRange[corpus.size()][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.oneParent[s]=new IloRange[sent.size()];
    for (int c=0; c < sent.size(); c++) {
      IloLinearNumExpr expr=cplex.linearNumExpr();
      for (int p=0; p < sent.size(); p++) {
        expr.addTerm(1.0,pp.arcChild[s][p][c]);
      }
      expr.addTerm(1.0,pp.arcRoot[s][c]);
      pp.oneParent[s][c]=cplex.eq(expr,1.0,"String_Node_Str");
    }
  }
  pp.rootFlowIsSentLength=new IloRange[corpus.size()];
  for (int s=0; s < corpus.size(); s++) {
    double[] ones=new double[pp.arcRoot[s].length];
    Arrays.fill(ones,1.0);
    IloLinearNumExpr expr=cplex.scalProd(ones,pp.flowRoot[s]);
    Sentence sent=corpus.getSentence(s);
    pp.rootFlowIsSentLength[s]=cplex.eq(expr,sent.size(),"String_Node_Str");
  }
  pp.flowDiff=new IloRange[corpus.size()][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.flowDiff[s]=new IloRange[sent.size()];
    for (int i=0; i < sent.size(); i++) {
      IloLinearNumExpr expr=cplex.linearNumExpr();
      for (int p=0; p < sent.size(); p++) {
        expr.addTerm(1.0,pp.flowChild[s][p][i]);
      }
      expr.addTerm(1.0,pp.flowRoot[s][i]);
      for (int c=0; c < sent.size(); c++) {
        expr.addTerm(-1.0,pp.flowChild[s][i][c]);
      }
      pp.flowDiff[s][i]=cplex.eq(expr,1.0,"String_Node_Str");
    }
  }
  pp.flowBound=new IloRange[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.flowBound[s]=new IloRange[sent.size()][sent.size()];
    for (int c=0; c < sent.size(); c++) {
      for (int p=0; p < sent.size(); p++) {
        IloLinearNumExpr expr=cplex.linearNumExpr();
        expr.addTerm(1.0,pp.flowChild[s][p][c]);
        expr.addTerm(-sent.size(),pp.arcChild[s][p][c]);
        pp.flowBound[s][p][c]=cplex.le(expr,0.0,"String_Node_Str");
      }
    }
  }
  if (formulation == IlpFormulation.FLOW_PROJ_LPRELAX) {
    pp.projectivity=new IloRange[corpus.size()][][];
    for (int s=0; s < corpus.size(); s++) {
      Sentence sent=corpus.getSentence(s);
      pp.projectivity[s]=new IloRange[sent.size()][sent.size()];
      for (int p=0; p < sent.size(); p++) {
        for (int c=0; c < sent.size(); c++) {
          if (c == p) {
            continue;
          }
          IloLinearNumExpr expr=cplex.linearNumExpr();
          for (int k=Math.min(p,c) + 1; k < Math.max(p,c); k++) {
            for (int l=0; l < sent.size(); l++) {
              if (l >= Math.min(p,c) && l <= Math.max(p,c)) {
                continue;
              }
              expr.addTerm(1.0,pp.arcChild[s][k][l]);
              expr.addTerm(1.0,pp.arcChild[s][l][k]);
            }
          }
          expr.addTerm(sent.size(),pp.arcChild[s][p][c]);
          pp.projectivity[s][p][c]=cplex.le(expr,sent.size(),"String_Node_Str");
        }
      }
    }
  }
  pp.numToSideCons=new IloRange[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.numToSideCons[s]=new IloRange[sent.size()][2];
    for (int p=0; p < sent.size(); p++) {
      for (int side=0; side < 2; side++) {
        IloLinearNumExpr expr=cplex.linearNumExpr();
        if (side == DmvModel.Lr.LEFT.getAsInt()) {
          for (int c=0; c < p - 1; c++) {
            expr.addTerm(1.0,pp.arcChild[s][p][c]);
          }
        }
 else {
          for (int c=p + 1; c < sent.size(); c++) {
            expr.addTerm(1.0,pp.arcChild[s][p][c]);
          }
        }
        expr.addTerm(-1.0,pp.numToSide[s][p][side]);
        pp.numToSideCons[s][p][side]=cplex.eq(expr,0.0,"String_Node_Str");
      }
    }
  }
  pp.genAdjCons=new IloRange[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.genAdjCons[s]=new IloRange[sent.size()][2];
    for (int p=0; p < sent.size(); p++) {
      for (int side=0; side < 2; side++) {
        IloLinearNumExpr expr=cplex.linearNumExpr();
        expr.addTerm(-1.0,pp.genAdj[s][p][side]);
        expr.addTerm(1.0 / sent.size(),pp.numToSide[s][p][side]);
        pp.genAdjCons[s][p][side]=cplex.le(expr,0.0,"String_Node_Str");
      }
    }
  }
  pp.numNonAdjCons=new IloRange[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.numNonAdjCons[s]=new IloRange[sent.size()][2];
    for (int p=0; p < sent.size(); p++) {
      for (int side=0; side < 2; side++) {
        IloLinearNumExpr expr=cplex.linearNumExpr();
        expr.addTerm(1.0,pp.numToSide[s][p][side]);
        expr.addTerm(-1.0,pp.genAdj[s][p][side]);
        expr.addTerm(-1.0,pp.numNonAdj[s][p][side]);
        pp.numNonAdjCons[s][p][side]=cplex.eq(expr,0.0,"String_Node_Str");
      }
    }
  }
  pp.noGenAdjCons=new IloRange[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.noGenAdjCons[s]=new IloRange[sent.size()][2];
    for (int p=0; p < sent.size(); p++) {
      for (int side=0; side < 2; side++) {
        IloLinearNumExpr expr=cplex.linearNumExpr();
        expr.addTerm(1.0,pp.genAdj[s][p][side]);
        expr.addTerm(1.0,pp.noGenAdj[s][p][side]);
        pp.noGenAdjCons[s][p][side]=cplex.eq(expr,1.0,"String_Node_Str");
      }
    }
  }
  pp.mat=cplex.LPMatrix();
  pp.mat.addRows(pp.oneArcPerWall);
  addRows(pp.mat,pp.oneParent);
  pp.mat.addRows(pp.rootFlowIsSentLength);
  addRows(pp.mat,pp.flowDiff);
  addRows(pp.mat,pp.flowBound);
  if (formulation == IlpFormulation.FLOW_PROJ_LPRELAX) {
    addRows(pp.mat,pp.projectivity);
  }
  addRows(pp.mat,pp.numToSideCons);
  addRows(pp.mat,pp.genAdjCons);
  addRows(pp.mat,pp.numNonAdjCons);
  addRows(pp.mat,pp.noGenAdjCons);
  pp.obj=cplex.maximize();
  IloLinearNumExpr expr=cplex.linearNumExpr();
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    DepSentenceDist sd=new DepSentenceDist(sent,model);
    for (int c=0; c < sent.size(); c++) {
      expr.addTerm(sd.root[c],pp.arcRoot[s][c]);
      for (int p=0; p < sent.size(); p++) {
        expr.addTerm(sd.child[c][p][0],pp.arcChild[s][p][c]);
      }
    }
    for (int p=0; p < sent.size(); p++) {
      for (int side=0; side < 2; side++) {
        expr.addTerm(sd.decision[p][side][0][0],pp.noGenAdj[s][p][side]);
        expr.addTerm(sd.decision[p][side][0][1] + sd.decision[p][side][1][0],pp.genAdj[s][p][side]);
        expr.addTerm(sd.decision[p][side][1][1],pp.numNonAdj[s][p][side]);
      }
    }
  }
  pp.obj.setExpr(expr);
  return pp;
}

Fixed version (ground truth):
private ParsingProblem buildProgram(DmvTrainCorpus corpus,DmvModel model) throws IloException {
  ParsingProblem pp=new ParsingProblem();
  pp.arcRoot=new IloNumVar[corpus.size()][];
  pp.arcChild=new IloNumVar[corpus.size()][][];
  pp.flowRoot=new IloNumVar[corpus.size()][];
  pp.flowChild=new IloNumVar[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.arcRoot[s]=new IloNumVar[sent.size()];
    pp.arcChild[s]=new IloNumVar[sent.size()][sent.size()];
    pp.flowRoot[s]=new IloNumVar[sent.size()];
    pp.flowChild[s]=new IloNumVar[sent.size()][sent.size()];
    for (int c=0; c < sent.size(); c++) {
      pp.arcRoot[s][c]=cplex.numVar(0,1,String.format("String_Node_Str",s,c));
      pp.flowRoot[s][c]=cplex.numVar(0,sent.size(),String.format("String_Node_Str",s,c));
    }
    for (int p=0; p < sent.size(); p++) {
      for (int c=0; c < sent.size(); c++) {
        if (p == c) {
          continue;
        }
        pp.arcChild[s][p][c]=cplex.numVar(0,1,String.format("String_Node_Str",s,p,c));
        pp.flowChild[s][p][c]=cplex.numVar(0,sent.size(),String.format("String_Node_Str",s,p,c));
      }
    }
  }
  pp.numToSide=new IloNumVar[corpus.size()][][];
  pp.genAdj=new IloNumVar[corpus.size()][][];
  pp.stopAdj=new IloNumVar[corpus.size()][][];
  pp.numNonAdj=new IloNumVar[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.numToSide[s]=new IloNumVar[sent.size()][2];
    pp.genAdj[s]=new IloNumVar[sent.size()][2];
    pp.stopAdj[s]=new IloNumVar[sent.size()][2];
    pp.numNonAdj[s]=new IloNumVar[sent.size()][2];
    for (int i=0; i < sent.size(); i++) {
      for (int side=0; side < 2; side++) {
        pp.numToSide[s][i][side]=cplex.numVar(0,sent.size(),String.format("String_Node_Str",s,i,side));
        pp.genAdj[s][i][side]=cplex.numVar(0,1,String.format("String_Node_Str",s,i,side));
        pp.stopAdj[s][i][side]=cplex.numVar(0,1,String.format("String_Node_Str",s,i,side));
        pp.numNonAdj[s][i][side]=cplex.numVar(0,sent.size() - 1,String.format("String_Node_Str",s,i,side));
      }
    }
  }
  pp.oneArcPerWall=new IloRange[corpus.size()];
  for (int s=0; s < corpus.size(); s++) {
    double[] ones=new double[pp.arcRoot[s].length];
    Arrays.fill(ones,1.0);
    IloLinearNumExpr expr=cplex.scalProd(ones,pp.arcRoot[s]);
    pp.oneArcPerWall[s]=cplex.eq(expr,1.0,"String_Node_Str");
  }
  pp.oneParent=new IloRange[corpus.size()][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.oneParent[s]=new IloRange[sent.size()];
    for (int c=0; c < sent.size(); c++) {
      IloLinearNumExpr expr=cplex.linearNumExpr();
      for (int p=0; p < sent.size(); p++) {
        if (p == c) {
          continue;
        }
        expr.addTerm(1.0,pp.arcChild[s][p][c]);
      }
      expr.addTerm(1.0,pp.arcRoot[s][c]);
      pp.oneParent[s][c]=cplex.eq(expr,1.0,"String_Node_Str");
    }
  }
  pp.rootFlowIsSentLength=new IloRange[corpus.size()];
  for (int s=0; s < corpus.size(); s++) {
    double[] ones=new double[pp.arcRoot[s].length];
    Arrays.fill(ones,1.0);
    IloLinearNumExpr expr=cplex.scalProd(ones,pp.flowRoot[s]);
    Sentence sent=corpus.getSentence(s);
    pp.rootFlowIsSentLength[s]=cplex.eq(expr,sent.size(),"String_Node_Str");
  }
  pp.flowDiff=new IloRange[corpus.size()][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.flowDiff[s]=new IloRange[sent.size()];
    for (int i=0; i < sent.size(); i++) {
      IloLinearNumExpr expr=cplex.linearNumExpr();
      for (int p=0; p < sent.size(); p++) {
        if (p == i) {
          continue;
        }
        expr.addTerm(1.0,pp.flowChild[s][p][i]);
      }
      expr.addTerm(1.0,pp.flowRoot[s][i]);
      for (int c=0; c < sent.size(); c++) {
        if (i == c) {
          continue;
        }
        expr.addTerm(-1.0,pp.flowChild[s][i][c]);
      }
      pp.flowDiff[s][i]=cplex.eq(expr,1.0,"String_Node_Str");
    }
  }
  pp.flowBoundRoot=new IloRange[corpus.size()][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.flowBoundRoot[s]=new IloRange[sent.size()];
    for (int c=0; c < sent.size(); c++) {
      IloLinearNumExpr expr=cplex.linearNumExpr();
      expr.addTerm(1.0,pp.flowRoot[s][c]);
      expr.addTerm(-sent.size(),pp.arcRoot[s][c]);
      pp.flowBoundRoot[s][c]=cplex.le(expr,0.0,"String_Node_Str");
    }
  }
  pp.flowBoundChild=new IloRange[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.flowBoundChild[s]=new IloRange[sent.size()][sent.size()];
    for (int c=0; c < sent.size(); c++) {
      for (int p=0; p < sent.size(); p++) {
        if (p == c) {
          continue;
        }
        IloLinearNumExpr expr=cplex.linearNumExpr();
        expr.addTerm(1.0,pp.flowChild[s][p][c]);
        expr.addTerm(-sent.size(),pp.arcChild[s][p][c]);
        pp.flowBoundChild[s][p][c]=cplex.le(expr,0.0,"String_Node_Str");
      }
    }
  }
  if (formulation == IlpFormulation.FLOW_PROJ_LPRELAX) {
    pp.projectiveRoot=new IloRange[corpus.size()][];
    for (int s=0; s < corpus.size(); s++) {
      Sentence sent=corpus.getSentence(s);
      pp.projectiveRoot[s]=new IloRange[sent.size()];
      for (int c=0; c < sent.size(); c++) {
        int p=-1;
        IloLinearNumExpr expr=cplex.linearNumExpr();
        for (int k=Math.min(p,c) + 1; k < Math.max(p,c); k++) {
          for (int l=0; l < sent.size(); l++) {
            if (l >= Math.min(p,c) && l <= Math.max(p,c)) {
              continue;
            }
            expr.addTerm(1.0,pp.arcChild[s][k][l]);
            expr.addTerm(1.0,pp.arcChild[s][l][k]);
          }
        }
        expr.addTerm(sent.size(),pp.arcRoot[s][c]);
        pp.projectiveRoot[s][c]=cplex.le(expr,sent.size(),"String_Node_Str");
      }
    }
    pp.projectiveChild=new IloRange[corpus.size()][][];
    for (int s=0; s < corpus.size(); s++) {
      Sentence sent=corpus.getSentence(s);
      pp.projectiveChild[s]=new IloRange[sent.size()][sent.size()];
      for (int c=0; c < sent.size(); c++) {
        for (int p=0; p < sent.size(); p++) {
          if (c == p) {
            continue;
          }
          IloLinearNumExpr expr=cplex.linearNumExpr();
          for (int k=Math.min(p,c) + 1; k < Math.max(p,c); k++) {
            for (int l=0; l < sent.size(); l++) {
              if (l >= Math.min(p,c) && l <= Math.max(p,c)) {
                continue;
              }
              expr.addTerm(1.0,pp.arcChild[s][k][l]);
              expr.addTerm(1.0,pp.arcChild[s][l][k]);
            }
          }
          expr.addTerm(sent.size(),pp.arcChild[s][p][c]);
          pp.projectiveChild[s][p][c]=cplex.le(expr,sent.size(),"String_Node_Str");
        }
      }
    }
  }
  pp.numToSideCons=new IloRange[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.numToSideCons[s]=new IloRange[sent.size()][2];
    for (int p=0; p < sent.size(); p++) {
      for (int side=0; side < 2; side++) {
        IloLinearNumExpr expr=cplex.linearNumExpr();
        if (side == DmvModel.Lr.LEFT.getAsInt()) {
          for (int c=0; c < p; c++) {
            expr.addTerm(1.0,pp.arcChild[s][p][c]);
          }
        }
 else {
          for (int c=p + 1; c < sent.size(); c++) {
            expr.addTerm(1.0,pp.arcChild[s][p][c]);
          }
        }
        expr.addTerm(-1.0,pp.numToSide[s][p][side]);
        pp.numToSideCons[s][p][side]=cplex.eq(expr,0.0,"String_Node_Str");
      }
    }
  }
  pp.genAdjCons=new IloRange[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.genAdjCons[s]=new IloRange[sent.size()][2];
    for (int p=0; p < sent.size(); p++) {
      for (int side=0; side < 2; side++) {
        IloLinearNumExpr expr=cplex.linearNumExpr();
        expr.addTerm(-1.0,pp.genAdj[s][p][side]);
        expr.addTerm(1.0 / sent.size(),pp.numToSide[s][p][side]);
        pp.genAdjCons[s][p][side]=cplex.le(expr,0.0,"String_Node_Str");
      }
    }
  }
  pp.numNonAdjCons=new IloRange[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.numNonAdjCons[s]=new IloRange[sent.size()][2];
    for (int p=0; p < sent.size(); p++) {
      for (int side=0; side < 2; side++) {
        IloLinearNumExpr expr=cplex.linearNumExpr();
        expr.addTerm(1.0,pp.numToSide[s][p][side]);
        expr.addTerm(-1.0,pp.genAdj[s][p][side]);
        expr.addTerm(-1.0,pp.numNonAdj[s][p][side]);
        pp.numNonAdjCons[s][p][side]=cplex.eq(expr,0.0,"String_Node_Str");
      }
    }
  }
  pp.stopAdjCons=new IloRange[corpus.size()][][];
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    pp.stopAdjCons[s]=new IloRange[sent.size()][2];
    for (int p=0; p < sent.size(); p++) {
      for (int side=0; side < 2; side++) {
        IloLinearNumExpr expr=cplex.linearNumExpr();
        expr.addTerm(1.0,pp.genAdj[s][p][side]);
        expr.addTerm(1.0,pp.stopAdj[s][p][side]);
        pp.stopAdjCons[s][p][side]=cplex.eq(expr,1.0,"String_Node_Str");
      }
    }
  }
  pp.mat=cplex.LPMatrix();
  pp.mat.addRows(pp.oneArcPerWall);
  CplexUtils.addRows(pp.mat,pp.oneParent);
  pp.mat.addRows(pp.rootFlowIsSentLength);
  CplexUtils.addRows(pp.mat,pp.flowDiff);
  CplexUtils.addRows(pp.mat,pp.flowBoundRoot);
  CplexUtils.addRows(pp.mat,pp.flowBoundChild);
  if (formulation == IlpFormulation.FLOW_PROJ_LPRELAX) {
    CplexUtils.addRows(pp.mat,pp.projectiveRoot);
    CplexUtils.addRows(pp.mat,pp.projectiveChild);
  }
  CplexUtils.addRows(pp.mat,pp.numToSideCons);
  CplexUtils.addRows(pp.mat,pp.genAdjCons);
  CplexUtils.addRows(pp.mat,pp.numNonAdjCons);
  CplexUtils.addRows(pp.mat,pp.stopAdjCons);
  pp.obj=cplex.maximize();
  IloLinearNumExpr expr=cplex.linearNumExpr();
  for (int s=0; s < corpus.size(); s++) {
    Sentence sent=corpus.getSentence(s);
    DepSentenceDist sd=new DepSentenceDist(sent,model);
    for (int c=0; c < sent.size(); c++) {
      expr.addTerm(sd.root[c],pp.arcRoot[s][c]);
      for (int p=0; p < sent.size(); p++) {
        if (p == c) {
          continue;
        }
        expr.addTerm(sd.child[c][p][0],pp.arcChild[s][p][c]);
      }
    }
    for (int p=0; p < sent.size(); p++) {
      for (int side=0; side < 2; side++) {
        expr.addTerm(sd.decision[p][side][0][0],pp.stopAdj[s][p][side]);
        expr.addTerm(sd.decision[p][side][0][1] + sd.decision[p][side][1][0],pp.genAdj[s][p][side]);
        expr.addTerm(sd.decision[p][side][1][1],pp.numNonAdj[s][p][side]);
      }
    }
  }
  pp.obj.setExpr(expr);
  return pp;
}