lemon/lp_base.h
changeset 799 6be1f9bd2ac0
parent 746 e4554cd6b2bf
child 834 207ba6c0f2e4
     1.1 --- a/lemon/lp_base.h	Sun Oct 04 10:15:32 2009 +0200
     1.2 +++ b/lemon/lp_base.h	Wed Dec 09 11:14:06 2009 +0100
     1.3 @@ -146,7 +146,7 @@
     1.4  
     1.5      ///Iterator for iterate over the columns of an LP problem
     1.6  
     1.7 -    /// Its usage is quite simple, for example you can count the number
     1.8 +    /// Its usage is quite simple, for example, you can count the number
     1.9      /// of columns in an LP \c lp:
    1.10      ///\code
    1.11      /// int count=0;
    1.12 @@ -241,7 +241,7 @@
    1.13  
    1.14      ///Iterator for iterate over the rows of an LP problem
    1.15  
    1.16 -    /// Its usage is quite simple, for example you can count the number
    1.17 +    /// Its usage is quite simple, for example, you can count the number
    1.18      /// of rows in an LP \c lp:
    1.19      ///\code
    1.20      /// int count=0;
    1.21 @@ -943,6 +943,14 @@
    1.22      virtual int _addCol() = 0;
    1.23      virtual int _addRow() = 0;
    1.24  
    1.25 +    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u) {
    1.26 +      int row = _addRow();
    1.27 +      _setRowCoeffs(row, b, e);
    1.28 +      _setRowLowerBound(row, l);
    1.29 +      _setRowUpperBound(row, u);
    1.30 +      return row;
    1.31 +    }
    1.32 +
    1.33      virtual void _eraseCol(int col) = 0;
    1.34      virtual void _eraseRow(int row) = 0;
    1.35  
    1.36 @@ -1207,8 +1215,10 @@
    1.37      ///\param u is the upper bound (\ref INF means no bound)
    1.38      ///\return The created row.
    1.39      Row addRow(Value l,const Expr &e, Value u) {
    1.40 -      Row r=addRow();
    1.41 -      row(r,l,e,u);
    1.42 +      Row r;
    1.43 +      e.simplify();
    1.44 +      r._id = _addRowId(_addRow(l - *e, ExprIterator(e.comps.begin(), cols),
    1.45 +                                ExprIterator(e.comps.end(), cols), u - *e));
    1.46        return r;
    1.47      }
    1.48  
    1.49 @@ -1217,8 +1227,12 @@
    1.50      ///\param c is a linear expression (see \ref Constr)
    1.51      ///\return The created row.
    1.52      Row addRow(const Constr &c) {
    1.53 -      Row r=addRow();
    1.54 -      row(r,c);
    1.55 +      Row r;
    1.56 +      c.expr().simplify();
    1.57 +      r._id = _addRowId(_addRow(c.lowerBounded()?c.lowerBound():-INF, 
    1.58 +                                ExprIterator(c.expr().comps.begin(), cols),
    1.59 +                                ExprIterator(c.expr().comps.end(), cols),
    1.60 +                                c.upperBounded()?c.upperBound():INF));
    1.61        return r;
    1.62      }
    1.63      ///Erase a column (i.e a variable) from the LP