lemon/cplex.cc
changeset 782 ceb2756dea2a
parent 576 745e182d0139
child 877 141f9c0db4a3
     1.1 --- a/lemon/cplex.cc	Mon Sep 28 15:53:20 2009 +0200
     1.2 +++ b/lemon/cplex.cc	Thu Nov 05 10:27:17 2009 +0100
     1.3 @@ -111,6 +111,39 @@
     1.4      return i;
     1.5    }
     1.6  
     1.7 +  int CplexBase::_addRow(Value lb, ExprIterator b, 
     1.8 +                         ExprIterator e, Value ub) {
     1.9 +    int i = CPXgetnumrows(cplexEnv(), _prob);
    1.10 +    if (lb == -INF) {
    1.11 +      const char s = 'L';
    1.12 +      CPXnewrows(cplexEnv(), _prob, 1, &ub, &s, 0, 0);
    1.13 +    } else if (ub == INF) {
    1.14 +      const char s = 'G';
    1.15 +      CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, 0, 0);
    1.16 +    } else if (lb == ub){
    1.17 +      const char s = 'E';
    1.18 +      CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, 0, 0);
    1.19 +    } else {
    1.20 +      const char s = 'R';
    1.21 +      double len = ub - lb;
    1.22 +      CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, &len, 0);
    1.23 +    }
    1.24 +
    1.25 +    std::vector<int> indices;
    1.26 +    std::vector<int> rowlist;
    1.27 +    std::vector<Value> values;
    1.28 +
    1.29 +    for(ExprIterator it=b; it!=e; ++it) {
    1.30 +      indices.push_back(it->first);
    1.31 +      values.push_back(it->second);
    1.32 +      rowlist.push_back(i);
    1.33 +    }
    1.34 +
    1.35 +    CPXchgcoeflist(cplexEnv(), _prob, values.size(),
    1.36 +                   &rowlist.front(), &indices.front(), &values.front());
    1.37 +
    1.38 +    return i;
    1.39 +  }
    1.40  
    1.41    void CplexBase::_eraseCol(int i) {
    1.42      CPXdelcols(cplexEnv(), _prob, i, i);