Index: src/work/athos/lp/lp_base.h
===================================================================
--- src/work/athos/lp/lp_base.h	(revision 1272)
+++ src/work/athos/lp/lp_base.h	(revision 1273)
@@ -21,4 +21,5 @@
 #include<map>
 #include<limits>
+#include<math.h>
 
 #include<lemon/utility.h>
@@ -73,4 +74,5 @@
 	return cross[n];
       }
+      ///\todo Create an own exception type.
       else throw LogicError(); //floatingId-s must form a continuous range;
     }
@@ -127,6 +129,5 @@
     ///
     ///Its value remains valid and correct even after the addition or erase of
-    ///new column (unless the referred column itself was also deleted,
-    ///of course).
+    ///other columns.
     ///
     ///\todo Document what can one do with a Col (INVALID, comparing,
@@ -151,5 +152,5 @@
     ///
     ///Its value remains valid and correct even after the addition or erase of
-    ///new rows (unless the referred row itself was also deleted, of course).
+    ///other rows.
     ///
     ///\todo Document what can one do with a Row (INVALID, comparing,
@@ -172,14 +173,14 @@
     ///Linear expression
     //    typedef SparseLinExpr<Col> Expr;
-    class Expr : public std::map<Col,Col::ExprValue>
+    class Expr : public std::map<Col,Value>
     {
     public:
-      typedef Col Var; 
-      typedef Col::ExprValue Coeff;
+      typedef LpSolverBase::Col Key; 
+      typedef LpSolverBase::Value Value;
       
     protected:
-      typedef std::map<Col,Col::ExprValue> Base;
+      typedef std::map<Col,Value> Base;
       
-      Coeff const_comp;
+      Value const_comp;
   public:
       typedef True IsLinExpression;
@@ -187,17 +188,17 @@
       Expr() : Base(), const_comp(0) { }
       ///\e
-      Expr(const Var &v) : const_comp(0) {
+      Expr(const Key &v) : const_comp(0) {
 	Base::insert(std::make_pair(v, 1));
       }
       ///\e
-      Expr(const Coeff &v) : const_comp(v) {}
-      ///\e
-      void set(const Var &v,const Coeff &c) {
+      Expr(const Value &v) : const_comp(v) {}
+      ///\e
+      void set(const Key &v,const Value &c) {
 	Base::insert(std::make_pair(v, c));
       }
       ///\e
-      Coeff &constComp() { return const_comp; }
-      ///\e
-      const Coeff &constComp() const { return const_comp; }
+      Value &constComp() { return const_comp; }
+      ///\e
+      const Value &constComp() const { return const_comp; }
       
       ///Removes the components with zero coefficient.
@@ -210,5 +211,11 @@
 	}
       }
-      
+
+      ///Sets all coefficients and the constant component to 0.
+      void clear() {
+	Base::clear();
+	const_comp=0;
+      }
+
       ///\e
       Expr &operator+=(const Expr &e) {
@@ -227,5 +234,5 @@
       }
       ///\e
-      Expr &operator*=(const Coeff &c) {
+      Expr &operator*=(const Value &c) {
 	for (Base::iterator j=Base::begin(); j!=Base::end(); ++j)
 	  j->second*=c;
@@ -234,5 +241,5 @@
       }
       ///\e
-      Expr &operator/=(const Coeff &c) {
+      Expr &operator/=(const Value &c) {
 	for (Base::iterator j=Base::begin(); j!=Base::end(); ++j)
 	  j->second/=c;
@@ -248,24 +255,48 @@
     public:
       typedef LpSolverBase::Expr Expr;
-      typedef Expr::Var Var;
-      typedef Expr::Coeff Coeff;
+      typedef Expr::Key Key;
+      typedef Expr::Value Value;
       
-      static const Coeff INF;
-      static const Coeff NaN;
-      //     static const Coeff INF=0;
-      //     static const Coeff NaN=1;
+      static const Value INF;
+      static const Value NaN;
+      //     static const Value INF=0;
+      //     static const Value NaN=1;
       
-      Expr expr;
-      Coeff lb,ub;
-      
-      Constr() : expr(), lb(NaN), ub(NaN) {}
-      Constr(Coeff _lb,const Expr &e,Coeff _ub) :
-	expr(e), lb(_lb), ub(_ub) {}
-      Constr(const Expr &e,Coeff _ub) : 
-	expr(e), lb(NaN), ub(_ub) {}
-      Constr(Coeff _lb,const Expr &e) :
-	expr(e), lb(_lb), ub(NaN) {}
+    protected:
+      Expr _expr;
+      Value _lb,_ub;
+    public:
+      ///\e
+      Constr() : _expr(), _lb(NaN), _ub(NaN) {}
+      ///\e
+      Constr(Value lb,const Expr &e,Value ub) :
+	_expr(e), _lb(lb), _ub(ub) {}
+      ///\e
+      Constr(const Expr &e,Value ub) : 
+	_expr(e), _lb(NaN), _ub(ub) {}
+      ///\e
+      Constr(Value lb,const Expr &e) :
+	_expr(e), _lb(lb), _ub(NaN) {}
+      ///\e
       Constr(const Expr &e) : 
-	expr(e), lb(NaN), ub(NaN) {}
+	_expr(e), _lb(NaN), _ub(NaN) {}
+      ///\e
+      void clear() 
+      {
+	_expr.clear();
+	_lb=_ub=NaN;
+      }
+      ///\e
+      Expr &expr() { return _expr; }
+      ///\e
+      const Expr &expr() const { return _expr; }
+      ///\e
+      Value &lowerBound() { return _lb; }
+      ///\e
+      const Value &lowerBound() const { return _lb; }
+      ///\e
+      Value &upperBound() { return _ub; }
+      ///\e
+      const Value &upperBound() const { return _ub; }
     };
     
@@ -355,14 +386,26 @@
     ///(i.e a new variables)
     ///
-    ///This magic function takes container as its argument
+    ///This magic function takes a container as its argument
     ///and fills its elements
     ///with new columns (i.e. variables)
-    ///\param t can be either any standard STL iterable container with
-    ///\ref Col \c values_type or \c mapped_type
-    ///like <tt>std::vector<LpSolverBase::Col></tt>,
-    /// <tt>std::list<LpSolverBase::Col></tt> or
-    /// <tt>std::map<AnyType,LpSolverBase::Col></tt> or
-    ///it can be an iterable lemon map like 
-    /// <tt>ListGraph::NodeMap<LpSolverBase::Col></tt>.
+    ///\param t can be
+    ///- a standard STL compatible iterable container with
+    ///\ref Col as its \c values_type
+    ///like
+    ///\code
+    ///std::vector<LpSolverBase::Col>
+    ///std::list<LpSolverBase::Col>
+    ///\endcode
+    ///- a standard STL compatible iterable container with
+    ///\ref Col as its \c mapped_type
+    ///like
+    ///\code
+    ///std::map<AnyType,LpSolverBase::Col>
+    ///\endcode
+    ///- an iterable lemon \ref concept::WriteMap "write map" like 
+    ///\code
+    ///ListGraph::NodeMap<LpSolverBase::Col>
+    ///ListGraph::EdgeMap<LpSolverBase::Col>
+    ///\endcode
     ///\return The number of the created column.
     ///\bug Iterable nodemap hasn't been implemented yet.
@@ -441,7 +484,8 @@
     ///\param c is a linear expression (see \ref Constr)
     void setRow(Row r, const Constr &c) {
-      Value lb= c.lb==NaN?-INF:lb;
-      Value ub= c.ub==NaN?INF:lb;
-      setRow(r,lb,c.expr,ub);
+      setRow(r,
+	     isnan(c.lowerBound())?-INF:c.lowerBound(),
+	     c.expr(),
+	     isnan(c.upperBound())?INF:c.upperBound());
     }
 
@@ -564,5 +608,5 @@
   ///
   inline LpSolverBase::Expr operator*(const LpSolverBase::Expr &a,
-				      const LpSolverBase::Expr::Coeff &b) 
+				      const LpSolverBase::Value &b) 
   {
     LpSolverBase::Expr tmp(a);
@@ -575,5 +619,5 @@
   ///\relates LpSolverBase::Expr
   ///
-  inline LpSolverBase::Expr operator*(const LpSolverBase::Expr::Coeff &a,
+  inline LpSolverBase::Expr operator*(const LpSolverBase::Value &a,
 				      const LpSolverBase::Expr &b) 
   {
@@ -587,5 +631,5 @@
   ///
   inline LpSolverBase::Expr operator/(const LpSolverBase::Expr &a,
-				      const LpSolverBase::Expr::Coeff &b) 
+				      const LpSolverBase::Value &b) 
   {
     LpSolverBase::Expr tmp(a);
@@ -608,5 +652,5 @@
   ///\relates LpSolverBase::Constr
   ///
-  inline LpSolverBase::Constr operator<=(const LpSolverBase::Expr::Coeff &e,
+  inline LpSolverBase::Constr operator<=(const LpSolverBase::Value &e,
 					 const LpSolverBase::Expr &f) 
   {
@@ -619,5 +663,5 @@
   ///
   inline LpSolverBase::Constr operator<=(const LpSolverBase::Expr &e,
-					 const LpSolverBase::Expr::Coeff &f) 
+					 const LpSolverBase::Value &f) 
   {
     return LpSolverBase::Constr(e,f);
@@ -639,5 +683,5 @@
   ///\relates LpSolverBase::Constr
   ///
-  inline LpSolverBase::Constr operator>=(const LpSolverBase::Expr::Coeff &e,
+  inline LpSolverBase::Constr operator>=(const LpSolverBase::Value &e,
 					 const LpSolverBase::Expr &f) 
   {
@@ -651,5 +695,5 @@
   ///
   inline LpSolverBase::Constr operator>=(const LpSolverBase::Expr &e,
-					 const LpSolverBase::Expr::Coeff &f) 
+					 const LpSolverBase::Value &f) 
   {
     return LpSolverBase::Constr(f,e);
@@ -670,10 +714,11 @@
   ///\relates LpSolverBase::Constr
   ///
-  inline LpSolverBase::Constr operator<=(const LpSolverBase::Constr::Coeff &n,
+  inline LpSolverBase::Constr operator<=(const LpSolverBase::Value &n,
 					 const LpSolverBase::Constr&c) 
   {
     LpSolverBase::Constr tmp(c);
-    if(tmp.lb!=tmp.NaN) throw LogicError();
-    else tmp.lb=n;
+    ///\todo Create an own exception type.
+    if(!isnan(tmp.lowerBound())) throw LogicError();
+    else tmp.lowerBound()=n;
     return tmp;
   }
@@ -683,22 +728,24 @@
   ///
   inline LpSolverBase::Constr operator<=(const LpSolverBase::Constr& c,
-					 const LpSolverBase::Constr::Coeff &n)
+					 const LpSolverBase::Value &n)
   {
     LpSolverBase::Constr tmp(c);
-    if(tmp.ub!=tmp.NaN) throw LogicError();
-    else tmp.ub=n;
-    return tmp;
-  }
-
-  ///\e
-  
-  ///\relates LpSolverBase::Constr
-  ///
-  inline LpSolverBase::Constr operator>=(const LpSolverBase::Constr::Coeff &n,
+    ///\todo Create an own exception type.
+    if(!isnan(tmp.upperBound())) throw LogicError();
+    else tmp.upperBound()=n;
+    return tmp;
+  }
+
+  ///\e
+  
+  ///\relates LpSolverBase::Constr
+  ///
+  inline LpSolverBase::Constr operator>=(const LpSolverBase::Value &n,
 					 const LpSolverBase::Constr&c) 
   {
     LpSolverBase::Constr tmp(c);
-    if(tmp.ub!=tmp.NaN) throw LogicError();
-    else tmp.ub=n;
+    ///\todo Create an own exception type.
+    if(!isnan(tmp.upperBound())) throw LogicError();
+    else tmp.upperBound()=n;
     return tmp;
   }
@@ -708,9 +755,10 @@
   ///
   inline LpSolverBase::Constr operator>=(const LpSolverBase::Constr& c,
-					 const LpSolverBase::Constr::Coeff &n)
+					 const LpSolverBase::Value &n)
   {
     LpSolverBase::Constr tmp(c);
-    if(tmp.lb!=tmp.NaN) throw LogicError();
-    else tmp.lb=n;
+    ///\todo Create an own exception type.
+    if(!isnan(tmp.lowerBound())) throw LogicError();
+    else tmp.lowerBound()=n;
     return tmp;
   }
