COIN-OR::LEMON - Graph Library

Changeset 1895:5b01801efbc0 in lemon-0.x for lemon/lp_base.h


Ignore:
Timestamp:
01/14/06 09:44:59 (18 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2470
Message:
  • colName() added (untested on CPLEX)
  • possibility to set lower/upper bounds of several cols at once
  • setObj() -> obj()
  • setRow() -> row()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/lp_base.h

    r1875 r1895  
    573573    virtual void _eraseCol(int col) = 0;
    574574    virtual void _eraseRow(int row) = 0;
     575    virtual void _getColName(int col,       std::string & name) = 0;
     576    virtual void _setColName(int col, const std::string & name) = 0;
    575577    virtual void _setRowCoeffs(int i,
    576578                               int length,
     
    809811    ///\todo Option to control whether a constraint with a single variable is
    810812    ///added or not.
    811     void setRow(Row r, Value l,const Expr &e, Value u) {
     813    void row(Row r, Value l,const Expr &e, Value u) {
    812814      std::vector<int> indices;
    813815      std::vector<Value> values;
     
    830832    ///\param r is the row to be modified
    831833    ///\param c is a linear expression (see \ref Constr)
    832     void setRow(Row r, const Constr &c) {
    833       setRow(r,
     834    void row(Row r, const Constr &c) {
     835      row(r,
    834836             c.lowerBounded()?c.lowerBound():-INF,
    835837             c.expr(),
     
    847849    Row addRow(Value l,const Expr &e, Value u) {
    848850      Row r=addRow();
    849       setRow(r,l,e,u);
     851      row(r,l,e,u);
    850852      return r;
    851853    }
     
    857859    Row addRow(const Constr &c) {
    858860      Row r=addRow();
    859       setRow(r,c);
     861      row(r,c);
    860862      return r;
    861863    }
     
    877879    }
    878880
    879     ///Set an element of the coefficient matrix of the LP
     881    /// Get the name of a column
     882   
     883    ///\param c is the coresponding coloumn
     884    ///\return The name of the colunm
     885    std::string ColName(Col c){
     886      std::string name;
     887      _getColName(cols.floatingId(c.id), name);
     888      return name;
     889    }
     890   
     891    /// Set the name of a column
     892   
     893    ///\param c is the coresponding coloumn
     894    ///\param name The name to be given
     895    void ColName(Col c, const std::string & name){
     896      _setColName(cols.floatingId(c.id), name);
     897    }
     898   
     899    /// Set an element of the coefficient matrix of the LP
    880900
    881901    ///\param r is the row of the element to be modified
    882902    ///\param c is the coloumn of the element to be modified
    883903    ///\param val is the new value of the coefficient
    884     void setCoeff(Row r, Col c, Value val){
     904
     905    void Coeff(Row r, Col c, Value val){
    885906      _setCoeff(rows.floatingId(r.id),cols.floatingId(c.id), val);
    886907    }
     
    888909    /// Set the lower bound of a column (i.e a variable)
    889910
    890     /// The upper bound of a variable (column) has to be given by an
     911    /// The lower bound of a variable (column) has to be given by an
    891912    /// extended number of type Value, i.e. a finite number of type
    892913    /// Value or -\ref INF.
     
    894915      _setColLowerBound(cols.floatingId(c.id),value);
    895916    }
     917   
     918    ///\brief Set the lower bound of  several columns
     919    ///(i.e a variables) at once
     920    ///
     921    ///This magic function takes a container as its argument
     922    ///and applies the function on all of its elements.
     923    /// The lower bound of a variable (column) has to be given by an
     924    /// extended number of type Value, i.e. a finite number of type
     925    /// Value or -\ref INF.
     926#ifdef DOXYGEN
     927    template<class T>
     928    void colLowerBound(T &t, Value value) { return 0;}
     929#else
     930    template<class T>
     931    typename enable_if<typename T::value_type::LpSolverCol,void>::type
     932    colLowerBound(T &t, Value value,dummy<0> = 0) {
     933      for(typename T::iterator i=t.begin();i!=t.end();++i) {
     934        colLowerBound(*i, value);
     935      }
     936    }
     937    template<class T>
     938    typename enable_if<typename T::value_type::second_type::LpSolverCol,
     939                       void>::type
     940    colLowerBound(T &t, Value value,dummy<1> = 1) {
     941      for(typename T::iterator i=t.begin();i!=t.end();++i) {
     942        colLowerBound(i->second, value);
     943      }
     944    }
     945    template<class T>
     946    typename enable_if<typename T::MapIt::Value::LpSolverCol,
     947                       void>::type
     948    colLowerBound(T &t, Value value,dummy<2> = 2) {
     949      for(typename T::MapIt i(t); i!=INVALID; ++i){
     950        colLowerBound(*i, value);
     951      }
     952    }
     953#endif
     954   
    896955    /// Set the upper bound of a column (i.e a variable)
    897956
     
    902961      _setColUpperBound(cols.floatingId(c.id),value);
    903962    };
     963
     964    ///\brief Set the lower bound of  several columns
     965    ///(i.e a variables) at once
     966    ///
     967    ///This magic function takes a container as its argument
     968    ///and applies the function on all of its elements.
     969    /// The upper bound of a variable (column) has to be given by an
     970    /// extended number of type Value, i.e. a finite number of type
     971    /// Value or \ref INF.
     972#ifdef DOXYGEN
     973    template<class T>
     974    void colUpperBound(T &t, Value value) { return 0;}
     975#else
     976    template<class T>
     977    typename enable_if<typename T::value_type::LpSolverCol,void>::type
     978    colUpperBound(T &t, Value value,dummy<0> = 0) {
     979      for(typename T::iterator i=t.begin();i!=t.end();++i) {
     980        colUpperBound(*i, value);
     981      }
     982    }
     983    template<class T>
     984    typename enable_if<typename T::value_type::second_type::LpSolverCol,
     985                       void>::type
     986    colUpperBound(T &t, Value value,dummy<1> = 1) {
     987      for(typename T::iterator i=t.begin();i!=t.end();++i) {
     988        colUpperBound(i->second, value);
     989      }
     990    }
     991    template<class T>
     992    typename enable_if<typename T::MapIt::Value::LpSolverCol,
     993                       void>::type
     994    colUpperBound(T &t, Value value,dummy<2> = 2) {
     995      for(typename T::MapIt i(t); i!=INVALID; ++i){
     996        colUpperBound(*i, value);
     997      }
     998    }
     999#endif
     1000
    9041001    /// Set the lower and the upper bounds of a column (i.e a variable)
    9051002
     
    9131010    }
    9141011   
     1012    ///\brief Set the lower and the upper bound of several columns
     1013    ///(i.e a variables) at once
     1014    ///
     1015    ///This magic function takes a container as its argument
     1016    ///and applies the function on all of its elements.
     1017    /// The lower and the upper bounds of
     1018    /// a variable (column) have to be given by an
     1019    /// extended number of type Value, i.e. a finite number of type
     1020    /// Value, -\ref INF or \ref INF.
     1021#ifdef DOXYGEN
     1022    template<class T>
     1023    void colBounds(T &t, Value lower, Value upper) { return 0;}
     1024#else
     1025    template<class T>
     1026    typename enable_if<typename T::value_type::LpSolverCol,void>::type
     1027    colBounds(T &t, Value lower, Value upper,dummy<0> = 0) {
     1028      for(typename T::iterator i=t.begin();i!=t.end();++i) {
     1029        colBounds(*i, lower, upper);
     1030      }
     1031    }
     1032    template<class T>
     1033    typename enable_if<typename T::value_type::second_type::LpSolverCol,
     1034                       void>::type
     1035    colBounds(T &t, Value lower, Value upper,dummy<1> = 1) {
     1036      for(typename T::iterator i=t.begin();i!=t.end();++i) {
     1037        colBounds(i->second, lower, upper);
     1038      }
     1039    }
     1040    template<class T>
     1041    typename enable_if<typename T::MapIt::Value::LpSolverCol,
     1042                       void>::type
     1043    colBounds(T &t, Value lower, Value upper,dummy<2> = 2) {
     1044      for(typename T::MapIt i(t); i!=INVALID; ++i){
     1045        colBounds(*i, lower, upper);
     1046      }
     1047    }
     1048#endif
     1049   
    9151050//     /// Set the lower bound of a row (i.e a constraint)
    9161051
     
    9461081   
    9471082    ///\param e is a linear expression of type \ref Expr.
     1083    ///\bug Is should be called obj()
    9481084    void setObj(Expr e) {
    9491085      _clearObj();
Note: See TracChangeset for help on using the changeset viewer.