Index: src/work/marci/lp/lp_solver_wrapper_3.h
===================================================================
--- src/work/marci/lp/lp_solver_wrapper_3.h	(revision 1097)
+++ src/work/marci/lp/lp_solver_wrapper_3.h	(revision 1099)
@@ -28,4 +28,5 @@
 //#include <lemon/graph_wrapper.h>
 #include <lemon/invalid.h>
+#include <expression.h>
 //#include <bfs_dfs.h>
 //#include <stp.h>
@@ -144,5 +145,16 @@
       /// Invalid constructor.
       ClassIt(const Invalid&) : i(-1) { }
+      friend bool operator<(const ClassIt& x, const ClassIt& y);
+      friend std::ostream& operator<<(std::ostream& os, 
+				      const ClassIt& it);
     };
+    friend bool operator<(const ClassIt& x, const ClassIt& y) {
+      return (x.i < y.i);
+    }
+    friend std::ostream& operator<<(std::ostream& os, 
+				    const ClassIt& it) {
+      os << it.i;
+      return os;
+    }
     /// First member of class \c class_id.
     ClassIt& first(ClassIt& it, int class_id) const {
@@ -159,102 +171,4 @@
   };
 
-  template <typename _Col, typename _Value>
-  class Expr;
-
-  template <typename _Col, typename _Value>
-  class SmallExpr {
-    template <typename _C, typename _V> 
-    friend class Expr;
-  protected:
-    _Col col;
-    _Value value;
-  public:
-    SmallExpr(_Col _col) : col(_col), value(1) { 
-    }
-    SmallExpr& operator *= (_Value _value) {
-      value*=_value;
-      return *this;
-    }
-    //    template <typename _C, typename _V>
-    //    friend SmallExpr<_C, _V> operator* (_V _value, 
-    //					const SmallExpr<_C, _V>& expr);
-    template <typename _C, typename _V>
-    friend std::ostream& operator<<(std::ostream& os, 
-				    const SmallExpr<_C, _V>& expr);
-  };
-
-  template <typename _Col, typename _Value>
-  SmallExpr<_Col, _Value> 
-  operator* (_Value value, 
-	     const SmallExpr<_Col, _Value>& expr) {
-    SmallExpr<_Col, _Value> tmp;
-    tmp=expr;
-    tmp*=value;
-    return tmp;
-  }
-
-  template <typename _Col, typename _Value>
-  std::ostream& operator<<(std::ostream& os, 
-			   const SmallExpr<_Col, _Value>& expr) {
-    os << expr.value << "*" << expr.col;
-    return os;
-  }
-
-  template <typename _Col, typename _Value>
-  class Expr {
-  protected:
-    typedef 
-    typename std::map<_Col, _Value> Data; 
-    Data data;
-  public:
-    Expr() { }
-    Expr(SmallExpr<_Col, _Value> expr) { 
-      data.insert(std::make_pair(expr.col, expr.value));
-    }
-//     Expr(_Col col) { 
-//       data.insert(std::make_pair(col, 1));
-//     }
-    Expr& operator*=(_Value _value) {
-      for (typename Data::iterator i=data.begin(); 
-	   i!=data.end(); ++i) {
-	(*i).second *= _value;
-      }
-      return *this;
-    }
-    Expr& operator+=(SmallExpr<_Col, _Value> expr) {
-      typename Data::iterator i=data.find(expr.col);
-      if (i==data.end()) {
-	data.insert(std::make_pair(expr.col, expr.value));
-      } else {
-	(*i).second+=expr.value;
-      }
-      return *this;
-    }
-    //    template <typename _C, typename _V> 
-    //    friend Expr<_C, _V> operator*(_V _value, const Expr<_C, _V>& expr);
-    template <typename _C, typename _V> 
-    friend std::ostream& operator<<(std::ostream& os, 
-				    const Expr<_C, _V>& expr);
-  };
-
-  template <typename _Col, typename _Value>
-  Expr<_Col, _Value> operator*(_Value _value, 
-			       const Expr<_Col, _Value>& expr) {
-    Expr<_Col, _Value> tmp;
-    tmp=expr;
-    tmp*=_value;
-    return tmp;
-  }
-
-  template <typename _Col, typename _Value>
-  std::ostream& operator<<(std::ostream& os, 
-			   const Expr<_Col, _Value>& expr) {
-    for (typename Expr<_Col, _Value>::Data::const_iterator i=
-	   expr.data.begin(); 
-	 i!=expr.data.end(); ++i) {
-      os << (*i).second << "*" << (*i).first << " ";
-    }
-    return os;
-  }
 
   /*! \e
@@ -425,4 +339,37 @@
     }
 
+    //MOST HIGH LEVEL, USER FRIEND FUNCTIONS
+
+    /// \e
+    typedef Expr<ColIt, _Value> Expression;
+    /// \e
+    typedef Expr<RowIt, _Value> DualExpression;
+    /// \e
+    void setRowCoeffs(RowIt row_it, const Expression& expr) {
+      std::vector<std::pair<int, _Value> > row_coeffs;
+      for(typename Expression::Data::const_iterator i=expr.data.begin(); 
+	  i!=expr.data.end(); ++i) {
+	row_coeffs.push_back(std::make_pair
+			     (col_iter_map[(*i).first], (*i).second));
+      }
+      _setRowCoeffs(row_iter_map[row_it], row_coeffs);
+    }
+    /// \e
+    void setColCoeffs(ColIt col_it, const DualExpression& expr) {
+      std::vector<std::pair<int, _Value> > col_coeffs;
+      for(typename DualExpression::Data::const_iterator i=expr.data.begin(); 
+	  i!=expr.data.end(); ++i) {
+	col_coeffs.push_back(std::make_pair
+			     (row_iter_map[(*i).first], (*i).second));
+      }
+      _setColCoeffs(col_iter_map[col_it], col_coeffs);
+    }
+    /// \e
+    void setObjCoeffs(const Expression& expr) {
+      for(typename Expression::Data::const_iterator i=expr.data.begin(); 
+	  i!=expr.data.end(); ++i) {
+	setObjCoef((*i).first, (*i).second);
+      }
+    }
     //SOLVER FUNCTIONS
 
