lemon/glpk.cc
changeset 780 580af8cf2f6a
parent 576 745e182d0139
child 877 141f9c0db4a3
     1.1 --- a/lemon/glpk.cc	Thu Nov 05 10:01:02 2009 +0100
     1.2 +++ b/lemon/glpk.cc	Thu Nov 05 10:23:16 2009 +0100
     1.3 @@ -59,6 +59,42 @@
     1.4      return i;
     1.5    }
     1.6  
     1.7 +  int GlpkBase::_addRow(Value lo, ExprIterator b, 
     1.8 +                        ExprIterator e, Value up) {
     1.9 +    int i = glp_add_rows(lp, 1);
    1.10 +
    1.11 +    if (lo == -INF) {
    1.12 +      if (up == INF) {
    1.13 +        glp_set_row_bnds(lp, i, GLP_FR, lo, up);
    1.14 +      } else {
    1.15 +        glp_set_row_bnds(lp, i, GLP_UP, lo, up);
    1.16 +      }    
    1.17 +    } else {
    1.18 +      if (up == INF) {
    1.19 +        glp_set_row_bnds(lp, i, GLP_LO, lo, up);
    1.20 +      } else if (lo != up) {        
    1.21 +        glp_set_row_bnds(lp, i, GLP_DB, lo, up);
    1.22 +      } else {
    1.23 +        glp_set_row_bnds(lp, i, GLP_FX, lo, up);
    1.24 +      }
    1.25 +    }
    1.26 +
    1.27 +    std::vector<int> indexes;
    1.28 +    std::vector<Value> values;
    1.29 +
    1.30 +    indexes.push_back(0);
    1.31 +    values.push_back(0);
    1.32 +
    1.33 +    for(ExprIterator it = b; it != e; ++it) {
    1.34 +      indexes.push_back(it->first);
    1.35 +      values.push_back(it->second);
    1.36 +    }
    1.37 +
    1.38 +    glp_set_mat_row(lp, i, values.size() - 1,
    1.39 +                    &indexes.front(), &values.front());
    1.40 +    return i;
    1.41 +  }
    1.42 +
    1.43    void GlpkBase::_eraseCol(int i) {
    1.44      int ca[2];
    1.45      ca[1] = i;