[Lemon-commits] Alpar Juttner: Fix newSolver()/cloneSolver() API...

Lemon HG hg at lemon.cs.elte.hu
Wed Mar 4 14:54:46 CET 2009


details:   http://lemon.cs.elte.hu/hg/lemon/rev/9db62975c32b
changeset: 562:9db62975c32b
user:      Alpar Juttner <alpar [at] cs.elte.hu>
date:      Thu Feb 26 07:39:16 2009 +0000
description:
	Fix newSolver()/cloneSolver() API in LP tools + doc improvements
	(#230)
	 - More logical structure for newSolver()/cloneSolver()
	 - Fix compilation problem with gcc-3.3
	 - Doc improvements

diffstat:

13 files changed, 118 insertions(+), 78 deletions(-)
lemon/clp.cc         |    4 ++--
lemon/clp.h          |    8 +++++---
lemon/cplex.cc       |    8 ++++----
lemon/cplex.h        |   12 +++++++-----
lemon/glpk.cc        |    8 ++++----
lemon/glpk.h         |   18 ++++++++++--------
lemon/lp_base.h      |   31 ++++++++++---------------------
lemon/lp_skeleton.cc |    8 ++++----
lemon/lp_skeleton.h  |   50 +++++++++++++++++++++++++++++---------------------
lemon/soplex.cc      |    4 ++--
lemon/soplex.h       |    7 ++++---
test/lp_test.cc      |   25 ++++++++++++++++++++++++-
test/mip_test.cc     |   13 +++++++++++++

diffs (truncated from 547 to 300 lines):

diff --git a/lemon/clp.cc b/lemon/clp.cc
--- a/lemon/clp.cc
+++ b/lemon/clp.cc
@@ -56,12 +56,12 @@
     }
   }
 
