LpSolverBase::Expr is documented
authoralpar
Thu, 31 Mar 2005 08:34:55 +0000
changeset 12797caed393608e
parent 1278 4abea330614d
child 1280 f2255b96c19c
LpSolverBase::Expr is documented
src/work/athos/lp/lp_base.h
     1.1 --- a/src/work/athos/lp/lp_base.h	Thu Mar 31 06:05:58 2005 +0000
     1.2 +++ b/src/work/athos/lp/lp_base.h	Thu Mar 31 08:34:55 2005 +0000
     1.3 @@ -34,7 +34,7 @@
     1.4    
     1.5    ///Internal data structure to convert floating id's to fix one's
     1.6      
     1.7 -  ///\todo This might by implemented to be usable in other places.
     1.8 +  ///\todo This might be implemented to be also usable in other places.
     1.9    class _FixId 
    1.10    {
    1.11      std::vector<int> index;
    1.12 @@ -170,8 +170,52 @@
    1.13        bool operator!=(Row c) const  {return id==c.id;} 
    1.14     };
    1.15      
    1.16 -    ///Linear expression
    1.17 -    //    typedef SparseLinExpr<Col> Expr;
    1.18 +    ///Linear expression of variables and a constant component
    1.19 +    
    1.20 +    ///This data structure strores a linear expression of the variables
    1.21 +    ///(\ref Col "Col"s) and also has a constant component.
    1.22 +    ///
    1.23 +    ///There are several ways to access and modify the contents of this
    1.24 +    ///container.
    1.25 +    ///- Its it fully compatible with \c std::map<Col,double>, so for expamle
    1.26 +    ///if \c e is an Expr and \c v and \c w are of type \ref Col then you can
    1.27 +    ///read and modify the coefficients like
    1.28 +    ///these.
    1.29 +    ///\code
    1.30 +    ///e[v]=5;
    1.31 +    ///e[v]+=12;
    1.32 +    ///e.erase(v);
    1.33 +    ///\endcode
    1.34 +    ///or you can also iterate through its elements.
    1.35 +    ///\code
    1.36 +    ///double s=0;
    1.37 +    ///for(LpSolverBase::Expr::iterator i=e.begin();i!=e.end();++i)
    1.38 +    ///  s+=i->second;
    1.39 +    ///\endcode
    1.40 +    ///(This code computes the sum of all coefficients).
    1.41 +    ///- Numbers (<tt>double</tt>'s)
    1.42 +    ///and variables (\ref Col "Col"s) directly convert to an
    1.43 +    ///\ref Expr and the usual linear operations are defined so  
    1.44 +    ///\code
    1.45 +    ///v+w
    1.46 +    ///2*v-3.12*(v-w/2)+2
    1.47 +    ///v*2.1+(3*v+(v*12+w+6)*3)/2
    1.48 +    ///\endcode
    1.49 +    ///are valid expressions. The usual assignment operations are also defined.
    1.50 +    ///\code
    1.51 +    ///e=v+w;
    1.52 +    ///e+=2*v-3.12*(v-w/2)+2;
    1.53 +    ///e*=3.4;
    1.54 +    ///e/=5;
    1.55 +    ///\endcode
    1.56 +    ///- The constant member can be set and read by \ref constComp()
    1.57 +    ///\code
    1.58 +    ///e.constComp()=12;
    1.59 +    ///double c=e.constComp();
    1.60 +    ///\endcode
    1.61 +    ///
    1.62 +    ///\note that \ref clear() not only sets all coefficients to 0 but also
    1.63 +    ///clears the constant components.
    1.64      class Expr : public std::map<Col,Value>
    1.65      {
    1.66      public: