COIN-OR::LEMON - Graph Library

Changeset 1431:ad44b1dd8013 in lemon-0.x


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

Added function _setCoeff().

Location:
src/lemon
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/lp_base.h

    r1405 r1431  
    430430                               int  const * indices,
    431431                               Value  const * values ) = 0;
     432    virtual void _setCoeff(int row, int col, Value value) = 0;
    432433    virtual void _setColLowerBound(int i, Value value) = 0;
    433434    virtual void _setColUpperBound(int i, Value value) = 0;
  • src/lemon/lp_cplex.cc

    r1407 r1431  
    132132  }
    133133 
     134  void LpCplex::_setCoeff(int row, int col, Value value)
     135  {
     136    CPXchgcoef (env, lp, row, col, value);
     137  }
     138
    134139  void LpCplex::_setColLowerBound(int i, Value value)
    135140  {
  • src/lemon/lp_cplex.h

    r1405 r1431  
    6464                               const int   * indices,
    6565                               const Value   * values);
     66    virtual void _setCoeff(int row, int col, Value value);
    6667    virtual void _setColLowerBound(int i, Value value);
    6768    virtual void _setColUpperBound(int i, Value value);
  • 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  {
  • src/lemon/lp_glpk.h

    r1405 r1431  
    5959                               const int   * indices,
    6060                               const Value   * values);
     61    virtual void _setCoeff(int row, int col, Value value);
    6162    virtual void _setColLowerBound(int i, Value value);
    6263    virtual void _setColUpperBound(int i, Value value);
  • src/lemon/lp_skeleton.cc

    r1405 r1431  
    5757  {
    5858  }
    59  
     59
     60  void LpSkeleton::_setCoeff(int, int, Value )
     61  {
     62  }
     63
     64
    6065  void LpSkeleton::_setColLowerBound(int, Value)
    6166  {
  • src/lemon/lp_skeleton.h

    r1405 r1431  
    5555                               Value  const * values );
    5656   
    57     /// \e
     57    /// Set one element of the coefficient matrix
     58    virtual void _setCoeff(int row, int col, Value value);
    5859
    5960    /// The lower bound of a variable (column) have to be given by an
Note: See TracChangeset for help on using the changeset viewer.