COIN-OR::LEMON - Graph Library

Changeset 1431:ad44b1dd8013 in lemon-0.x for src/lemon/lp_glpk.cc


Ignore:
Timestamp:
05/20/05 11:31:25 (15 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1905
Message:

Added function _setCoeff().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/lp_glpk.cc

    r1405 r1431  
    8888                    const_cast<Value * >(values));
    8989  }
    90  
     90
     91
     92  void LpGlpk::_setCoeff(int row, int col, Value value)
     93  {
     94    ///FIXME Of course this is not efficient at all, but GLPK knows not more.
     95    // First approach: get one row, apply changes and set it again
     96    //(one idea to improve this: maybe it is better to do this with 1 coloumn)
     97   
     98    int mem_length=2+lpx_get_num_cols(lp);
     99    int* indices = new int[mem_length];
     100    Value* values = new Value[mem_length];
     101   
     102
     103    int length=lpx_get_mat_row(lp, row, indices, values);
     104
     105    //The following code does not suppose that the elements of the array indices are sorted
     106    int i=1;
     107    bool found=false;
     108    while (i <= length && !found){
     109      if (indices[i]==col){
     110        found = true;
     111        values[i]=value;
     112      }
     113      ++i;
     114    }
     115    if (!found){
     116      ++length;
     117      indices[length]=col;
     118      values[length]=value;
     119    }
     120   
     121    lpx_set_mat_row(lp, row, length, indices, values);
     122    delete [] indices;
     123    delete [] values;
     124   
     125  }
     126
    91127  void LpGlpk::_setColLowerBound(int i, Value lo)
    92128  {
Note: See TracChangeset for help on using the changeset viewer.