Changes in / [594:d59dcc933e59:593:d6b40ebb2617] in lemon
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/clp.cc
r587 r485 57 57 } 58 58 59 ClpLp* ClpLp:: newSolver() const {59 ClpLp* ClpLp::_newSolver() const { 60 60 ClpLp* newlp = new ClpLp; 61 61 return newlp; 62 62 } 63 63 64 ClpLp* ClpLp:: cloneSolver() const {64 ClpLp* ClpLp::_cloneSolver() const { 65 65 ClpLp* copylp = new ClpLp(*this); 66 66 return copylp; -
lemon/clp.h
r587 r485 57 57 ~ClpLp(); 58 58 59 /// \e60 virtual ClpLp* newSolver() const;61 /// \e62 virtual ClpLp* cloneSolver() const;63 64 59 protected: 65 60 … … 71 66 72 67 protected: 68 69 virtual ClpLp* _newSolver() const; 70 virtual ClpLp* _cloneSolver() const; 73 71 74 72 virtual const char* _solverName() const; -
lemon/cplex.cc
r587 r485 452 452 CplexLp::~CplexLp() {} 453 453 454 CplexLp* CplexLp:: newSolver() const { return new CplexLp; }455 CplexLp* CplexLp:: cloneSolver() const {return new CplexLp(*this); }454 CplexLp* CplexLp::_newSolver() const { return new CplexLp; } 455 CplexLp* CplexLp::_cloneSolver() const {return new CplexLp(*this); } 456 456 457 457 const char* CplexLp::_solverName() const { return "CplexLp"; } … … 824 824 CplexMip::~CplexMip() {} 825 825 826 CplexMip* CplexMip:: newSolver() const { return new CplexMip; }827 CplexMip* CplexMip:: cloneSolver() const {return new CplexMip(*this); }826 CplexMip* CplexMip::_newSolver() const { return new CplexMip; } 827 CplexMip* CplexMip::_cloneSolver() const {return new CplexMip(*this); } 828 828 829 829 const char* CplexMip::_solverName() const { return "CplexMip"; } -
lemon/cplex.h
r587 r485 161 161 /// This class implements an interface for the CPLEX LP solver. 162 162 ///\ingroup lp_group 163 class CplexLp : public LpSolver, public CplexBase{163 class CplexLp : public CplexBase, public LpSolver { 164 164 public: 165 165 /// \e … … 171 171 /// \e 172 172 virtual ~CplexLp(); 173 174 /// \e175 virtual CplexLp* cloneSolver() const;176 /// \e177 virtual CplexLp* newSolver() const;178 173 179 174 private: … … 191 186 192 187 protected: 188 189 virtual CplexLp* _cloneSolver() const; 190 virtual CplexLp* _newSolver() const; 193 191 194 192 virtual const char* _solverName() const; … … 225 223 /// This class implements an interface for the CPLEX MIP solver. 226 224 ///\ingroup lp_group 227 class CplexMip : public MipSolver, public CplexBase{225 class CplexMip : public CplexBase, public MipSolver { 228 226 public: 229 227 /// \e -
lemon/glpk.cc
r589 r485 523 523 } 524 524 525 void GlpkBase::freeEnv() {526 glp_free_env();527 }528 529 GlpkBase::FreeEnvHelper GlpkBase::freeEnvHelper;530 531 525 // GlpkLp members 532 526 … … 541 535 } 542 536 543 GlpkLp* GlpkLp:: newSolver() const { return new GlpkLp; }544 GlpkLp* GlpkLp:: cloneSolver() const { return new GlpkLp(*this); }537 GlpkLp* GlpkLp::_newSolver() const { return new GlpkLp; } 538 GlpkLp* GlpkLp::_cloneSolver() const { return new GlpkLp(*this); } 545 539 546 540 const char* GlpkLp::_solverName() const { return "GlpkLp"; } … … 947 941 } 948 942 949 GlpkMip* GlpkMip:: newSolver() const { return new GlpkMip; }950 GlpkMip* GlpkMip:: cloneSolver() const {return new GlpkMip(*this); }943 GlpkMip* GlpkMip::_newSolver() const { return new GlpkMip; } 944 GlpkMip* GlpkMip::_cloneSolver() const {return new GlpkMip(*this); } 951 945 952 946 const char* GlpkMip::_solverName() const { return "GlpkMip"; } -
lemon/glpk.h
r589 r485 101 101 virtual void _clear(); 102 102 103 private:104 105 static void freeEnv();106 107 struct FreeEnvHelper {108 ~FreeEnvHelper() {109 freeEnv();110 }111 };112 113 static FreeEnvHelper freeEnvHelper;114 115 103 public: 116 104 … … 132 120 /// This class implements an interface for the GLPK LP solver. 133 121 ///\ingroup lp_group 134 class GlpkLp : public LpSolver, public GlpkBase{122 class GlpkLp : public GlpkBase, public LpSolver { 135 123 public: 136 124 … … 139 127 ///\e 140 128 GlpkLp(const GlpkLp&); 141 142 ///\e143 virtual GlpkLp* cloneSolver() const;144 ///\e145 virtual GlpkLp* newSolver() const;146 129 147 130 private: … … 153 136 154 137 protected: 138 139 virtual GlpkLp* _cloneSolver() const; 140 virtual GlpkLp* _newSolver() const; 155 141 156 142 virtual const char* _solverName() const; … … 168 154 virtual Value _getDualRay(int i) const; 169 155 156 ///\todo It should be clarified 157 /// 170 158 virtual ProblemType _getPrimalType() const; 171 159 virtual ProblemType _getDualType() const; … … 216 204 /// This class implements an interface for the GLPK MIP solver. 217 205 ///\ingroup lp_group 218 class GlpkMip : public MipSolver, public GlpkBase{206 class GlpkMip : public GlpkBase, public MipSolver { 219 207 public: 220 208 … … 224 212 GlpkMip(const GlpkMip&); 225 213 226 virtual GlpkMip* cloneSolver() const;227 virtual GlpkMip* newSolver() const; 228 229 protected:214 protected: 215 216 virtual GlpkMip* _cloneSolver() const; 217 virtual GlpkMip* _newSolver() const; 230 218 231 219 virtual const char* _solverName() const; -
lemon/lp_base.h
r587 r561 919 919 920 920 //Abstract virtual functions 921 virtual LpBase* _newSolver() const = 0; 922 virtual LpBase* _cloneSolver() const = 0; 921 923 922 924 virtual int _addColId(int col) { return cols.addIndex(col); } … … 985 987 /// Virtual destructor 986 988 virtual ~LpBase() {} 989 990 ///Creates a new LP problem 991 LpBase* newSolver() {return _newSolver();} 992 ///Makes a copy of the LP problem 993 LpBase* cloneSolver() {return _cloneSolver();} 987 994 988 995 ///Gives back the name of the solver. … … 1815 1822 public: 1816 1823 1817 ///Allocate a new LP problem instance1818 virtual LpSolver* newSolver() const = 0;1819 ///Make a copy of the LP problem1820 virtual LpSolver* cloneSolver() const = 0;1821 1822 1824 ///\name Solve the LP 1823 1825 … … 1934 1936 ///@} 1935 1937 1938 LpSolver* newSolver() {return _newSolver();} 1939 LpSolver* cloneSolver() {return _cloneSolver();} 1940 1936 1941 protected: 1937 1942 1943 virtual LpSolver* _newSolver() const = 0; 1944 virtual LpSolver* _cloneSolver() const = 0; 1938 1945 }; 1939 1946 … … 1969 1976 }; 1970 1977 1971 ///Allocate a new MIP problem instance1972 virtual MipSolver* newSolver() const = 0;1973 ///Make a copy of the MIP problem1974 virtual MipSolver* cloneSolver() const = 0;1975 1976 1978 ///\name Solve the MIP 1977 1979 … … 2061 2063 virtual Value _getSolValue() const = 0; 2062 2064 2065 public: 2066 2067 MipSolver* newSolver() {return _newSolver();} 2068 MipSolver* cloneSolver() {return _cloneSolver();} 2069 2070 protected: 2071 2072 virtual MipSolver* _newSolver() const = 0; 2073 virtual MipSolver* _cloneSolver() const = 0; 2063 2074 }; 2064 2075 -
lemon/lp_skeleton.cc
r587 r482 106 106 { return BASIC; } 107 107 108 LpSkeleton* LpSkeleton:: newSolver() const108 LpSkeleton* LpSkeleton::_newSolver() const 109 109 { return static_cast<LpSkeleton*>(0); } 110 110 111 LpSkeleton* LpSkeleton:: cloneSolver() const111 LpSkeleton* LpSkeleton::_cloneSolver() const 112 112 { return static_cast<LpSkeleton*>(0); } 113 113 … … 123 123 { return UNDEFINED; } 124 124 125 MipSkeleton* MipSkeleton:: newSolver() const125 MipSkeleton* MipSkeleton::_newSolver() const 126 126 { return static_cast<MipSkeleton*>(0); } 127 127 128 MipSkeleton* MipSkeleton:: cloneSolver() const128 MipSkeleton* MipSkeleton::_cloneSolver() const 129 129 { return static_cast<MipSkeleton*>(0); } 130 130 -
lemon/lp_skeleton.h
r588 r576 23 23 24 24 ///\file 25 ///\brief Skeleton file to implement LP/MIP solver interfaces 26 /// 27 ///The classes in this file do nothing, but they can serve as skeletons when 28 ///implementing an interface to new solvers. 25 ///\brief A skeleton file to implement LP solver interfaces 29 26 namespace lemon { 30 27 31 ///A skeleton class to implement LP/MIP solver base interface 32 33 ///This class does nothing, but it can serve as a skeleton when 34 ///implementing an interface to new solvers. 28 ///A skeleton class to implement LP solver interfaces 35 29 class SkeletonSolverBase : public virtual LpBase { 36 30 int col_num,row_num; … … 143 137 }; 144 138 145 /// \brief Skeleton class for an LP solver interface139 /// \brief Interface for a skeleton LP solver 146 140 /// 147 ///This class does nothing, but it can serve as a skeleton when 148 ///implementing an interface to new solvers. 149 141 /// This class implements an interface for a skeleton LP solver. 150 142 ///\ingroup lp_group 151 class LpSkeleton : public LpSolver, public SkeletonSolverBase{143 class LpSkeleton : public SkeletonSolverBase, public LpSolver { 152 144 public: 153 ///\e 154 LpSkeleton() : LpSolver(), SkeletonSolverBase() {} 155 ///\e 156 virtual LpSkeleton* newSolver() const; 157 ///\e 158 virtual LpSkeleton* cloneSolver() const; 145 LpSkeleton() : SkeletonSolverBase(), LpSolver() {} 146 159 147 protected: 160 148 … … 186 174 187 175 ///\e 176 virtual LpSkeleton* _newSolver() const; 177 ///\e 178 virtual LpSkeleton* _cloneSolver() const; 179 ///\e 188 180 virtual const char* _solverName() const; 189 181 190 182 }; 191 183 192 /// \brief Skeleton class for a MIP solver interface184 /// \brief Interface for a skeleton MIP solver 193 185 /// 194 ///This class does nothing, but it can serve as a skeleton when 195 ///implementing an interface to new solvers. 186 /// This class implements an interface for a skeleton MIP solver. 196 187 ///\ingroup lp_group 197 class MipSkeleton : public MipSolver, public SkeletonSolverBase{188 class MipSkeleton : public SkeletonSolverBase, public MipSolver { 198 189 public: 199 ///\e 200 MipSkeleton() : MipSolver(), SkeletonSolverBase() {} 201 ///\e 202 virtual MipSkeleton* newSolver() const; 203 ///\e 204 virtual MipSkeleton* cloneSolver() const; 190 MipSkeleton() : SkeletonSolverBase(), MipSolver() {} 205 191 206 192 protected: 207 193 ///\e 194 195 ///\bug Wrong interface 196 /// 208 197 virtual SolveExitStatus _solve(); 209 198 210 199 ///\e 200 201 ///\bug Wrong interface 202 /// 211 203 virtual Value _getSol(int i) const; 212 204 213 205 ///\e 206 207 ///\bug Wrong interface 208 /// 214 209 virtual Value _getSolValue() const; 215 210 216 211 ///\e 212 213 ///\bug Wrong interface 214 /// 217 215 virtual ProblemType _getType() const; 218 216 219 217 ///\e 218 virtual MipSkeleton* _newSolver() const; 219 220 ///\e 221 virtual MipSkeleton* _cloneSolver() const; 222 ///\e 220 223 virtual const char* _solverName() const; 224 221 225 }; 222 226 -
lemon/soplex.cc
r587 r485 20 20 #include <lemon/soplex.h> 21 21 22 #include <soplex .h>22 #include <soplex/soplex.h> 23 23 24 24 … … 55 55 } 56 56 57 SoplexLp* SoplexLp:: newSolver() const {57 SoplexLp* SoplexLp::_newSolver() const { 58 58 SoplexLp* newlp = new SoplexLp(); 59 59 return newlp; 60 60 } 61 61 62 SoplexLp* SoplexLp:: cloneSolver() const {62 SoplexLp* SoplexLp::_cloneSolver() const { 63 63 SoplexLp* newlp = new SoplexLp(*this); 64 64 return newlp; -
lemon/soplex.h
r587 r485 74 74 /// \e 75 75 ~SoplexLp(); 76 /// \e77 virtual SoplexLp* newSolver() const;78 /// \e79 virtual SoplexLp* cloneSolver() const;80 76 81 77 protected: 78 79 virtual SoplexLp* _newSolver() const; 80 virtual SoplexLp* _cloneSolver() const; 82 81 83 82 virtual const char* _solverName() const; -
m4/lx_check_soplex.m4
r586 r480 21 21 SOPLEX_CXXFLAGS="-I$with_soplex_includedir" 22 22 elif test x"$with_soplex" != x"yes"; then 23 SOPLEX_CXXFLAGS="-I$with_soplex/ src"23 SOPLEX_CXXFLAGS="-I$with_soplex/include" 24 24 fi 25 25 … … 39 39 40 40 lx_soplex_test_prog=' 41 #include <soplex .h>41 #include <soplex/soplex.h> 42 42 43 43 int main(int argc, char** argv) -
test/lp_test.cc
r589 r485 198 198 check(const_cast<const LpSolver::Expr&>(e)[p2]==0, buf.str()); 199 199 200 //Test for clone/new201 LP* lpnew = lp.newSolver();202 LP* lpclone = lp.cloneSolver();203 delete lpnew;204 delete lpclone;205 200 206 201 } … … 253 248 if (stat == LpSolver::OPTIMAL) { 254 249 std::ostringstream sbuf; 255 sbuf << "Wrong optimal value (" << lp.primal() <<") with " 256 << lp.solverName() <<"\n the right optimum is " << exp_opt; 250 sbuf << "Wrong optimal value: the right optimum is " << exp_opt; 257 251 check(std::abs(lp.primal()-exp_opt) < 1e-3, sbuf.str()); 258 252 } … … 362 356 } 363 357 364 template<class LP>365 void cloneTest()366 {367 //Test for clone/new368 369 LP* lp = new LP();370 LP* lpnew = lp->newSolver();371 LP* lpclone = lp->cloneSolver();372 delete lp;373 delete lpnew;374 delete lpclone;375 }376 377 358 int main() 378 359 { … … 385 366 lpTest(lp_glpk1); 386 367 aTest(lp_glpk2); 387 cloneTest<GlpkLp>();388 368 } 389 369 #endif … … 402 382 #endif 403 383 } 404 cloneTest<CplexLp>();405 384 #endif 406 385 … … 410 389 lpTest(lp_soplex1); 411 390 aTest(lp_soplex2); 412 cloneTest<SoplexLp>();413 391 } 414 392 #endif … … 419 397 lpTest(lp_clp1); 420 398 aTest(lp_clp2); 421 cloneTest<ClpLp>();422 399 } 423 400 #endif -
test/mip_test.cc
r589 r485 107 107 } 108 108 109 template<class MIP>110 void cloneTest()111 {112 113 MIP* mip = new MIP();114 MIP* mipnew = mip->newSolver();115 MIP* mipclone = mip->cloneSolver();116 delete mip;117 delete mipnew;118 delete mipclone;119 }120 109 121 110 int main() … … 126 115 GlpkMip mip1; 127 116 aTest(mip1); 128 cloneTest<GlpkMip>();129 117 } 130 118 #endif … … 142 130 #endif 143 131 } 144 cloneTest<CplexMip>();145 132 #endif 146 133
Note: See TracChangeset
for help on using the changeset viewer.