diff -r e4ec01f1a4cd -r 852361980706 lemon/lp_base.h --- a/lemon/lp_base.h Tue Apr 08 15:16:16 2008 +0000 +++ b/lemon/lp_base.h Tue Apr 08 16:01:28 2008 +0000 @@ -371,25 +371,6 @@ 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 @@ -481,19 +462,6 @@ return isFinite(_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 @@ -735,15 +703,33 @@ typedef MappedOutputIterator ColIterator; //Abstract virtual functions - virtual LpSolverBase &_newLp() = 0; - virtual LpSolverBase &_copyLp(){ - ///\todo This should be implemented here, too, when we have - ///problem retrieving routines. It can be overriden. + virtual LpSolverBase* _newLp() = 0; + virtual LpSolverBase* _copyLp(){ + LpSolverBase* newlp = _newLp(); - //Starting: - LpSolverBase & newlp(_newLp()); + std::map ref; + for (LpSolverBase::ColIt it(*this); it != INVALID; ++it) { + Col ccol = newlp->addCol(); + ref[it] = ccol; + newlp->colName(ccol, colName(it)); + newlp->colLowerBound(ccol, colLowerBound(it)); + newlp->colUpperBound(ccol, colUpperBound(it)); + } + + for (LpSolverBase::RowIt it(*this); it != INVALID; ++it) { + Expr e = row(it), ce; + for (Expr::iterator jt = e.begin(); jt != e.end(); ++jt) { + ce[ref[jt->first]] = jt->second; + } + ce += e.constComp(); + Row r = newlp->addRow(ce); + + double lower, upper; + getRowBounds(it, lower, upper); + newlp->rowBounds(r, lower, upper); + } + return newlp; - //return *(LpSolverBase*)0; }; virtual int _addCol() = 0; @@ -804,9 +790,9 @@ virtual ~LpSolverBase() {} ///Creates a new LP problem - LpSolverBase &newLp() {return _newLp();} + LpSolverBase* newLp() {return _newLp();} ///Makes a copy of the LP problem - LpSolverBase ©Lp() {return _copyLp();} + LpSolverBase* copyLp() {return _copyLp();} ///\name Build up and modify the LP