# HG changeset patch # User athos # Date 1168619346 0 # Node ID bfcaad2b84e8ba4b6e0f5c1307074bdf445a65ea # Parent 48ecc4feb42b31dcfaafb5c3328b2d4948b8113c One important thing only: equality-type constraint can now be added to an lp. The prettyPrint functions are not too pretty yet, I accept. diff -r 48ecc4feb42b -r bfcaad2b84e8 lemon/lp_base.h --- a/lemon/lp_base.h Thu Jan 11 22:08:18 2007 +0000 +++ b/lemon/lp_base.h Fri Jan 12 16:29:06 2007 +0000 @@ -19,6 +19,9 @@ #ifndef LEMON_LP_BASE_H #define LEMON_LP_BASE_H +#include + + #include #include #include @@ -269,7 +272,7 @@ ///Linear expression of variables and a constant component - ///This data structure strores a linear expression of the variables + ///This data structure stores 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 @@ -327,7 +330,7 @@ typedef std::map Base; Value const_comp; - public: + public: typedef True IsLinExpression; ///\e Expr() : Base(), const_comp(0) { } @@ -404,6 +407,26 @@ const_comp/=c; return *this; } + + //std::ostream & + void prettyPrint(std::ostream &os) { + //std::fmtflags os.flags(); + //os.setf(std::ios::showpos); + Base::iterator j=Base::begin(); + if (j!=Base::end()) + os<second<<"*x["<first)<<"]"; + ++j; + for (; j!=Base::end(); ++j){ + if (j->second>=0) + os<<"+"; + os<second<<"*x["<first)<<"]"; + } + //Nem valami korrekt, de nem talaltam meg, hogy kell + //os.unsetf(std::ios::showpos); + + //return os; + } + }; ///Linear constraint @@ -496,6 +519,20 @@ using namespace std; return finite(_ub); } + + void prettyPrint(std::ostream &os) { + if (_lb==-LpSolverBase::INF||isNaN(_lb)) + os<<"-infty<="; + else + os<<_lb<<"<="; + _expr.prettyPrint(os); + if (_ub==LpSolverBase::INF) + os<<"<=infty"; + else + os<<"<="<<_ub; + //return os; + } + }; ///Linear expression of rows @@ -1490,6 +1527,16 @@ } ///\e + + ///\relates LpSolverBase::Constr + /// + inline LpSolverBase::Constr operator==(const LpSolverBase::Expr &e, + const LpSolverBase::Value &f) + { + return LpSolverBase::Constr(f,e,f); + } + + ///\e ///\relates LpSolverBase::Constr /// diff -r 48ecc4feb42b -r bfcaad2b84e8 lemon/lp_glpk.cc --- a/lemon/lp_glpk.cc Thu Jan 11 22:08:18 2007 +0000 +++ b/lemon/lp_glpk.cc Fri Jan 12 16:29:06 2007 +0000 @@ -526,6 +526,9 @@ LpGlpk::SolveExitStatus LpGlpk::_solve() { + // A way to check the problem to be solved + //lpx_write_cpxlp(lp,"naittvan.cpx"); + int i = lpx_simplex(lp); switch (i) { case LPX_E_OK: diff -r 48ecc4feb42b -r bfcaad2b84e8 test/lp_test.cc --- a/test/lp_test.cc Thu Jan 11 22:08:18 2007 +0000 +++ b/test/lp_test.cc Fri Jan 12 16:29:06 2007 +0000 @@ -194,11 +194,13 @@ buf << "Coeff. of p2 should be 0"; // std::cout<