lemon/glpk.cc
changeset 848 e05b2b48515a
parent 576 745e182d0139
child 877 141f9c0db4a3
equal deleted inserted replaced
9:cf4ae847dc52 10:49d8ccefc1da
    54   }
    54   }
    55 
    55 
    56   int GlpkBase::_addRow() {
    56   int GlpkBase::_addRow() {
    57     int i = glp_add_rows(lp, 1);
    57     int i = glp_add_rows(lp, 1);
    58     glp_set_row_bnds(lp, i, GLP_FR, 0.0, 0.0);
    58     glp_set_row_bnds(lp, i, GLP_FR, 0.0, 0.0);
       
    59     return i;
       
    60   }
       
    61 
       
    62   int GlpkBase::_addRow(Value lo, ExprIterator b, 
       
    63                         ExprIterator e, Value up) {
       
    64     int i = glp_add_rows(lp, 1);
       
    65 
       
    66     if (lo == -INF) {
       
    67       if (up == INF) {
       
    68         glp_set_row_bnds(lp, i, GLP_FR, lo, up);
       
    69       } else {
       
    70         glp_set_row_bnds(lp, i, GLP_UP, lo, up);
       
    71       }    
       
    72     } else {
       
    73       if (up == INF) {
       
    74         glp_set_row_bnds(lp, i, GLP_LO, lo, up);
       
    75       } else if (lo != up) {        
       
    76         glp_set_row_bnds(lp, i, GLP_DB, lo, up);
       
    77       } else {
       
    78         glp_set_row_bnds(lp, i, GLP_FX, lo, up);
       
    79       }
       
    80     }
       
    81 
       
    82     std::vector<int> indexes;
       
    83     std::vector<Value> values;
       
    84 
       
    85     indexes.push_back(0);
       
    86     values.push_back(0);
       
    87 
       
    88     for(ExprIterator it = b; it != e; ++it) {
       
    89       indexes.push_back(it->first);
       
    90       values.push_back(it->second);
       
    91     }
       
    92 
       
    93     glp_set_mat_row(lp, i, values.size() - 1,
       
    94                     &indexes.front(), &values.front());
    59     return i;
    95     return i;
    60   }
    96   }
    61 
    97 
    62   void GlpkBase::_eraseCol(int i) {
    98   void GlpkBase::_eraseCol(int i) {
    63     int ca[2];
    99     int ca[2];