# HG changeset patch # User alpar # Date 1112258095 0 # Node ID 7caed393608e4853e0402cdb994f6f9a4978545c # Parent 4abea330614d0bb82bf431ed9556a442a3650b7d LpSolverBase::Expr is documented diff -r 4abea330614d -r 7caed393608e src/work/athos/lp/lp_base.h --- a/src/work/athos/lp/lp_base.h Thu Mar 31 06:05:58 2005 +0000 +++ b/src/work/athos/lp/lp_base.h Thu Mar 31 08:34:55 2005 +0000 @@ -34,7 +34,7 @@ ///Internal data structure to convert floating id's to fix one's - ///\todo This might by implemented to be usable in other places. + ///\todo This might be implemented to be also usable in other places. class _FixId { std::vector index; @@ -170,8 +170,52 @@ bool operator!=(Row c) const {return id==c.id;} }; - ///Linear expression - // typedef SparseLinExpr Expr; + ///Linear expression of variables and a constant component + + ///This data structure strores a linear expression of the variables + ///(\ref Col "Col"s) and also has a constant component. + /// + ///There are several ways to access and modify the contents of this + ///container. + ///- Its it fully compatible with \c std::map, so for expamle + ///if \c e is an Expr and \c v and \c w are of type \ref Col then you can + ///read and modify the coefficients like + ///these. + ///\code + ///e[v]=5; + ///e[v]+=12; + ///e.erase(v); + ///\endcode + ///or you can also iterate through its elements. + ///\code + ///double s=0; + ///for(LpSolverBase::Expr::iterator i=e.begin();i!=e.end();++i) + /// s+=i->second; + ///\endcode + ///(This code computes the sum of all coefficients). + ///- Numbers (double's) + ///and variables (\ref Col "Col"s) directly convert to an + ///\ref Expr and the usual linear operations are defined so + ///\code + ///v+w + ///2*v-3.12*(v-w/2)+2 + ///v*2.1+(3*v+(v*12+w+6)*3)/2 + ///\endcode + ///are valid expressions. The usual assignment operations are also defined. + ///\code + ///e=v+w; + ///e+=2*v-3.12*(v-w/2)+2; + ///e*=3.4; + ///e/=5; + ///\endcode + ///- The constant member can be set and read by \ref constComp() + ///\code + ///e.constComp()=12; + ///double c=e.constComp(); + ///\endcode + /// + ///\note that \ref clear() not only sets all coefficients to 0 but also + ///clears the constant components. class Expr : public std::map { public: