lemon/glpk.cc
changeset 993 ad40f7d32846
parent 877 141f9c0db4a3
parent 955 8d281761dea4
     1.1 --- a/lemon/glpk.cc	Fri Aug 09 11:07:27 2013 +0200
     1.2 +++ b/lemon/glpk.cc	Sun Aug 11 15:28:12 2013 +0200
     1.3 @@ -2,7 +2,7 @@
     1.4   *
     1.5   * This file is a part of LEMON, a generic C++ optimization library.
     1.6   *
     1.7 - * Copyright (C) 2003-2009
     1.8 + * Copyright (C) 2003-2010
     1.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11   *
    1.12 @@ -59,6 +59,42 @@
    1.13      return i;
    1.14    }
    1.15  
    1.16 +  int GlpkBase::_addRow(Value lo, ExprIterator b,
    1.17 +                        ExprIterator e, Value up) {
    1.18 +    int i = glp_add_rows(lp, 1);
    1.19 +
    1.20 +    if (lo == -INF) {
    1.21 +      if (up == INF) {
    1.22 +        glp_set_row_bnds(lp, i, GLP_FR, lo, up);
    1.23 +      } else {
    1.24 +        glp_set_row_bnds(lp, i, GLP_UP, lo, up);
    1.25 +      }
    1.26 +    } else {
    1.27 +      if (up == INF) {
    1.28 +        glp_set_row_bnds(lp, i, GLP_LO, lo, up);
    1.29 +      } else if (lo != up) {
    1.30 +        glp_set_row_bnds(lp, i, GLP_DB, lo, up);
    1.31 +      } else {
    1.32 +        glp_set_row_bnds(lp, i, GLP_FX, lo, up);
    1.33 +      }
    1.34 +    }
    1.35 +
    1.36 +    std::vector<int> indexes;
    1.37 +    std::vector<Value> values;
    1.38 +
    1.39 +    indexes.push_back(0);
    1.40 +    values.push_back(0);
    1.41 +
    1.42 +    for(ExprIterator it = b; it != e; ++it) {
    1.43 +      indexes.push_back(it->first);
    1.44 +      values.push_back(it->second);
    1.45 +    }
    1.46 +
    1.47 +    glp_set_mat_row(lp, i, values.size() - 1,
    1.48 +                    &indexes.front(), &values.front());
    1.49 +    return i;
    1.50 +  }
    1.51 +
    1.52    void GlpkBase::_eraseCol(int i) {
    1.53      int ca[2];
    1.54      ca[1] = i;