COIN-OR::LEMON - Graph Library

Ticket #44: 9347462c3106.patch

File 9347462c3106.patch, 49.3 KB (added by Balazs Dezso, 10 years ago)

Next iteration

  • lemon/config.h.in

    # HG changeset patch
    # User Balazs Dezso <deba@inf.elte.hu>
    # Date 1228485765 -3600
    # Node ID 9347462c31067ff85c7691347bb28585967daf09
    # Parent  f259f5b9d9c7ebd5f31318849759c73af275f82f
    Lp improvments (ticket #44)
    
     - Add macro CLP macro definition to config.h.in
     - Update lp.h to use soplex and clp
     - Remove default_solver_name
     - New solverName() function in solvers
     - Fix the objective value retrieval in CLP
     - Rename basic classes
       - SolverBase -> LpBase
       - LpBase -> LpSolver
       - MipBase -> MipSolver
     - Handle exceptions for MipCplex test
     - Rename tolerance parameter to epsilon
     - Rename MapIt to CoeffIt
    
    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/config.h.in
    a b  
    55#undef HAVE_GLPK
    66
    77/* Define to 1 if you have SOPLEX */
    8 #undef HAVE_SOPLEX
    9  No newline at end of file
     8#undef HAVE_SOPLEX
     9
     10/* Define to 1 if you have CLP */
     11#undef HAVE_CLP
  • lemon/lp.h

    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/lp.h
    a b  
    2828#include <lemon/lp_cplex.h>
    2929#elif HAVE_SOPLEX
    3030#include <lemon/lp_soplex.h>
     31#elif HAVE_CLP
     32#include <lemon/lp_clp.h>
    3133#endif
    3234
    3335///\file
     
    4143  ///The default LP solver identifier.
    4244  ///\ingroup lp_group
    4345  ///
    44   ///Currently, the possible values are \c GLPK or \c CPLEX
    45 #define DEFAULT_LP SOLVER
     46  ///Currently, the possible values are \c LP_GLPK, \c LP_CPLEX, \c
     47  ///LP_SOPLEX or \c LP_CLP
     48#define LEMON_DEFAULT_LP SOLVER
    4649  ///The default LP solver
    4750
    4851  ///The default LP solver.
    4952  ///\ingroup lp_group
    5053  ///
    51   ///Currently, it is either \c LpGlpk or \c LpCplex
     54  ///Currently, it is either \c LpGlpk, \c LpCplex, \c LpSoplex or \c LpClp
    5255  typedef LpGlpk Lp;
    53   ///The default LP solver identifier string
    5456
    55   ///The default LP solver identifier string.
     57  ///The default MIP solver identifier
     58
     59  ///The default MIP solver identifier.
    5660  ///\ingroup lp_group
    5761  ///
    58   ///Currently, the possible values are "GLPK" or "CPLEX"
    59   const char default_solver_name[]="SOLVER";
     62  ///Currently, the possible values are \c MIP_GLPK or \c MIP_CPLEX
     63#define LEMON_DEFAULT_MIP SOLVER
     64  ///The default MIP solver.
    6065
    61   ///The default ILP solver.
    62 
    63   ///The default ILP solver.
     66  ///The default MIP solver.
    6467  ///\ingroup lp_group
    6568  ///
    66   ///Currently, it is either \c LpGlpk or \c LpCplex
     69  ///Currently, it is either \c MipGlpk or \c MipCplex
    6770  typedef MipGlpk Mip;
    6871#else
    6972#ifdef HAVE_GLPK
    70 #define DEFAULT_LP GLPK
     73# define LEMON_DEFAULT_LP LP_GLPK
    7174  typedef LpGlpk Lp;
     75# define LEMON_DEFAULT_MIP MIP_GLPK
    7276  typedef MipGlpk Mip;
    73   const char default_solver_name[]="GLPK";
    7477#elif HAVE_CPLEX
    75 #define DEFAULT_LP CPLEX
     78# define LEMON_DEFAULT_LP LP_CPLEX
    7679  typedef LpCplex Lp;
     80# define LEMON_DEFAULT_MIP MIP_CPLEX
    7781  typedef MipCplex Mip;
    78   const char default_solver_name[]="CPLEX";
    7982#elif HAVE_SOPLEX
    80 #define DEFAULT_LP SOPLEX
     83# define DEFAULT_LP LP_SOPLEX
    8184  typedef LpSoplex Lp;
    82   const char default_solver_name[]="SOPLEX";
     85#elif HAVE_CLP
     86# define DEFAULT_LP LP_CLP
     87  typedef LpClp Lp; 
    8388#endif
    8489#endif
    8590
  • lemon/lp_base.cc

    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/lp_base.cc
    a b  
    2222#include <lemon/lp_base.h>
    2323namespace lemon {
    2424
    25   const LpBase::Value
    26   SolverBase::INF = std::numeric_limits<Value>::infinity();
    27   const LpBase::Value
    28   SolverBase::NaN = std::numeric_limits<Value>::quiet_NaN();
    29 
    30 //   const LpBase::Constr::Value
    31 //   LpBase::Constr::INF = std::numeric_limits<Value>::infinity();
    32 //   const LpBase::Constr::Value
    33 //   LpBase::Constr::NaN = std::numeric_limits<Value>::quiet_NaN();
     25  const LpBase::Value LpBase::INF = std::numeric_limits<Value>::infinity();
     26  const LpBase::Value LpBase::NaN = std::numeric_limits<Value>::quiet_NaN();
    3427
    3528} //namespace lemon
  • lemon/lp_base.h

    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/lp_base.h
    a b  
    3636///\ingroup lp_group
    3737namespace lemon {
    3838
    39   ///Common base class for LP solvers
     39  ///Common base class for LP and MIP solvers
    4040
    4141  ///\todo Much more docs
    4242  ///\ingroup lp_group
    43   class SolverBase {
     43  class LpBase {
    4444
    4545  protected:
    4646
     
    9090    ///\todo Document what can one do with a Col (INVALID, comparing,
    9191    ///it is similar to Node/Edge)
    9292    class Col {
    93       friend class SolverBase;
     93      friend class LpBase;
    9494    protected:
    9595      int _id;
    9696      explicit Col(int id) : _id(id) {}
     
    105105    };
    106106
    107107    class ColIt : public Col {
    108       const SolverBase *_solver;
     108      const LpBase *_solver;
    109109    public:
    110110      ColIt() {}
    111       ColIt(const SolverBase &solver) : _solver(&solver)
     111      ColIt(const LpBase &solver) : _solver(&solver)
    112112      {
    113113        _solver->cols.firstItem(_id);
    114114      }
     
    133133    ///\todo Document what can one do with a Row (INVALID, comparing,
    134134    ///it is similar to Node/Edge)
    135135    class Row {
    136       friend class SolverBase;
     136      friend class LpBase;
    137137    protected:
    138138      int _id;
    139139      explicit Row(int id) : _id(id) {}
     
    149149    };
    150150
    151151    class RowIt : public Row {
    152       const SolverBase *_solver;
     152      const LpBase *_solver;
    153153    public:
    154154      RowIt() {}
    155       RowIt(const SolverBase &solver) : _solver(&solver)
     155      RowIt(const LpBase &solver) : _solver(&solver)
    156156      {
    157157        _solver->rows.firstItem(_id);
    158158      }
     
    184184    ///or you can also iterate through its elements.
    185185    ///\code
    186186    ///double s=0;
    187     ///for(SolverBase::Expr::ConstMapIt i(e);i!=INVALID;++i)
     187    ///for(LpBase::Expr::ConstCoeffIt i(e);i!=INVALID;++i)
    188188    ///  s+=*i * primal(i);
    189189    ///\endcode
    190190    ///(This code computes the primal value of the expression).
     
    216216    ///\sa Constr
    217217    ///
    218218    class Expr {
    219       friend class SolverBase;
     219      friend class LpBase;
    220220    public:
    221       typedef SolverBase::Col Key;
    222       typedef SolverBase::Value Value;
     221      typedef LpBase::Col Key;
     222      typedef LpBase::Value Value;
    223223
    224224    protected:
    225225      Value const_comp;
     
    264264      ///\e
    265265      const Value& operator*() const { return const_comp; }
    266266
    267       ///Removes the coefficients closer to zero than \c tolerance.
    268       void simplify(Value tolerance = 0.0) {
     267      ///Removes the coefficients closer to zero than \c epsilon.
     268      void simplify(Value epsilon = 0.0) {
    269269        std::map<int, Value>::iterator it=comps.begin();
    270270        while (it != comps.end()) {
    271271          std::map<int, Value>::iterator jt=it;
    272272          ++jt;
    273           if (std::fabs((*it).second) <= tolerance) comps.erase(it);
     273          if (std::fabs((*it).second) <= epsilon) comps.erase(it);
    274274          it=jt;
    275275        }
    276         if (std::fabs(const_comp) <= tolerance) const_comp = 0;
     276        if (std::fabs(const_comp) <= epsilon) const_comp = 0;
    277277      }
    278278
    279       void simplify(Value tolerance = 0.0) const {
    280         const_cast<Expr*>(this)->simplify(tolerance);
     279      void simplify(Value epsilon = 0.0) const {
     280        const_cast<Expr*>(this)->simplify(epsilon);
    281281      }
    282282
    283283      ///Sets all coefficients and the constant component to 0.
     
    319319        return *this;
    320320      }
    321321
    322       class MapIt {
     322      class CoeffIt {
    323323      private:
    324324
    325325        std::map<int, Value>::iterator _it, _end;
    326326
    327327      public:
    328328
    329         MapIt(Expr& e)
     329        CoeffIt(Expr& e)
    330330          : _it(e.comps.begin()), _end(e.comps.end()){}
    331331
    332332        operator Col() const {
     
    336336        Value& operator*() { return _it->second; }
    337337        const Value& operator*() const { return _it->second; }
    338338
    339         MapIt& operator++() { ++_it; return *this; }
     339        CoeffIt& operator++() { ++_it; return *this; }
    340340
    341341        bool operator==(Invalid) const { return _it == _end; }
    342342        bool operator!=(Invalid) const { return _it != _end; }
    343343      };
    344344
    345       class ConstMapIt {
     345      class ConstCoeffIt {
    346346      private:
    347347
    348348        std::map<int, Value>::const_iterator _it, _end;
    349349
    350350      public:
    351351
    352         ConstMapIt(const Expr& e)
     352        ConstCoeffIt(const Expr& e)
    353353          : _it(e.comps.begin()), _end(e.comps.end()){}
    354354
    355355        operator Col() const {
     
    358358
    359359        const Value& operator*() const { return _it->second; }
    360360
    361         ConstMapIt& operator++() { ++_it; return *this; }
     361        ConstCoeffIt& operator++() { ++_it; return *this; }
    362362
    363363        bool operator==(Invalid) const { return _it == _end; }
    364364        bool operator!=(Invalid) const { return _it != _end; }
     
    395395    class Constr
    396396    {
    397397    public:
    398       typedef SolverBase::Expr Expr;
     398      typedef LpBase::Expr Expr;
    399399      typedef Expr::Key Key;
    400400      typedef Expr::Value Value;
    401401
     
    406406      ///\e
    407407      Constr() : _expr(), _lb(NaN), _ub(NaN) {}
    408408      ///\e
    409       Constr(Value lb,const Expr &e,Value ub) :
     409      Constr(Value lb, const Expr &e, Value ub) :
    410410        _expr(e), _lb(lb), _ub(ub) {}
    411411      Constr(const Expr &e) :
    412412        _expr(e), _lb(NaN), _ub(NaN) {}
     
    466466    ///or you can also iterate through its elements.
    467467    ///\code
    468468    ///double s=0;
    469     ///for(SolverBase::DualExpr::ConstMapIt i(e);i!=INVALID;++i)
     469    ///for(LpBase::DualExpr::ConstCoeffIt i(e);i!=INVALID;++i)
    470470    ///  s+=*i;
    471471    ///\endcode
    472472    ///(This code computes the sum of all coefficients).
     
    490490    ///\sa Expr
    491491    ///
    492492    class DualExpr {
    493       friend class SolverBase;
     493      friend class LpBase;
    494494    public:
    495       typedef SolverBase::Row Key;
    496       typedef SolverBase::Value Value;
     495      typedef LpBase::Row Key;
     496      typedef LpBase::Value Value;
    497497
    498498    protected:
    499499      std::map<int, Value> comps;
     
    530530        }
    531531      }
    532532
    533       ///Removes the coefficients closer to zero than \c tolerance.
    534       void simplify(Value tolerance = 0.0) {
     533      ///Removes the coefficients closer to zero than \c epsilon.
     534      void simplify(Value epsilon = 0.0) {
    535535        std::map<int, Value>::iterator it=comps.begin();
    536536        while (it != comps.end()) {
    537537          std::map<int, Value>::iterator jt=it;
    538538          ++jt;
    539           if (std::fabs((*it).second) <= tolerance) comps.erase(it);
     539          if (std::fabs((*it).second) <= epsilon) comps.erase(it);
    540540          it=jt;
    541541        }
    542542      }
    543543
    544       void simplify(Value tolerance = 0.0) const {
    545         const_cast<DualExpr*>(this)->simplify(tolerance);
     544      void simplify(Value epsilon = 0.0) const {
     545        const_cast<DualExpr*>(this)->simplify(epsilon);
    546546      }
    547547
    548548      ///Sets all coefficients to 0.
     
    579579        return *this;
    580580      }
    581581
    582       class MapIt {
     582      class CoeffIt {
    583583      private:
    584584
    585585        std::map<int, Value>::iterator _it, _end;
    586586
    587587      public:
    588588
    589         MapIt(DualExpr& e)
     589        CoeffIt(DualExpr& e)
    590590          : _it(e.comps.begin()), _end(e.comps.end()){}
    591591
    592592        operator Row() const {
     
    596596        Value& operator*() { return _it->second; }
    597597        const Value& operator*() const { return _it->second; }
    598598
    599         MapIt& operator++() { ++_it; return *this; }
     599        CoeffIt& operator++() { ++_it; return *this; }
    600600
    601601        bool operator==(Invalid) const { return _it == _end; }
    602602        bool operator!=(Invalid) const { return _it != _end; }
    603603      };
    604604
    605       class ConstMapIt {
     605      class ConstCoeffIt {
    606606      private:
    607607
    608608        std::map<int, Value>::const_iterator _it, _end;
    609609
    610610      public:
    611611
    612         ConstMapIt(const DualExpr& e)
     612        ConstCoeffIt(const DualExpr& e)
    613613          : _it(e.comps.begin()), _end(e.comps.end()){}
    614614
    615615        operator Row() const {
     
    618618
    619619        const Value& operator*() const { return _it->second; }
    620620
    621         ConstMapIt& operator++() { ++_it; return *this; }
     621        ConstCoeffIt& operator++() { ++_it; return *this; }
    622622
    623623        bool operator==(Invalid) const { return _it == _end; }
    624624        bool operator!=(Invalid) const { return _it != _end; }
     
    712712  protected:
    713713
    714714    //Abstract virtual functions
    715     virtual SolverBase* _newSolver() const = 0;
    716     virtual SolverBase* _cloneSolver() const = 0;
     715    virtual LpBase* _newSolver() const = 0;
     716    virtual LpBase* _cloneSolver() const = 0;
    717717
    718718    virtual int _addColId(int col) { return cols.addIndex(col); }
    719719    virtual int _addRowId(int row) { return rows.addIndex(row); }
     
    767767
    768768    virtual void _clear() = 0;
    769769
     770    virtual const char* _solverName() const = 0;
     771
    770772    //Own protected stuff
    771773
    772774    //Constant component of the objective function
     
    775777  public:
    776778
    777779    ///\e
    778     SolverBase() : rows(), cols(), obj_const_comp(0) {
     780    LpBase() : rows(), cols(), obj_const_comp(0) {
    779781    }
    780782
    781783    ///\e
    782     virtual ~SolverBase() {}
     784    virtual ~LpBase() {}
    783785
    784786    ///Creates a new LP problem
    785     SolverBase* newSolver() {return _newSolver();}
     787    LpBase* newSolver() {return _newSolver();}
    786788    ///Makes a copy of the LP problem
    787     SolverBase* cloneSolver() {return _cloneSolver();}
     789    LpBase* cloneSolver() {return _cloneSolver();}
     790
     791    ///Gives back the name of the solver.
     792    const char* solverName() const {return _solverName();}
    788793
    789794    ///\name Build up and modify the LP
    790795
     
    804809    ///\ref Col as its \c values_type
    805810    ///like
    806811    ///\code
    807     ///std::vector<SolverBase::Col>
    808     ///std::list<SolverBase::Col>
     812    ///std::vector<LpBase::Col>
     813    ///std::list<LpBase::Col>
    809814    ///\endcode
    810815    ///- a standard STL compatible iterable container with
    811816    ///\ref Col as its \c mapped_type
    812817    ///like
    813818    ///\code
    814     ///std::map<AnyType,SolverBase::Col>
     819    ///std::map<AnyType,LpBase::Col>
    815820    ///\endcode
    816821    ///- an iterable lemon \ref concepts::WriteMap "write map" like
    817822    ///\code
    818     ///ListGraph::NodeMap<SolverBase::Col>
    819     ///ListGraph::ArcMap<SolverBase::Col>
     823    ///ListGraph::NodeMap<LpBase::Col>
     824    ///ListGraph::ArcMap<LpBase::Col>
    820825    ///\endcode
    821826    ///\return The number of the created column.
    822827#ifdef DOXYGEN
     
    906911    ///\ref Row as its \c values_type
    907912    ///like
    908913    ///\code
    909     ///std::vector<SolverBase::Row>
    910     ///std::list<SolverBase::Row>
     914    ///std::vector<LpBase::Row>
     915    ///std::list<LpBase::Row>
    911916    ///\endcode
    912917    ///- a standard STL compatible iterable container with
    913918    ///\ref Row as its \c mapped_type
    914919    ///like
    915920    ///\code
    916     ///std::map<AnyType,SolverBase::Row>
     921    ///std::map<AnyType,LpBase::Row>
    917922    ///\endcode
    918923    ///- an iterable lemon \ref concepts::WriteMap "write map" like
    919924    ///\code
    920     ///ListGraph::NodeMap<SolverBase::Row>
    921     ///ListGraph::ArcMap<SolverBase::Row>
     925    ///ListGraph::NodeMap<LpBase::Row>
     926    ///ListGraph::ArcMap<LpBase::Row>
    922927    ///\endcode
    923928    ///\return The number of rows created.
    924929#ifdef DOXYGEN
     
    13411346
    13421347  };
    13431348
    1344   ///\relates SolverBase::Expr
     1349  ///\relates LpBase::Expr
    13451350  ///
    1346   inline SolverBase::Expr operator+(const SolverBase::Expr &a,
    1347                                     const SolverBase::Expr &b) {
    1348     SolverBase::Expr tmp(a);
     1351  inline LpBase::Expr operator+(const LpBase::Expr &a,
     1352                                const LpBase::Expr &b) {
     1353    LpBase::Expr tmp(a);
    13491354    tmp+=b;
    13501355    return tmp;
    13511356  }
    13521357  ///\e
    13531358
    1354   ///\relates SolverBase::Expr
     1359  ///\relates LpBase::Expr
    13551360  ///
    1356   inline SolverBase::Expr operator-(const SolverBase::Expr &a,
    1357                                     const SolverBase::Expr &b) {
    1358     SolverBase::Expr tmp(a);
     1361  inline LpBase::Expr operator-(const LpBase::Expr &a,
     1362                                const LpBase::Expr &b) {
     1363    LpBase::Expr tmp(a);
    13591364    tmp-=b;
    13601365    return tmp;
    13611366  }
    13621367  ///\e
    13631368
    1364   ///\relates SolverBase::Expr
     1369  ///\relates LpBase::Expr
    13651370  ///
    1366   inline SolverBase::Expr operator*(const SolverBase::Expr &a,
    1367                                     const SolverBase::Value &b) {
    1368     SolverBase::Expr tmp(a);
     1371  inline LpBase::Expr operator*(const LpBase::Expr &a,
     1372                                const LpBase::Value &b) {
     1373    LpBase::Expr tmp(a);
    13691374    tmp*=b;
    13701375    return tmp;
    13711376  }
    13721377
    13731378  ///\e
    13741379
    1375   ///\relates SolverBase::Expr
     1380  ///\relates LpBase::Expr
    13761381  ///
    1377   inline SolverBase::Expr operator*(const SolverBase::Value &a,
    1378                                     const SolverBase::Expr &b) {
    1379     SolverBase::Expr tmp(b);
     1382  inline LpBase::Expr operator*(const LpBase::Value &a,
     1383                                const LpBase::Expr &b) {
     1384    LpBase::Expr tmp(b);
    13801385    tmp*=a;
    13811386    return tmp;
    13821387  }
    13831388  ///\e
    13841389
    1385   ///\relates SolverBase::Expr
     1390  ///\relates LpBase::Expr
    13861391  ///
    1387   inline SolverBase::Expr operator/(const SolverBase::Expr &a,
    1388                                     const SolverBase::Value &b) {
    1389     SolverBase::Expr tmp(a);
     1392  inline LpBase::Expr operator/(const LpBase::Expr &a,
     1393                                const LpBase::Value &b) {
     1394    LpBase::Expr tmp(a);
    13901395    tmp/=b;
    13911396    return tmp;
    13921397  }
    13931398
    13941399  ///\e
    13951400
    1396   ///\relates SolverBase::Constr
     1401  ///\relates LpBase::Constr
    13971402  ///
    1398   inline SolverBase::Constr operator<=(const SolverBase::Expr &e,
    1399                                        const SolverBase::Expr &f) {
    1400     return SolverBase::Constr(0, f - e, SolverBase::INF);
     1403  inline LpBase::Constr operator<=(const LpBase::Expr &e,
     1404                                   const LpBase::Expr &f) {
     1405    return LpBase::Constr(0, f - e, LpBase::INF);
    14011406  }
    14021407
    14031408  ///\e
    14041409
    1405   ///\relates SolverBase::Constr
     1410  ///\relates LpBase::Constr
    14061411  ///
    1407   inline SolverBase::Constr operator<=(const SolverBase::Value &e,
    1408                                        const SolverBase::Expr &f) {
    1409     return SolverBase::Constr(e, f, SolverBase::NaN);
     1412  inline LpBase::Constr operator<=(const LpBase::Value &e,
     1413                                   const LpBase::Expr &f) {
     1414    return LpBase::Constr(e, f, LpBase::NaN);
    14101415  }
    14111416
    14121417  ///\e
    14131418
    1414   ///\relates SolverBase::Constr
     1419  ///\relates LpBase::Constr
    14151420  ///
    1416   inline SolverBase::Constr operator<=(const SolverBase::Expr &e,
    1417                                        const SolverBase::Value &f) {
    1418     return SolverBase::Constr(- SolverBase::INF, e, f);
     1421  inline LpBase::Constr operator<=(const LpBase::Expr &e,
     1422                                   const LpBase::Value &f) {
     1423    return LpBase::Constr(- LpBase::INF, e, f);
    14191424  }
    14201425
    14211426  ///\e
    14221427
    1423   ///\relates SolverBase::Constr
     1428  ///\relates LpBase::Constr
    14241429  ///
    1425   inline SolverBase::Constr operator>=(const SolverBase::Expr &e,
    1426                                        const SolverBase::Expr &f) {
    1427     return SolverBase::Constr(0, e - f, SolverBase::INF);
     1430  inline LpBase::Constr operator>=(const LpBase::Expr &e,
     1431                                   const LpBase::Expr &f) {
     1432    return LpBase::Constr(0, e - f, LpBase::INF);
    14281433  }
    14291434
    14301435
    14311436  ///\e
    14321437
    1433   ///\relates SolverBase::Constr
     1438  ///\relates LpBase::Constr
    14341439  ///
    1435   inline SolverBase::Constr operator>=(const SolverBase::Value &e,
    1436                                        const SolverBase::Expr &f) {
    1437     return SolverBase::Constr(SolverBase::NaN, f, e);
     1440  inline LpBase::Constr operator>=(const LpBase::Value &e,
     1441                                   const LpBase::Expr &f) {
     1442    return LpBase::Constr(LpBase::NaN, f, e);
    14381443  }
    14391444
    14401445
    14411446  ///\e
    14421447
    1443   ///\relates SolverBase::Constr
     1448  ///\relates LpBase::Constr
    14441449  ///
    1445   inline SolverBase::Constr operator>=(const SolverBase::Expr &e,
    1446                                        const SolverBase::Value &f) {
    1447     return SolverBase::Constr(f, e, SolverBase::INF);
     1450  inline LpBase::Constr operator>=(const LpBase::Expr &e,
     1451                                   const LpBase::Value &f) {
     1452    return LpBase::Constr(f, e, LpBase::INF);
    14481453  }
    14491454
    14501455  ///\e
    14511456
    1452   ///\relates SolverBase::Constr
     1457  ///\relates LpBase::Constr
    14531458  ///
    1454   inline SolverBase::Constr operator==(const SolverBase::Expr &e,
    1455                                        const SolverBase::Value &f) {
    1456     return SolverBase::Constr(f, e, f);
     1459  inline LpBase::Constr operator==(const LpBase::Expr &e,
     1460                                   const LpBase::Value &f) {
     1461    return LpBase::Constr(f, e, f);
    14571462  }
    14581463
    14591464  ///\e
    14601465
    1461   ///\relates SolverBase::Constr
     1466  ///\relates LpBase::Constr
    14621467  ///
    1463   inline SolverBase::Constr operator==(const SolverBase::Expr &e,
    1464                                        const SolverBase::Expr &f) {
    1465     return SolverBase::Constr(0, f - e, 0);
     1468  inline LpBase::Constr operator==(const LpBase::Expr &e,
     1469                                   const LpBase::Expr &f) {
     1470    return LpBase::Constr(0, f - e, 0);
    14661471  }
    14671472
    14681473  ///\e
    14691474
    1470   ///\relates SolverBase::Constr
     1475  ///\relates LpBase::Constr
    14711476  ///
    1472   inline SolverBase::Constr operator<=(const SolverBase::Value &n,
    1473                                        const SolverBase::Constr &c) {
    1474     SolverBase::Constr tmp(c);
     1477  inline LpBase::Constr operator<=(const LpBase::Value &n,
     1478                                   const LpBase::Constr &c) {
     1479    LpBase::Constr tmp(c);
    14751480    LEMON_ASSERT(std::isnan(tmp.lowerBound()), "Wrong LP constraint");
    14761481    tmp.lowerBound()=n;
    14771482    return tmp;
    14781483  }
    14791484  ///\e
    14801485
    1481   ///\relates SolverBase::Constr
     1486  ///\relates LpBase::Constr
    14821487  ///
    1483   inline SolverBase::Constr operator<=(const SolverBase::Constr &c,
    1484                                        const SolverBase::Value &n)
     1488  inline LpBase::Constr operator<=(const LpBase::Constr &c,
     1489                                   const LpBase::Value &n)
    14851490  {
    1486     SolverBase::Constr tmp(c);
     1491    LpBase::Constr tmp(c);
    14871492    LEMON_ASSERT(std::isnan(tmp.upperBound()), "Wrong LP constraint");
    14881493    tmp.upperBound()=n;
    14891494    return tmp;
     
    14911496
    14921497  ///\e
    14931498
    1494   ///\relates SolverBase::Constr
     1499  ///\relates LpBase::Constr
    14951500  ///
    1496   inline SolverBase::Constr operator>=(const SolverBase::Value &n,
    1497                                        const SolverBase::Constr &c) {
    1498     SolverBase::Constr tmp(c);
     1501  inline LpBase::Constr operator>=(const LpBase::Value &n,
     1502                                   const LpBase::Constr &c) {
     1503    LpBase::Constr tmp(c);
    14991504    LEMON_ASSERT(std::isnan(tmp.upperBound()), "Wrong LP constraint");
    15001505    tmp.upperBound()=n;
    15011506    return tmp;
    15021507  }
    15031508  ///\e
    15041509
    1505   ///\relates SolverBase::Constr
     1510  ///\relates LpBase::Constr
    15061511  ///
    1507   inline SolverBase::Constr operator>=(const SolverBase::Constr &c,
    1508                                        const SolverBase::Value &n)
     1512  inline LpBase::Constr operator>=(const LpBase::Constr &c,
     1513                                   const LpBase::Value &n)
    15091514  {
    1510     SolverBase::Constr tmp(c);
     1515    LpBase::Constr tmp(c);
    15111516    LEMON_ASSERT(std::isnan(tmp.lowerBound()), "Wrong LP constraint");
    15121517    tmp.lowerBound()=n;
    15131518    return tmp;
     
    15151520
    15161521  ///\e
    15171522
    1518   ///\relates SolverBase::DualExpr
     1523  ///\relates LpBase::DualExpr
    15191524  ///
    1520   inline SolverBase::DualExpr operator+(const SolverBase::DualExpr &a,
    1521                                         const SolverBase::DualExpr &b) {
    1522     SolverBase::DualExpr tmp(a);
     1525  inline LpBase::DualExpr operator+(const LpBase::DualExpr &a,
     1526                                    const LpBase::DualExpr &b) {
     1527    LpBase::DualExpr tmp(a);
    15231528    tmp+=b;
    15241529    return tmp;
    15251530  }
    15261531  ///\e
    15271532
    1528   ///\relates SolverBase::DualExpr
     1533  ///\relates LpBase::DualExpr
    15291534  ///
    1530   inline SolverBase::DualExpr operator-(const SolverBase::DualExpr &a,
    1531                                         const SolverBase::DualExpr &b) {
    1532     SolverBase::DualExpr tmp(a);
     1535  inline LpBase::DualExpr operator-(const LpBase::DualExpr &a,
     1536                                    const LpBase::DualExpr &b) {
     1537    LpBase::DualExpr tmp(a);
    15331538    tmp-=b;
    15341539    return tmp;
    15351540  }
    15361541  ///\e
    15371542
    1538   ///\relates SolverBase::DualExpr
     1543  ///\relates LpBase::DualExpr
    15391544  ///
    1540   inline SolverBase::DualExpr operator*(const SolverBase::DualExpr &a,
    1541                                         const SolverBase::Value &b) {
    1542     SolverBase::DualExpr tmp(a);
     1545  inline LpBase::DualExpr operator*(const LpBase::DualExpr &a,
     1546                                    const LpBase::Value &b) {
     1547    LpBase::DualExpr tmp(a);
    15431548    tmp*=b;
    15441549    return tmp;
    15451550  }
    15461551
    15471552  ///\e
    15481553
    1549   ///\relates SolverBase::DualExpr
     1554  ///\relates LpBase::DualExpr
    15501555  ///
    1551   inline SolverBase::DualExpr operator*(const SolverBase::Value &a,
    1552                                         const SolverBase::DualExpr &b) {
    1553     SolverBase::DualExpr tmp(b);
     1556  inline LpBase::DualExpr operator*(const LpBase::Value &a,
     1557                                    const LpBase::DualExpr &b) {
     1558    LpBase::DualExpr tmp(b);
    15541559    tmp*=a;
    15551560    return tmp;
    15561561  }
    15571562  ///\e
    15581563
    1559   ///\relates SolverBase::DualExpr
     1564  ///\relates LpBase::DualExpr
    15601565  ///
    1561   inline SolverBase::DualExpr operator/(const SolverBase::DualExpr &a,
    1562                                         const SolverBase::Value &b) {
    1563     SolverBase::DualExpr tmp(a);
     1566  inline LpBase::DualExpr operator/(const LpBase::DualExpr &a,
     1567                                    const LpBase::Value &b) {
     1568    LpBase::DualExpr tmp(a);
    15641569    tmp/=b;
    15651570    return tmp;
    15661571  }
     
    15691574  ///
    15701575  /// \brief Common base class for LP solvers
    15711576  /// \todo Much more docs
    1572   class LpBase : virtual public SolverBase {
     1577  class LpSolver : virtual public LpBase {
    15731578  public:
    15741579
    15751580    ///\e
     
    15861591      UNBOUNDED = 4
    15871592    };
    15881593
     1594    ///\e
    15891595    enum VarStatus {
    1590       BASIC, FREE, LOWER, UPPER, FIXED
     1596      /// The variable is in the basis
     1597      BASIC,
     1598      /// The variable is free, but not basic
     1599      FREE,
     1600      /// The variable has active lower bound
     1601      LOWER,
     1602      /// The variable has active upper bound
     1603      UPPER,
     1604      /// The variable is non-basic and fixed
     1605      FIXED
    15911606    };
    15921607
    15931608  protected:
     
    16441659    ///\e
    16451660    Value primal(const Expr& e) const {
    16461661      double res = *e;
    1647       for (Expr::ConstMapIt c(e); c != INVALID; ++c) {
     1662      for (Expr::ConstCoeffIt c(e); c != INVALID; ++c) {
    16481663        res += *c * primal(c);
    16491664      }
    16501665      return res;
     
    16571672    ///\e
    16581673    Value dual(const DualExpr& e) const {
    16591674      double res = 0.0;
    1660       for (DualExpr::ConstMapIt r(e); r != INVALID; ++r) {
     1675      for (DualExpr::ConstCoeffIt r(e); r != INVALID; ++r) {
    16611676        res += *r * dual(r);
    16621677      }
    16631678      return res;
     
    16811696    Value primal() const { return _getPrimalValue()+obj_const_comp;}
    16821697    ///@}
    16831698
    1684     LpBase* newSolver() {return _newSolver();}
    1685     LpBase* cloneSolver() {return _cloneSolver();}
     1699    LpSolver* newSolver() {return _newSolver();}
     1700    LpSolver* cloneSolver() {return _cloneSolver();}
    16861701
    16871702  protected:
    16881703
    1689     virtual LpBase* _newSolver() const = 0;
    1690     virtual LpBase* _cloneSolver() const = 0;
     1704    virtual LpSolver* _newSolver() const = 0;
     1705    virtual LpSolver* _cloneSolver() const = 0;
    16911706  };
    16921707
    16931708
     
    16951710  ///
    16961711  /// \brief Common base class for MIP solvers
    16971712  /// \todo Much more docs
    1698   class MipBase : virtual public SolverBase {
     1713  class MipSolver : virtual public LpBase {
    16991714  public:
    17001715
    17011716    ///\e
     
    17991814    ///\e
    18001815    Value sol(const Expr& e) const {
    18011816      double res = *e;
    1802       for (Expr::ConstMapIt c(e); c != INVALID; ++c) {
     1817      for (Expr::ConstCoeffIt c(e); c != INVALID; ++c) {
    18031818        res += *c * sol(c);
    18041819      }
    18051820      return res;
     
    18231838
    18241839  public:
    18251840
    1826     MipBase* newSolver() {return _newSolver();}
    1827     MipBase* cloneSolver() {return _cloneSolver();}
     1841    MipSolver* newSolver() {return _newSolver();}
     1842    MipSolver* cloneSolver() {return _cloneSolver();}
    18281843
    18291844  protected:
    18301845
    1831     virtual MipBase* _newSolver() const = 0;
    1832     virtual MipBase* _cloneSolver() const = 0;
     1846    virtual MipSolver* _newSolver() const = 0;
     1847    virtual MipSolver* _cloneSolver() const = 0;
    18331848  };
    18341849
    18351850
  • lemon/lp_clp.cc

    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/lp_clp.cc
    a b  
    6565    LpClp* copylp = new LpClp(*this);
    6666    return copylp;
    6767  }
     68
     69  const char* LpClp::_solverName() const { return "LpClp"; }
    6870
    6971  int LpClp::_addCol() {
    7072    _prob->addColumn(0, 0, 0, -COIN_DBL_MAX, COIN_DBL_MAX, 0.0);
     
    311313    return _prob->primalColumnSolution()[i];
    312314  }
    313315  LpClp::Value LpClp::_getPrimalValue() const {
    314     return _prob->rawObjectiveValue();
     316    return _prob->objectiveValue();
    315317  }
    316318
    317319  LpClp::Value LpClp::_getDual(int i) const {
     
    399401    }
    400402  }
    401403
    402   void LpClp::_setSense(SolverBase::Sense sense) {
     404  void LpClp::_setSense(LpClp::Sense sense) {
    403405    switch (sense) {
    404406    case MIN:
    405407      _prob->setOptimizationDirection(1);
     
    410412    }
    411413  }
    412414
    413   SolverBase::Sense LpClp::_getSense() const {
     415  LpClp::Sense LpClp::_getSense() const {
    414416    double dir = _prob->optimizationDirection();
    415417    if (dir > 0.0) {
    416418      return MIN;
  • lemon/lp_clp.h

    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/lp_clp.h
    a b  
    3939  /// Clp library is an object oriented lp solver library developed at
    4040  /// the IBM. The CLP is part of the COIN-OR package and it can be
    4141  /// used with Common Public License.
    42   class LpClp : public LpBase {
     42  class LpClp : public LpSolver {
    4343  protected:
    4444
    4545    ClpSimplex* _prob;
     
    4848    std::map<std::string, int> _row_names_ref;
    4949
    5050  public:
    51 
    52     typedef LpBase Parent;
    5351
    5452    /// \e
    5553    LpClp();
     
    6967  protected:
    7068
    7169    virtual LpClp* _newSolver() const;
    72     virtual LpClp* _cloneSolver() const ;
     70    virtual LpClp* _cloneSolver() const;
     71
     72    virtual const char* _solverName() const;
    7373
    7474    virtual int _addCol();
    7575    virtual int _addRow();
  • lemon/lp_cplex.cc

    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/lp_cplex.cc
    a b  
    6969    }
    7070  }
    7171
    72   CplexBase::CplexBase() : SolverBase() {
     72  CplexBase::CplexBase() : LpBase() {
    7373    int status;
    7474    _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem");
    7575  }
    7676
    7777  CplexBase::CplexBase(const CplexEnv& env)
    78     : SolverBase(), _env(env) {
     78    : LpBase(), _env(env) {
    7979    int status;
    8080    _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem");
    8181  }
    8282
    8383  CplexBase::CplexBase(const CplexBase& cplex)
    84     : SolverBase() {
     84    : LpBase() {
    8585    int status;
    8686    _prob = CPXcloneprob(cplexEnv(), cplex._prob, &status);
    8787    rows = cplex.rows;
     
    395395    }
    396396  }
    397397
    398   void CplexBase::_setObjCoeff(int i, SolverBase::Value obj_coef)
     398  void CplexBase::_setObjCoeff(int i, CplexBase::Value obj_coef)
    399399  {
    400400    CPXchgobj(cplexEnv(), _prob, 1, &i, &obj_coef);
    401401  }
     
    441441  // LpCplex members
    442442
    443443  LpCplex::LpCplex()
    444     : SolverBase(), CplexBase(), LpBase() {}
     444    : LpBase(), CplexBase(), LpSolver() {}
    445445
    446446  LpCplex::LpCplex(const CplexEnv& env)
    447     : SolverBase(), CplexBase(env), LpBase() {}
     447    : LpBase(), CplexBase(env), LpSolver() {}
    448448
    449449  LpCplex::LpCplex(const LpCplex& other)
    450     : SolverBase(), CplexBase(other), LpBase() {}
     450    : LpBase(), CplexBase(other), LpSolver() {}
    451451
    452452  LpCplex::~LpCplex() {}
    453453
    454454  LpCplex* LpCplex::_newSolver() const { return new LpCplex; }
    455455  LpCplex* LpCplex::_cloneSolver() const {return new LpCplex(*this); }
     456
     457  const char* LpCplex::_solverName() const { return "LpCplex"; }
    456458
    457459  void LpCplex::_clear_temporals() {
    458460    _col_status.clear();
     
    796798  // MipCplex members
    797799
    798800  MipCplex::MipCplex()
    799     : SolverBase(), CplexBase(), MipBase() {
     801    : LpBase(), CplexBase(), MipSolver() {
    800802
    801803#if CPX_VERSION < 800
    802804    CPXchgprobtype(cplexEnv(),  _prob, CPXPROB_MIP);
     
    806808  }
    807809
    808810  MipCplex::MipCplex(const CplexEnv& env)
    809     : SolverBase(), CplexBase(env), MipBase() {
     811    : LpBase(), CplexBase(env), MipSolver() {
    810812
    811813#if CPX_VERSION < 800
    812814    CPXchgprobtype(cplexEnv(),  _prob, CPXPROB_MIP);
     
    817819  }
    818820
    819821  MipCplex::MipCplex(const MipCplex& other)
    820     : SolverBase(), CplexBase(other), MipBase() {}
     822    : LpBase(), CplexBase(other), MipSolver() {}
    821823
    822824  MipCplex::~MipCplex() {}
    823825
    824826  MipCplex* MipCplex::_newSolver() const { return new MipCplex; }
    825827  MipCplex* MipCplex::_cloneSolver() const {return new MipCplex(*this); }
     828
     829  const char* MipCplex::_solverName() const { return "MipCplex"; }
    826830
    827831  void MipCplex::_setColType(int i, MipCplex::ColTypes col_type) {
    828832
     
    843847    }
    844848  }
    845849
    846   MipBase::ColTypes MipCplex::_getColType(int i) const {
     850  MipCplex::ColTypes MipCplex::_getColType(int i) const {
    847851    char t;
    848852    CPXgetctype (cplexEnv(), _prob, &t, i, i);
    849853    switch (t) {
  • lemon/lp_cplex.h

    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/lp_cplex.h
    a b  
    7777
    7878  /// \brief Base interface for the CPLEX LP and MIP solver
    7979  ///
    80   /// This class implements the common interface of the CPLEX LP and MIP solver.
    81   ///\ingroup lp_group
    82   class CplexBase : virtual public SolverBase {
     80  /// This class implements the common interface of the CPLEX LP and
     81  /// MIP solvers. 
     82  /// \ingroup lp_group
     83  class CplexBase : virtual public LpBase {
    8384  protected:
    84 
    85     typedef SolverBase Parent;
    8685
    8786    CplexEnv _env;
    8887    cpxlp* _prob;
     
    161160  ///
    162161  /// This class implements an interface for the CPLEX LP solver.
    163162  ///\ingroup lp_group
    164   class LpCplex : public CplexBase, public LpBase {
     163  class LpCplex : public CplexBase, public LpSolver {
    165164  public:
    166165    /// \e
    167166    LpCplex();
     
    189188
    190189    virtual LpCplex* _cloneSolver() const;
    191190    virtual LpCplex* _newSolver() const;
     191
     192    virtual const char* _solverName() const;
    192193
    193194    virtual SolveExitStatus _solve();
    194195    virtual Value _getPrimal(int i) const;
     
    221222  ///
    222223  /// This class implements an interface for the CPLEX MIP solver.
    223224  ///\ingroup lp_group
    224   class MipCplex : public CplexBase, public MipBase {
     225  class MipCplex : public CplexBase, public MipSolver {
    225226  public:
    226227    /// \e
    227228    MipCplex();
     
    237238    virtual MipCplex* _cloneSolver() const;
    238239    virtual MipCplex* _newSolver() const;
    239240
     241    virtual const char* _solverName() const;
     242
    240243    virtual ColTypes _getColType(int col) const;
    241244    virtual void _setColType(int col, ColTypes col_type);
    242245
  • lemon/lp_glpk.cc

    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/lp_glpk.cc
    a b  
    2828
    2929  // GlpkBase members
    3030
    31   GlpkBase::GlpkBase() : SolverBase() {
     31  GlpkBase::GlpkBase() : LpBase() {
    3232    lp = glp_create_prob();
    3333    glp_create_index(lp);
    3434  }
    3535
    36   GlpkBase::GlpkBase(const GlpkBase &other) : SolverBase() {
     36  GlpkBase::GlpkBase(const GlpkBase &other) : LpBase() {
    3737    lp = glp_create_prob();
    3838    glp_copy_prob(lp, other.lp, GLP_ON);
    3939    glp_create_index(lp);
     
    232232
    233233  }
    234234
    235   SolverBase::Value GlpkBase::_getCoeff(int ix, int jx) const {
     235  GlpkBase::Value GlpkBase::_getCoeff(int ix, int jx) const {
    236236
    237237    int length = glp_get_mat_row(lp, ix, 0, 0);
    238238
     
    290290    }
    291291  }
    292292
    293   SolverBase::Value GlpkBase::_getColLowerBound(int i) const {
     293  GlpkBase::Value GlpkBase::_getColLowerBound(int i) const {
    294294    int b = glp_get_col_type(lp, i);
    295295    switch (b) {
    296296    case GLP_LO:
     
    345345
    346346  }
    347347
    348   SolverBase::Value GlpkBase::_getColUpperBound(int i) const {
     348  GlpkBase::Value GlpkBase::_getColUpperBound(int i) const {
    349349    int b = glp_get_col_type(lp, i);
    350350      switch (b) {
    351351      case GLP_UP:
     
    398398
    399399  }
    400400
    401   SolverBase::Value GlpkBase::_getRowLowerBound(int i) const {
     401  GlpkBase::Value GlpkBase::_getRowLowerBound(int i) const {
    402402    int b = glp_get_row_type(lp, i);
    403403    switch (b) {
    404404    case GLP_LO:
     
    452452    }
    453453  }
    454454
    455   SolverBase::Value GlpkBase::_getRowUpperBound(int i) const {
     455  GlpkBase::Value GlpkBase::_getRowUpperBound(int i) const {
    456456    int b = glp_get_row_type(lp, i);
    457457    switch (b) {
    458458    case GLP_UP:
     
    488488    glp_set_obj_coef(lp, i, obj_coef);
    489489  }
    490490
    491   SolverBase::Value GlpkBase::_getObjCoeff(int i) const {
     491  GlpkBase::Value GlpkBase::_getObjCoeff(int i) const {
    492492    //i = 0 means the constant term (shift)
    493493    return glp_get_obj_coef(lp, i);
    494494  }
    495495
    496   void GlpkBase::_setSense(SolverBase::Sense sense) {
     496  void GlpkBase::_setSense(GlpkBase::Sense sense) {
    497497    switch (sense) {
    498498    case MIN:
    499499      glp_set_obj_dir(lp, GLP_MIN);
     
    504504    }
    505505  }
    506506
    507   SolverBase::Sense GlpkBase::_getSense() const {
     507  GlpkBase::Sense GlpkBase::_getSense() const {
    508508    switch(glp_get_obj_dir(lp)) {
    509509    case GLP_MIN:
    510510      return MIN;
     
    512512      return MAX;
    513513    default:
    514514      LEMON_ASSERT(false, "Wrong sense");
    515       return SolverBase::Sense();
     515      return GlpkBase::Sense();
    516516    }
    517517  }
    518518
     
    525525  // LpGlpk members
    526526
    527527  LpGlpk::LpGlpk()
    528     : SolverBase(), GlpkBase(), LpBase() {
     528    : LpBase(), GlpkBase(), LpSolver() {
    529529    messageLevel(MESSAGE_NO_OUTPUT);
    530530  }
    531531
    532532  LpGlpk::LpGlpk(const LpGlpk& other)
    533     : SolverBase(other), GlpkBase(other), LpBase(other) {
     533    : LpBase(other), GlpkBase(other), LpSolver(other) {
    534534    messageLevel(MESSAGE_NO_OUTPUT);
    535535  }
    536536
    537537  LpGlpk* LpGlpk::_newSolver() const { return new LpGlpk; }
    538   LpGlpk* LpGlpk::_cloneSolver() const {return new LpGlpk(*this); }
     538  LpGlpk* LpGlpk::_cloneSolver() const { return new LpGlpk(*this); }
     539
     540  const char* LpGlpk::_solverName() const { return "LpGlpk"; }
    539541
    540542  void LpGlpk::_clear_temporals() {
    541543    _primal_ray.clear();
     
    822824  // MipGlpk members
    823825
    824826  MipGlpk::MipGlpk()
    825     : SolverBase(), GlpkBase(), MipBase() {
     827    : LpBase(), GlpkBase(), MipSolver() {
    826828    messageLevel(MESSAGE_NO_OUTPUT);
    827829  }
    828830
    829831  MipGlpk::MipGlpk(const MipGlpk& other)
    830     : SolverBase(), GlpkBase(other), MipBase() {
     832    : LpBase(), GlpkBase(other), MipSolver() {
    831833    messageLevel(MESSAGE_NO_OUTPUT);
    832834  }
    833835
     
    941943  MipGlpk* MipGlpk::_newSolver() const { return new MipGlpk; }
    942944  MipGlpk* MipGlpk::_cloneSolver() const {return new MipGlpk(*this); }
    943945
     946  const char* MipGlpk::_solverName() const { return "MipGlpk"; }
     947
    944948  void MipGlpk::messageLevel(MessageLevel m) {
    945949    _message_level = m;
    946950  }
  • lemon/lp_glpk.h

    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/lp_glpk.h
    a b  
    3939  ///
    4040  /// This class implements the common interface of the GLPK LP and MIP solver.
    4141  /// \ingroup lp_group
    42   class GlpkBase : virtual public SolverBase {
     42  class GlpkBase : virtual public LpBase {
    4343  protected:
    4444
    4545    typedef glp_prob LPX;
    4646    glp_prob* lp;
    47 
    48     typedef LpBase Parent;
    4947
    5048    GlpkBase();
    5149    GlpkBase(const GlpkBase&);
     
    121119  ///
    122120  /// This class implements an interface for the GLPK LP solver.
    123121  ///\ingroup lp_group
    124   class LpGlpk : public GlpkBase, public LpBase {
     122  class LpGlpk : public GlpkBase, public LpSolver {
    125123  public:
    126124
    127125    ///\e
     
    141139    virtual LpGlpk* _cloneSolver() const;
    142140    virtual LpGlpk* _newSolver() const;
    143141
    144     ///\todo It should be clarified
    145     ///
     142    virtual const char* _solverName() const;
     143
    146144    virtual SolveExitStatus _solve();
    147145    virtual Value _getPrimal(int i) const;
    148146    virtual Value _getDual(int i) const;
     
    205203  ///
    206204  /// This class implements an interface for the GLPK MIP solver.
    207205  ///\ingroup lp_group
    208   class MipGlpk : public GlpkBase, public MipBase {
     206  class MipGlpk : public GlpkBase, public MipSolver {
    209207  public:
    210208
    211209    ///\e
     
    217215
    218216    virtual MipGlpk* _cloneSolver() const;
    219217    virtual MipGlpk* _newSolver() const;
     218
     219    virtual const char* _solverName() const;
    220220
    221221    virtual ColTypes _getColType(int col) const;
    222222    virtual void _setColType(int col, ColTypes col_type);
  • lemon/lp_skeleton.cc

    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/lp_skeleton.cc
    a b  
    111111  LpSkeleton* LpSkeleton::_cloneSolver() const
    112112  { return static_cast<LpSkeleton*>(0); }
    113113
     114  const char* LpSkeleton::_solverName() const { return "LpSkeleton"; }
     115
    114116  MipSkeleton::SolveExitStatus MipSkeleton::_solve()
    115117  { return SOLVED; }
    116118
     
    126128  MipSkeleton* MipSkeleton::_cloneSolver() const
    127129  { return static_cast<MipSkeleton*>(0); }
    128130
     131  const char* MipSkeleton::_solverName() const { return "MipSkeleton"; }
     132
    129133} //namespace lemon
    130134
  • lemon/lp_skeleton.h

    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/lp_skeleton.h
    a b  
    2626namespace lemon {
    2727
    2828  ///A skeleton class to implement LP solver interfaces
    29   class SkeletonSolverBase : public virtual SolverBase {
     29  class SkeletonSolverBase : public virtual LpBase {
    3030    int col_num,row_num;
    3131
    3232  protected:
     
    140140  ///
    141141  /// This class implements an interface for a skeleton LP solver.
    142142  ///\ingroup lp_group
    143   class LpSkeleton : public SkeletonSolverBase, public LpBase {
     143  class LpSkeleton : public SkeletonSolverBase, public LpSolver {
    144144  public:
    145     LpSkeleton() : SkeletonSolverBase(), LpBase() {}
     145    LpSkeleton() : SkeletonSolverBase(), LpSolver() {}
    146146
    147147  protected:
    148148
     
    176176    virtual LpSkeleton* _newSolver() const;
    177177    ///\e
    178178    virtual LpSkeleton* _cloneSolver() const;
     179    ///\e
     180    virtual const char* _solverName() const;
    179181
    180182  };
    181183
     
    183185  ///
    184186  /// This class implements an interface for a skeleton MIP solver.
    185187  ///\ingroup lp_group
    186   class MipSkeleton : public SkeletonSolverBase, public MipBase {
     188  class MipSkeleton : public SkeletonSolverBase, public MipSolver {
    187189  public:
    188     MipSkeleton() : SkeletonSolverBase(), MipBase() {}
     190    MipSkeleton() : SkeletonSolverBase(), MipSolver() {}
    189191
    190192  protected:
    191193    ///\e
     
    217219
    218220    ///\e
    219221    virtual MipSkeleton* _cloneSolver() const;
     222    ///\e
     223    virtual const char* _solverName() const;
    220224
    221225  };
    222226
  • lemon/lp_soplex.cc

    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/lp_soplex.cc
    a b  
    2626///\brief Implementation of the LEMON-SOPLEX lp solver interface.
    2727namespace lemon {
    2828
    29   LpSoplex::LpSoplex()
    30     : SolverBase(), LpBase() {
     29  LpSoplex::LpSoplex() {
    3130    soplex = new soplex::SoPlex;
    3231  }
    3332
     
    3534    delete soplex;
    3635  }
    3736
    38   LpSoplex::LpSoplex(const LpSoplex& lp)
    39     : SolverBase(), LpBase() {
     37  LpSoplex::LpSoplex(const LpSoplex& lp) {
    4038    rows = lp.rows;
    4139    cols = lp.cols;
    4240
     
    6563    LpSoplex* newlp = new LpSoplex(*this);
    6664    return newlp;
    6765  }
     66
     67  const char* LpSoplex::_solverName() const { return "LpSoplex"; }
    6868
    6969  int LpSoplex::_addCol() {
    7070    soplex::LPCol c;
  • lemon/lp_soplex.h

    diff -r f259f5b9d9c7 -r 9347462c3106 lemon/lp_soplex.h
    a b  
    4343  /// developed at the Konrad-Zuse-Zentrum für Informationstechnik
    4444  /// Berlin (ZIB). You can find detailed information about it at the
    4545  /// <tt>http://soplex.zib.de</tt> address.
    46   class LpSoplex : public LpBase {
     46  class LpSoplex : public LpSolver {
    4747  private:
    4848
    4949    soplex::SoPlex* soplex;
     
    6767
    6868  public:
    6969
    70     typedef LpBase Parent;
    71 
    72 
    7370    /// \e
    7471    LpSoplex();
    7572    /// \e
     
    8077  protected:
    8178
    8279    virtual LpSoplex* _newSolver() const;
    83     virtual LpSoplex* _cloneSolver() const ;
     80    virtual LpSoplex* _cloneSolver() const;
     81
     82    virtual const char* _solverName() const;
    8483
    8584    virtual int _addCol();
    8685    virtual int _addRow();
  • test/lp_test.cc

    diff -r f259f5b9d9c7 -r 9347462c3106 test/lp_test.cc
    a b  
    4343
    4444using namespace lemon;
    4545
    46 void lpTest(LpBase & lp)
     46void lpTest(LpSolver& lp)
    4747{
    4848
    49   typedef LpBase LP;
     49  typedef LpSolver LP;
    5050
    5151  std::vector<LP::Col> x(10);
    5252  //  for(int i=0;i<10;i++) x.push_back(lp.addCol());
     
    195195    tolerance=0.02;
    196196    e.simplify(tolerance);
    197197    buf << "Coeff. of p2 should be 0";
    198     check(const_cast<const LpBase::Expr&>(e)[p2]==0, buf.str());
     198    check(const_cast<const LpSolver::Expr&>(e)[p2]==0, buf.str());
    199199
    200200
    201201  }
     
    235235
    236236}
    237237
    238 void solveAndCheck(LpBase& lp, LpBase::ProblemType stat,
     238void solveAndCheck(LpSolver& lp, LpSolver::ProblemType stat,
    239239                   double exp_opt) {
    240240  using std::string;
    241241  lp.solve();
     
    245245
    246246  check(lp.primalType()==stat, buf.str());
    247247
    248   if (stat ==  LpBase::OPTIMAL) {
     248  if (stat ==  LpSolver::OPTIMAL) {
    249249    std::ostringstream sbuf;
    250250    sbuf << "Wrong optimal value: the right optimum is " << exp_opt;
    251251    check(std::abs(lp.primal()-exp_opt) < 1e-3, sbuf.str());
    252252  }
    253253}
    254254
    255 void aTest(LpBase & lp)
     255void aTest(LpSolver & lp)
    256256{
    257   typedef LpBase LP;
     257  typedef LpSolver LP;
    258258
    259259 //The following example is very simple
    260260
    261   typedef LpBase::Row Row;
    262   typedef LpBase::Col Col;
     261  typedef LpSolver::Row Row;
     262  typedef LpSolver::Col Col;
    263263
    264264
    265265  Col x1 = lp.addCol();
     
    285285  check(lp.coeff(upright,x1)==1,"The coefficient in question is 1!");
    286286  check(lp.colLowerBound(x1)==0,
    287287        "The lower bound for variable x1 should be 0.");
    288   check(lp.colUpperBound(x1)==LpBase::INF,
     288  check(lp.colUpperBound(x1)==LpSolver::INF,
    289289        "The upper bound for variable x1 should be infty.");
    290   check(lp.rowLowerBound(upright) == -LpBase::INF,
     290  check(lp.rowLowerBound(upright) == -LpSolver::INF,
    291291        "The lower bound for the first row should be -infty.");
    292292  check(lp.rowUpperBound(upright)==1,
    293293        "The upper bound for the first row should be 1.");
    294   LpBase::Expr e = lp.row(upright);
     294  LpSolver::Expr e = lp.row(upright);
    295295  check(e[x1] == 1, "The first coefficient should 1.");
    296296  check(e[x2] == 2, "The second coefficient should 1.");
    297297
     
    300300  check(e[x1] == 1, "The first coefficient should 1.");
    301301  check(e[x2] == 1, "The second coefficient should 1.");
    302302
    303   LpBase::DualExpr de = lp.col(x1);
     303  LpSolver::DualExpr de = lp.col(x1);
    304304  check(  de[upright] == 1, "The first coefficient should 1.");
    305305
    306   LpBase* clp = lp.cloneSolver();
     306  LpSolver* clp = lp.cloneSolver();
    307307
    308308  //Testing the problem retrieving routines
    309309  check(clp->objCoeff(x1)==1,"First term should be 1 in the obj function!");
     
    312312  //  std::cout<<lp.colLowerBound(x1)<<std::endl;
    313313  check(clp->colLowerBound(x1)==0,
    314314        "The lower bound for variable x1 should be 0.");
    315   check(clp->colUpperBound(x1)==LpBase::INF,
     315  check(clp->colUpperBound(x1)==LpSolver::INF,
    316316        "The upper bound for variable x1 should be infty.");
    317317
    318   check(lp.rowLowerBound(upright)==-LpBase::INF,
     318  check(lp.rowLowerBound(upright)==-LpSolver::INF,
    319319        "The lower bound for the first row should be -infty.");
    320320  check(lp.rowUpperBound(upright)==1,
    321321        "The upper bound for the first row should be 1.");
     
    331331  //Maximization of x1+x2
    332332  //over the triangle with vertices (0,0) (0,1) (1,0)
    333333  double expected_opt=1;
    334   solveAndCheck(lp, LpBase::OPTIMAL, expected_opt);
     334  solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt);
    335335
    336336  //Minimization
    337337  lp.sense(lp.MIN);
    338338  expected_opt=0;
    339   solveAndCheck(lp, LpBase::OPTIMAL, expected_opt);
     339  solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt);
    340340
    341341  //Vertex (-1,0) instead of (0,0)
    342   lp.colLowerBound(x1, -LpBase::INF);
     342  lp.colLowerBound(x1, -LpSolver::INF);
    343343  expected_opt=-1;
    344   solveAndCheck(lp, LpBase::OPTIMAL, expected_opt);
     344  solveAndCheck(lp, LpSolver::OPTIMAL, expected_opt);
    345345
    346346  //Erase one constraint and return to maximization
    347347  lp.erase(upright);
    348348  lp.sense(lp.MAX);
    349   expected_opt=LpBase::INF;
    350   solveAndCheck(lp, LpBase::UNBOUNDED, expected_opt);
     349  expected_opt=LpSolver::INF;
     350  solveAndCheck(lp, LpSolver::UNBOUNDED, expected_opt);
    351351
    352352  //Infeasibilty
    353353  lp.addRow(x1+x2 <=-2);
    354   solveAndCheck(lp, LpBase::INFEASIBLE, expected_opt);
     354  solveAndCheck(lp, LpSolver::INFEASIBLE, expected_opt);
    355355
    356356}
    357357
  • test/mip_test.cc

    diff -r f259f5b9d9c7 -r 9347462c3106 test/mip_test.cc
    a b  
    3434
    3535using namespace lemon;
    3636
    37 void solveAndCheck(MipBase& mip, MipBase::ProblemType stat,
     37void solveAndCheck(MipSolver& mip, MipSolver::ProblemType stat,
    3838                   double exp_opt) {
    3939  using std::string;
    4040
     
    4747  //  itoa(stat,buf1, 10);
    4848  check(mip.type()==stat, buf.str());
    4949
    50   if (stat ==  MipBase::OPTIMAL) {
     50  if (stat ==  MipSolver::OPTIMAL) {
    5151    std::ostringstream sbuf;
    5252    buf << "Wrong optimal value: the right optimum is " << exp_opt;
    5353    check(std::abs(mip.solValue()-exp_opt) < 1e-3, sbuf.str());
     
    5555  }
    5656}
    5757
    58 void aTest(MipBase& mip)
     58void aTest(MipSolver& mip)
    5959{
    6060 //The following example is very simple
    6161
    6262
    63   typedef MipBase::Row Row;
    64   typedef MipBase::Col Col;
     63  typedef MipSolver::Row Row;
     64  typedef MipSolver::Col Col;
    6565
    6666
    6767
     
    8989  //Maximization of x1
    9090  //over the triangle with vertices (0,0),(4/5,2/5),(0,2)
    9191  double expected_opt=4.0/5.0;
    92   solveAndCheck(mip, MipBase::OPTIMAL, expected_opt);
     92  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
    9393
    9494  //Restrict x2 to integer
    95   mip.colType(x2,MipBase::INTEGER);
     95  mip.colType(x2,MipSolver::INTEGER);
    9696  expected_opt=1.0/2.0;
    97   solveAndCheck(mip, MipBase::OPTIMAL, expected_opt);
     97  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
    9898
    9999
    100100  //Restrict both to integer
    101   mip.colType(x1,MipBase::INTEGER);
     101  mip.colType(x1,MipSolver::INTEGER);
    102102  expected_opt=0;
    103   solveAndCheck(mip, MipBase::OPTIMAL, expected_opt);
     103  solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt);
    104104
    105105
    106106
     
    111111{
    112112
    113113#ifdef HAVE_GLPK
    114   MipGlpk mip1;
    115   aTest(mip1);
     114  {
     115    MipGlpk mip1;
     116    aTest(mip1);
     117  }
    116118#endif
    117119
    118120#ifdef HAVE_CPLEX
    119   MipCplex mip2;
    120   aTest(mip2);
     121  try {
     122    MipCplex mip2;
     123    aTest(mip2);
     124  } catch (CplexEnv::LicenseError& error) {
     125#ifdef LEMON_FORCE_CPLEX_CHECK
     126    check(false, error.what());
     127#else
     128    std::cerr << error.what() << std::endl;
     129    std::cerr << "Cplex license check failed, lp check skipped" << std::endl;
     130#endif
     131  }
    121132#endif
    122133
    123134  return 0;