[Lemon-commits] [lemon_svn] alpar: r1711 - hugo/trunk/src/work/athos/lp
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:47:08 CET 2006
Author: alpar
Date: Thu Mar 31 10:34:55 2005
New Revision: 1711
Modified:
hugo/trunk/src/work/athos/lp/lp_base.h
Log:
LpSolverBase::Expr is documented
Modified: hugo/trunk/src/work/athos/lp/lp_base.h
==============================================================================
--- hugo/trunk/src/work/athos/lp/lp_base.h (original)
+++ hugo/trunk/src/work/athos/lp/lp_base.h Thu Mar 31 10:34:55 2005
@@ -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<int> index;
@@ -170,8 +170,52 @@
bool operator!=(Row c) const {return id==c.id;}
};
- ///Linear expression
- // typedef SparseLinExpr<Col> 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<Col,double>, 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 (<tt>double</tt>'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<Col,Value>
{
public:
More information about the Lemon-commits
mailing list