1.1 --- a/lemon/lp_base.h Tue Apr 08 15:16:16 2008 +0000
1.2 +++ b/lemon/lp_base.h Tue Apr 08 16:01:28 2008 +0000
1.3 @@ -371,25 +371,6 @@
1.4 return *this;
1.5 }
1.6
1.7 - //std::ostream &
1.8 - void prettyPrint(std::ostream &os) {
1.9 - //std::fmtflags os.flags();
1.10 - //os.setf(std::ios::showpos);
1.11 - Base::iterator j=Base::begin();
1.12 - if (j!=Base::end())
1.13 - os<<j->second<<"*x["<<id(j->first)<<"]";
1.14 - ++j;
1.15 - for (; j!=Base::end(); ++j){
1.16 - if (j->second>=0)
1.17 - os<<"+";
1.18 - os<<j->second<<"*x["<<id(j->first)<<"]";
1.19 - }
1.20 - //Nem valami korrekt, de nem talaltam meg, hogy kell
1.21 - //os.unsetf(std::ios::showpos);
1.22 -
1.23 - //return os;
1.24 - }
1.25 -
1.26 };
1.27
1.28 ///Linear constraint
1.29 @@ -481,19 +462,6 @@
1.30 return isFinite(_ub);
1.31 }
1.32
1.33 - void prettyPrint(std::ostream &os) {
1.34 - if (_lb==-LpSolverBase::INF||isNaN(_lb))
1.35 - os<<"-infty<=";
1.36 - else
1.37 - os<<_lb<<"<=";
1.38 - _expr.prettyPrint(os);
1.39 - if (_ub==LpSolverBase::INF)
1.40 - os<<"<=infty";
1.41 - else
1.42 - os<<"<="<<_ub;
1.43 - //return os;
1.44 - }
1.45 -
1.46 };
1.47
1.48 ///Linear expression of rows
1.49 @@ -735,15 +703,33 @@
1.50 typedef MappedOutputIterator<DualExpr> ColIterator;
1.51
1.52 //Abstract virtual functions
1.53 - virtual LpSolverBase &_newLp() = 0;
1.54 - virtual LpSolverBase &_copyLp(){
1.55 - ///\todo This should be implemented here, too, when we have
1.56 - ///problem retrieving routines. It can be overriden.
1.57 + virtual LpSolverBase* _newLp() = 0;
1.58 + virtual LpSolverBase* _copyLp(){
1.59 + LpSolverBase* newlp = _newLp();
1.60
1.61 - //Starting:
1.62 - LpSolverBase & newlp(_newLp());
1.63 + std::map<Col, Col> ref;
1.64 + for (LpSolverBase::ColIt it(*this); it != INVALID; ++it) {
1.65 + Col ccol = newlp->addCol();
1.66 + ref[it] = ccol;
1.67 + newlp->colName(ccol, colName(it));
1.68 + newlp->colLowerBound(ccol, colLowerBound(it));
1.69 + newlp->colUpperBound(ccol, colUpperBound(it));
1.70 + }
1.71 +
1.72 + for (LpSolverBase::RowIt it(*this); it != INVALID; ++it) {
1.73 + Expr e = row(it), ce;
1.74 + for (Expr::iterator jt = e.begin(); jt != e.end(); ++jt) {
1.75 + ce[ref[jt->first]] = jt->second;
1.76 + }
1.77 + ce += e.constComp();
1.78 + Row r = newlp->addRow(ce);
1.79 +
1.80 + double lower, upper;
1.81 + getRowBounds(it, lower, upper);
1.82 + newlp->rowBounds(r, lower, upper);
1.83 + }
1.84 +
1.85 return newlp;
1.86 - //return *(LpSolverBase*)0;
1.87 };
1.88
1.89 virtual int _addCol() = 0;
1.90 @@ -804,9 +790,9 @@
1.91 virtual ~LpSolverBase() {}
1.92
1.93 ///Creates a new LP problem
1.94 - LpSolverBase &newLp() {return _newLp();}
1.95 + LpSolverBase* newLp() {return _newLp();}
1.96 ///Makes a copy of the LP problem
1.97 - LpSolverBase ©Lp() {return _copyLp();}
1.98 + LpSolverBase* copyLp() {return _copyLp();}
1.99
1.100 ///\name Build up and modify the LP
1.101