-  ClpLp* ClpLp::_newSolver() const {
+  ClpLp* ClpLp::newSolver() const {
     ClpLp* newlp = new ClpLp;
     return newlp;
   }
 
-  ClpLp* ClpLp::_cloneSolver() const {
+  ClpLp* ClpLp::cloneSolver() const {
     ClpLp* copylp = new ClpLp(*this);
     return copylp;
   }
diff --git a/lemon/clp.h b/lemon/clp.h
--- a/lemon/clp.h
+++ b/lemon/clp.h
@@ -56,6 +56,11 @@
     /// \e
     ~ClpLp();
 
+    /// \e
+    virtual ClpLp* newSolver() const;
+    /// \e
+    virtual ClpLp* cloneSolver() const;
+
   protected:
 
     mutable double* _primal_ray;
@@ -66,9 +71,6 @@
 
   protected:
 
-    virtual ClpLp* _newSolver() const;
-    virtual ClpLp* _cloneSolver() const;
-
     virtual const char* _solverName() const;
 
     virtual int _addCol();
diff --git a/lemon/cplex.cc b/lemon/cplex.cc
--- a/lemon/cplex.cc
+++ b/lemon/cplex.cc
@@ -451,8 +451,8 @@
 
   CplexLp::~CplexLp() {}
 
-  CplexLp* CplexLp::_newSolver() const { return new CplexLp; }
-  CplexLp* CplexLp::_cloneSolver() const {return new CplexLp(*this); }
+  CplexLp* CplexLp::newSolver() const { return new CplexLp; }
+  CplexLp* CplexLp::cloneSolver() const {return new CplexLp(*this); }
 
   const char* CplexLp::_solverName() const { return "CplexLp"; }
 
@@ -823,8 +823,8 @@
 
   CplexMip::~CplexMip() {}
 
-  CplexMip* CplexMip::_newSolver() const { return new CplexMip; }
-  CplexMip* CplexMip::_cloneSolver() const {return new CplexMip(*this); }
+  CplexMip* CplexMip::newSolver() const { return new CplexMip; }
+  CplexMip* CplexMip::cloneSolver() const {return new CplexMip(*this); }
 
   const char* CplexMip::_solverName() const { return "CplexMip"; }
 
diff --git a/lemon/cplex.h b/lemon/cplex.h
--- a/lemon/cplex.h
+++ b/lemon/cplex.h
@@ -160,7 +160,7 @@
   ///
   /// This class implements an interface for the CPLEX LP solver.
   ///\ingroup lp_group
-  class CplexLp : public CplexBase, public LpSolver {
+  class CplexLp : public LpSolver, public CplexBase {
   public:
     /// \e
     CplexLp();
@@ -171,6 +171,11 @@
     /// \e
     virtual ~CplexLp();
 
+    /// \e
+    virtual CplexLp* cloneSolver() const;
+    /// \e
+    virtual CplexLp* newSolver() const;
+
   private:
 
     // these values cannot retrieved element by element
@@ -186,9 +191,6 @@
 
   protected:
 
-    virtual CplexLp* _cloneSolver() const;
-    virtual CplexLp* _newSolver() const;
-
     virtual const char* _solverName() const;
 
     virtual SolveExitStatus _solve();
@@ -222,7 +224,7 @@
   ///
   /// This class implements an interface for the CPLEX MIP solver.
   ///\ingroup lp_group
-  class CplexMip : public CplexBase, public MipSolver {
+  class CplexMip : public MipSolver, public CplexBase {
   public:
     /// \e
     CplexMip();
diff --git a/lemon/glpk.cc b/lemon/glpk.cc
--- a/lemon/glpk.cc
+++ b/lemon/glpk.cc
@@ -534,8 +534,8 @@
     messageLevel(MESSAGE_NO_OUTPUT);
   }
 
-  GlpkLp* GlpkLp::_newSolver() const { return new GlpkLp; }
-  GlpkLp* GlpkLp::_cloneSolver() const { return new GlpkLp(*this); }
+  GlpkLp* GlpkLp::newSolver() const { return new GlpkLp; }
+  GlpkLp* GlpkLp::cloneSolver() const { return new GlpkLp(*this); }
 
   const char* GlpkLp::_solverName() const { return "GlpkLp"; }
 
@@ -940,8 +940,8 @@
     return glp_mip_obj_val(lp);
   }
 
-  GlpkMip* GlpkMip::_newSolver() const { return new GlpkMip; }
-  GlpkMip* GlpkMip::_cloneSolver() const {return new GlpkMip(*this); }
+  GlpkMip* GlpkMip::newSolver() const { return new GlpkMip; }
+  GlpkMip* GlpkMip::cloneSolver() const {return new GlpkMip(*this); }
 
   const char* GlpkMip::_solverName() const { return "GlpkMip"; }
 
diff --git a/lemon/glpk.h b/lemon/glpk.h
--- a/lemon/glpk.h
+++ b/lemon/glpk.h
@@ -119,7 +119,7 @@
   ///
   /// This class implements an interface for the GLPK LP solver.
   ///\ingroup lp_group
-  class GlpkLp : public GlpkBase, public LpSolver {
+  class GlpkLp : public LpSolver, public GlpkBase {
   public:
 
     ///\e
@@ -127,6 +127,11 @@
     ///\e
     GlpkLp(const GlpkLp&);
 
+    ///\e
+    virtual GlpkLp* cloneSolver() const;
+    ///\e
+    virtual GlpkLp* newSolver() const;
+
   private:
 
     mutable std::vector<double> _primal_ray;
@@ -136,9 +141,6 @@
 
   protected:
 
-    virtual GlpkLp* _cloneSolver() const;
-    virtual GlpkLp* _newSolver() const;
-
     virtual const char* _solverName() const;
 
     virtual SolveExitStatus _solve();
@@ -203,7 +205,7 @@
   ///
   /// This class implements an interface for the GLPK MIP solver.
   ///\ingroup lp_group
-  class GlpkMip : public GlpkBase, public MipSolver {
+  class GlpkMip : public MipSolver, public GlpkBase {
   public:
 
     ///\e
@@ -211,11 +213,11 @@
     ///\e
     GlpkMip(const GlpkMip&);
 
+    virtual GlpkMip* cloneSolver() const;
+    virtual GlpkMip* newSolver() const;
+
   protected:
 
-    virtual GlpkMip* _cloneSolver() const;
-    virtual GlpkMip* _newSolver() const;
-
     virtual const char* _solverName() const;
 
     virtual ColTypes _getColType(int col) const;
diff --git a/lemon/lp_base.h b/lemon/lp_base.h
--- a/lemon/lp_base.h
+++ b/lemon/lp_base.h
@@ -918,8 +918,6 @@
   protected:
 
     //Abstract virtual functions
-    virtual LpBase* _newSolver() const = 0;
-    virtual LpBase* _cloneSolver() const = 0;
 
     virtual int _addColId(int col) { return cols.addIndex(col); }
     virtual int _addRowId(int row) { return rows.addIndex(row); }
@@ -987,11 +985,6 @@
     /// Virtual destructor
     virtual ~LpBase() {}
 
-    ///Creates a new LP problem
-    LpBase* newSolver() {return _newSolver();}
-    ///Makes a copy of the LP problem
-    LpBase* cloneSolver() {return _cloneSolver();}
-
     ///Gives back the name of the solver.
     const char* solverName() const {return _solverName();}
 
@@ -1821,6 +1814,11 @@
 
   public:
 
+    ///Allocate a new LP problem instance
+    virtual LpSolver* newSolver() const = 0;
+    ///Make a copy of the LP problem
+    virtual LpSolver* cloneSolver() const = 0;
+
     ///\name Solve the LP
 
     ///@{
@@ -1935,13 +1933,8 @@
     Value primal() const { return _getPrimalValue()+obj_const_comp;}
     ///@}
 
-    LpSolver* newSolver() {return _newSolver();}
-    LpSolver* cloneSolver() {return _cloneSolver();}
-
   protected:
 
-    virtual LpSolver* _newSolver() const = 0;
-    virtual LpSolver* _cloneSolver() const = 0;
   };
 
 
@@ -1975,6 +1968,11 @@
       UNBOUNDED = 4
     };
 
+    ///Allocate a new MIP problem instance
+    virtual MipSolver* newSolver() const = 0;
+    ///Make a copy of the MIP problem
+    virtual MipSolver* cloneSolver() const = 0;
+
     ///\name Solve the MIP
 
     ///@{
@@ -2062,15 +2060,6 @@
     virtual Value _getSol(int i) const = 0;
     virtual Value _getSolValue() const = 0;
 
-  public:
-
-    MipSolver* newSolver() {return _newSolver();}
-    MipSolver* cloneSolver() {return _cloneSolver();}
-
-  protected:
-
-    virtual MipSolver* _newSolver() const = 0;
-    virtual MipSolver* _cloneSolver() const = 0;
   };
 
 
diff --git a/lemon/lp_skeleton.cc b/lemon/lp_skeleton.cc
--- a/lemon/lp_skeleton.cc
+++ b/lemon/lp_skeleton.cc
@@ -105,10 +105,10 @@
   LpSkeleton::VarStatus LpSkeleton::_getRowStatus(int) const
   { return BASIC; }
 
-  LpSkeleton* LpSkeleton::_newSolver() const
+  LpSkeleton* LpSkeleton::newSolver() const
   { return static_cast<LpSkeleton*>(0); }
 
-  LpSkeleton* LpSkeleton::_cloneSolver() const
+  LpSkeleton* LpSkeleton::cloneSolver() const
   { return static_cast<LpSkeleton*>(0); }
 
   const char* LpSkeleton::_solverName() const { return "LpSkeleton"; }
@@ -122,10 +122,10 @@
   MipSkeleton::ProblemType MipSkeleton::_getType() const
   { return UNDEFINED; }
 
-  MipSkeleton* MipSkeleton::_newSolver() const
+  MipSkeleton* MipSkeleton::newSolver() const
   { return static_cast<MipSkeleton*>(0); }
 
-  MipSkeleton* MipSkeleton::_cloneSolver() const
+  MipSkeleton* MipSkeleton::cloneSolver() const
   { return static_cast<MipSkeleton*>(0); }
 



More information about the Lemon-commits mailing list