src/lemon/lp_base.h
changeset 1340 80da1eadcaa7
parent 1323 3aaadfb7de3d
child 1359 1581f961cfaa
equal deleted inserted replaced
2:e502f15e6b79 3:39eea6d4de85
    28 
    28 
    29 //#include"lin_expr.h"
    29 //#include"lin_expr.h"
    30 
    30 
    31 ///\file
    31 ///\file
    32 ///\brief The interface of the LP solver interface.
    32 ///\brief The interface of the LP solver interface.
       
    33 ///\ingroup gen_opt_group
    33 namespace lemon {
    34 namespace lemon {
    34   
    35   
    35   ///Internal data structure to convert floating id's to fix one's
    36   ///Internal data structure to convert floating id's to fix one's
    36     
    37     
    37   ///\todo This might be implemented to be also usable in other places.
    38   ///\todo This might be implemented to be also usable in other places.
    98     std::size_t maxFixId() { return cross.size()-1; }
    99     std::size_t maxFixId() { return cross.size()-1; }
    99   
   100   
   100   };
   101   };
   101     
   102     
   102   ///Common base class for LP solvers
   103   ///Common base class for LP solvers
       
   104   
       
   105   ///\todo Much more docs
       
   106   ///\ingroup gen_opt_group
   103   class LpSolverBase {
   107   class LpSolverBase {
   104 
   108 
   105   public:
   109   public:
   106 
   110 
   107     ///\e
   111     ///\e
   215     ///\code
   219     ///\code
   216     ///v+w
   220     ///v+w
   217     ///2*v-3.12*(v-w/2)+2
   221     ///2*v-3.12*(v-w/2)+2
   218     ///v*2.1+(3*v+(v*12+w+6)*3)/2
   222     ///v*2.1+(3*v+(v*12+w+6)*3)/2
   219     ///\endcode
   223     ///\endcode
   220     ///are valid expressions. The usual assignment operations are also defined.
   224     ///are valid \ref Expr "Expr"essions.
       
   225     ///The usual assignment operations are also defined.
   221     ///\code
   226     ///\code
   222     ///e=v+w;
   227     ///e=v+w;
   223     ///e+=2*v-3.12*(v-w/2)+2;
   228     ///e+=2*v-3.12*(v-w/2)+2;
   224     ///e*=3.4;
   229     ///e*=3.4;
   225     ///e/=5;
   230     ///e/=5;
   228     ///\code
   233     ///\code
   229     ///e.constComp()=12;
   234     ///e.constComp()=12;
   230     ///double c=e.constComp();
   235     ///double c=e.constComp();
   231     ///\endcode
   236     ///\endcode
   232     ///
   237     ///
   233     ///\note that \ref clear() not only sets all coefficients to 0 but also
   238     ///\note \ref clear() not only sets all coefficients to 0 but also
   234     ///clears the constant components.
   239     ///clears the constant components.
       
   240     ///
       
   241     ///\sa Constr
       
   242     ///
   235     class Expr : public std::map<Col,Value>
   243     class Expr : public std::map<Col,Value>
   236     {
   244     {
   237     public:
   245     public:
   238       typedef LpSolverBase::Col Key; 
   246       typedef LpSolverBase::Col Key; 
   239       typedef LpSolverBase::Value Value;
   247       typedef LpSolverBase::Value Value;
   307 	return *this;
   315 	return *this;
   308       }
   316       }
   309     };
   317     };
   310     
   318     
   311     ///Linear constraint
   319     ///Linear constraint
   312     //typedef LinConstr<Expr> Constr;
   320 
       
   321     ///\todo document please
       
   322     ///
   313     class Constr
   323     class Constr
   314     {
   324     {
   315     public:
   325     public:
   316       typedef LpSolverBase::Expr Expr;
   326       typedef LpSolverBase::Expr Expr;
   317       typedef Expr::Key Key;
   327       typedef Expr::Key Key;
   501     ///\param l is lower bound (-\ref INF means no bound)
   511     ///\param l is lower bound (-\ref INF means no bound)
   502     ///\param e is a linear expression (see \ref Expr)
   512     ///\param e is a linear expression (see \ref Expr)
   503     ///\param u is the upper bound (\ref INF means no bound)
   513     ///\param u is the upper bound (\ref INF means no bound)
   504     ///\bug This is a temportary function. The interface will change to
   514     ///\bug This is a temportary function. The interface will change to
   505     ///a better one.
   515     ///a better one.
       
   516     ///\todo Option to control whether a constraint with a single variable is
       
   517     ///added or not.
   506     void setRow(Row r, Value l,const Expr &e, Value u) {
   518     void setRow(Row r, Value l,const Expr &e, Value u) {
   507       std::vector<int> indices;
   519       std::vector<int> indices;
   508       std::vector<Value> values;
   520       std::vector<Value> values;
   509       indices.push_back(0);
   521       indices.push_back(0);
   510       values.push_back(0);
   522       values.push_back(0);