COIN-OR::LEMON - Graph Library

Changeset 2605:852361980706 in lemon-0.x for lemon/lp_base.h


Ignore:
Timestamp:
04/08/08 18:01:28 (16 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3488
Message:

Bug fixes in LP solvers

  • the copyLp is clarified
  • newLp and copyLp gives back pointers
  • cplex gives back empty string for variables without name
  • cplex row and column retrieval
  • added macro for soplex
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/lp_base.h

    r2569 r2605  
    372372      }
    373373
    374       //std::ostream &
    375       void prettyPrint(std::ostream &os) {
    376         //std::fmtflags os.flags();
    377         //os.setf(std::ios::showpos);
    378         Base::iterator j=Base::begin();
    379         if (j!=Base::end())
    380           os<<j->second<<"*x["<<id(j->first)<<"]";
    381         ++j;
    382         for (; j!=Base::end(); ++j){
    383           if (j->second>=0)
    384             os<<"+";
    385           os<<j->second<<"*x["<<id(j->first)<<"]";
    386         }
    387         //Nem valami korrekt, de nem talaltam meg, hogy kell
    388         //os.unsetf(std::ios::showpos);
    389 
    390         //return os;
    391       }
    392 
    393374    };
    394375   
     
    482463      }
    483464
    484       void prettyPrint(std::ostream &os) {
    485         if (_lb==-LpSolverBase::INF||isNaN(_lb))
    486           os<<"-infty<=";
    487         else
    488           os<<_lb<<"<=";
    489         _expr.prettyPrint(os);
    490         if (_ub==LpSolverBase::INF)
    491           os<<"<=infty";
    492         else
    493           os<<"<="<<_ub;
    494         //return os;
    495       }
    496 
    497465    };
    498466   
     
    736704
    737705    //Abstract virtual functions
    738     virtual LpSolverBase &_newLp() = 0;
    739     virtual LpSolverBase &_copyLp(){
    740       ///\todo This should be implemented here, too, when we have
    741       ///problem retrieving routines. It can be overriden.
    742 
    743       //Starting:
    744       LpSolverBase & newlp(_newLp());
     706    virtual LpSolverBase* _newLp() = 0;
     707    virtual LpSolverBase* _copyLp(){
     708      LpSolverBase* newlp = _newLp();
     709
     710      std::map<Col, Col> ref;
     711      for (LpSolverBase::ColIt it(*this); it != INVALID; ++it) {
     712        Col ccol = newlp->addCol();
     713        ref[it] = ccol;
     714        newlp->colName(ccol, colName(it));
     715        newlp->colLowerBound(ccol, colLowerBound(it));
     716        newlp->colUpperBound(ccol, colUpperBound(it));
     717      }
     718
     719      for (LpSolverBase::RowIt it(*this); it != INVALID; ++it) {
     720        Expr e = row(it), ce;
     721        for (Expr::iterator jt = e.begin(); jt != e.end(); ++jt) {
     722          ce[ref[jt->first]] = jt->second;
     723        }
     724        ce += e.constComp();
     725        Row r = newlp->addRow(ce);
     726
     727        double lower, upper;
     728        getRowBounds(it, lower, upper);
     729        newlp->rowBounds(r, lower, upper);
     730      }
     731
    745732      return newlp;
    746       //return *(LpSolverBase*)0;
    747733    };
    748734
     
    805791
    806792    ///Creates a new LP problem
    807     LpSolverBase &newLp() {return _newLp();}
     793    LpSolverBase* newLp() {return _newLp();}
    808794    ///Makes a copy of the LP problem
    809     LpSolverBase &copyLp() {return _copyLp();}
     795    LpSolverBase* copyLp() {return _copyLp();}
    810796   
    811797    ///\name Build up and modify the LP
Note: See TracChangeset for help on using the changeset viewer.