src/work/athos/lp/lp_base.h
changeset 1289 142633fc5014
parent 1275 16980bf77bd3
child 1291 16cde3e1aa9f
equal deleted inserted replaced
12:5c681e1f50bd 13:8827747d8d2f
    32 ///\brief The interface of the LP solver interface.
    32 ///\brief The interface of the LP solver interface.
    33 namespace lemon {
    33 namespace lemon {
    34   
    34   
    35   ///Internal data structure to convert floating id's to fix one's
    35   ///Internal data structure to convert floating id's to fix one's
    36     
    36     
    37   ///\todo This might by implemented to be usable in other places.
    37   ///\todo This might be implemented to be also usable in other places.
    38   class _FixId 
    38   class _FixId 
    39   {
    39   {
    40     std::vector<int> index;
    40     std::vector<int> index;
    41     std::vector<int> cross;
    41     std::vector<int> cross;
    42     int first_free;
    42     int first_free;
   168       bool operator<(Row c) const  {return id<c.id;}
   168       bool operator<(Row c) const  {return id<c.id;}
   169       bool operator==(Row c) const  {return id==c.id;}
   169       bool operator==(Row c) const  {return id==c.id;}
   170       bool operator!=(Row c) const  {return id==c.id;} 
   170       bool operator!=(Row c) const  {return id==c.id;} 
   171    };
   171    };
   172     
   172     
   173     ///Linear expression
   173     ///Linear expression of variables and a constant component
   174     //    typedef SparseLinExpr<Col> Expr;
   174     
       
   175     ///This data structure strores a linear expression of the variables
       
   176     ///(\ref Col "Col"s) and also has a constant component.
       
   177     ///
       
   178     ///There are several ways to access and modify the contents of this
       
   179     ///container.
       
   180     ///- Its it fully compatible with \c std::map<Col,double>, so for expamle
       
   181     ///if \c e is an Expr and \c v and \c w are of type \ref Col then you can
       
   182     ///read and modify the coefficients like
       
   183     ///these.
       
   184     ///\code
       
   185     ///e[v]=5;
       
   186     ///e[v]+=12;
       
   187     ///e.erase(v);
       
   188     ///\endcode
       
   189     ///or you can also iterate through its elements.
       
   190     ///\code
       
   191     ///double s=0;
       
   192     ///for(LpSolverBase::Expr::iterator i=e.begin();i!=e.end();++i)
       
   193     ///  s+=i->second;
       
   194     ///\endcode
       
   195     ///(This code computes the sum of all coefficients).
       
   196     ///- Numbers (<tt>double</tt>'s)
       
   197     ///and variables (\ref Col "Col"s) directly convert to an
       
   198     ///\ref Expr and the usual linear operations are defined so  
       
   199     ///\code
       
   200     ///v+w
       
   201     ///2*v-3.12*(v-w/2)+2
       
   202     ///v*2.1+(3*v+(v*12+w+6)*3)/2
       
   203     ///\endcode
       
   204     ///are valid expressions. The usual assignment operations are also defined.
       
   205     ///\code
       
   206     ///e=v+w;
       
   207     ///e+=2*v-3.12*(v-w/2)+2;
       
   208     ///e*=3.4;
       
   209     ///e/=5;
       
   210     ///\endcode
       
   211     ///- The constant member can be set and read by \ref constComp()
       
   212     ///\code
       
   213     ///e.constComp()=12;
       
   214     ///double c=e.constComp();
       
   215     ///\endcode
       
   216     ///
       
   217     ///\note that \ref clear() not only sets all coefficients to 0 but also
       
   218     ///clears the constant components.
   175     class Expr : public std::map<Col,Value>
   219     class Expr : public std::map<Col,Value>
   176     {
   220     {
   177     public:
   221     public:
   178       typedef LpSolverBase::Col Key; 
   222       typedef LpSolverBase::Col Key; 
   179       typedef LpSolverBase::Value Value;
   223       typedef LpSolverBase::Value Value;