lemon/cplex.cc
changeset 942 2b6bffe0e7e8
parent 746 e4554cd6b2bf
child 956 4764031c082c
     1.1 --- a/lemon/cplex.cc	Tue Dec 20 17:44:38 2011 +0100
     1.2 +++ b/lemon/cplex.cc	Tue Dec 20 18:15:14 2011 +0100
     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 @@ -111,6 +111,39 @@
    1.13      return i;
    1.14    }
    1.15  
    1.16 +  int CplexBase::_addRow(Value lb, ExprIterator b,
    1.17 +                         ExprIterator e, Value ub) {
    1.18 +    int i = CPXgetnumrows(cplexEnv(), _prob);
    1.19 +    if (lb == -INF) {
    1.20 +      const char s = 'L';
    1.21 +      CPXnewrows(cplexEnv(), _prob, 1, &ub, &s, 0, 0);
    1.22 +    } else if (ub == INF) {
    1.23 +      const char s = 'G';
    1.24 +      CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, 0, 0);
    1.25 +    } else if (lb == ub){
    1.26 +      const char s = 'E';
    1.27 +      CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, 0, 0);
    1.28 +    } else {
    1.29 +      const char s = 'R';
    1.30 +      double len = ub - lb;
    1.31 +      CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, &len, 0);
    1.32 +    }
    1.33 +
    1.34 +    std::vector<int> indices;
    1.35 +    std::vector<int> rowlist;
    1.36 +    std::vector<Value> values;
    1.37 +
    1.38 +    for(ExprIterator it=b; it!=e; ++it) {
    1.39 +      indices.push_back(it->first);
    1.40 +      values.push_back(it->second);
    1.41 +      rowlist.push_back(i);
    1.42 +    }
    1.43 +
    1.44 +    CPXchgcoeflist(cplexEnv(), _prob, values.size(),
    1.45 +                   &rowlist.front(), &indices.front(), &values.front());
    1.46 +
    1.47 +    return i;
    1.48 +  }
    1.49  
    1.50    void CplexBase::_eraseCol(int i) {
    1.51      CPXdelcols(cplexEnv(), _prob, i, i);
    1.52 @@ -456,7 +489,7 @@
    1.53    }
    1.54  
    1.55    void CplexBase::_applyMessageLevel() {
    1.56 -    CPXsetintparam(cplexEnv(), CPX_PARAM_SCRIND, 
    1.57 +    CPXsetintparam(cplexEnv(), CPX_PARAM_SCRIND,
    1.58                     _message_enabled ? CPX_ON : CPX_OFF);
    1.59    }
    1.60