Changes in / [546:d6b40ebb2617:547:d59dcc933e59] in lemon-1.2
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/clp.cc
r462 r540 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
r462 r540 57 57 ~ClpLp(); 58 58 59 /// \e 60 virtual ClpLp* newSolver() const; 61 /// \e 62 virtual ClpLp* cloneSolver() const; 63 59 64 protected: 60 65 … … 66 71 67 72 protected: 68 69 virtual ClpLp* _newSolver() const;70 virtual ClpLp* _cloneSolver() const;71 73 72 74 virtual const char* _solverName() const; -
lemon/cplex.cc
r462 r540 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
r462 r540 161 161 /// This class implements an interface for the CPLEX LP solver. 162 162 ///\ingroup lp_group 163 class CplexLp : public CplexBase, public LpSolver{163 class CplexLp : public LpSolver, public CplexBase { 164 164 public: 165 165 /// \e … … 171 171 /// \e 172 172 virtual ~CplexLp(); 173 174 /// \e 175 virtual CplexLp* cloneSolver() const; 176 /// \e 177 virtual CplexLp* newSolver() const; 173 178 174 179 private: … … 186 191 187 192 protected: 188 189 virtual CplexLp* _cloneSolver() const;190 virtual CplexLp* _newSolver() const;191 193 192 194 virtual const char* _solverName() const; … … 223 225 /// This class implements an interface for the CPLEX MIP solver. 224 226 ///\ingroup lp_group 225 class CplexMip : public CplexBase, public MipSolver{227 class CplexMip : public MipSolver, public CplexBase { 226 228 public: 227 229 /// \e -
lemon/glpk.cc
r462 r542 523 523 } 524 524 525 void GlpkBase::freeEnv() { 526 glp_free_env(); 527 } 528 529 GlpkBase::FreeEnvHelper GlpkBase::freeEnvHelper; 530 525 531 // GlpkLp members 526 532 … … 535 541 } 536 542 537 GlpkLp* GlpkLp:: _newSolver() const { return new GlpkLp; }538 GlpkLp* GlpkLp:: _cloneSolver() const { return new GlpkLp(*this); }543 GlpkLp* GlpkLp::newSolver() const { return new GlpkLp; } 544 GlpkLp* GlpkLp::cloneSolver() const { return new GlpkLp(*this); } 539 545 540 546 const char* GlpkLp::_solverName() const { return "GlpkLp"; } … … 941 947 } 942 948 943 GlpkMip* GlpkMip:: _newSolver() const { return new GlpkMip; }944 GlpkMip* GlpkMip:: _cloneSolver() const {return new GlpkMip(*this); }949 GlpkMip* GlpkMip::newSolver() const { return new GlpkMip; } 950 GlpkMip* GlpkMip::cloneSolver() const {return new GlpkMip(*this); } 945 951 946 952 const char* GlpkMip::_solverName() const { return "GlpkMip"; } -
lemon/glpk.h
r462 r542 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 103 115 public: 104 116 … … 120 132 /// This class implements an interface for the GLPK LP solver. 121 133 ///\ingroup lp_group 122 class GlpkLp : public GlpkBase, public LpSolver{134 class GlpkLp : public LpSolver, public GlpkBase { 123 135 public: 124 136 … … 127 139 ///\e 128 140 GlpkLp(const GlpkLp&); 141 142 ///\e 143 virtual GlpkLp* cloneSolver() const; 144 ///\e 145 virtual GlpkLp* newSolver() const; 129 146 130 147 private: … … 136 153 137 154 protected: 138 139 virtual GlpkLp* _cloneSolver() const;140 virtual GlpkLp* _newSolver() const;141 155 142 156 virtual const char* _solverName() const; … … 154 168 virtual Value _getDualRay(int i) const; 155 169 156 ///\todo It should be clarified157 ///158 170 virtual ProblemType _getPrimalType() const; 159 171 virtual ProblemType _getDualType() const; … … 204 216 /// This class implements an interface for the GLPK MIP solver. 205 217 ///\ingroup lp_group 206 class GlpkMip : public GlpkBase, public MipSolver{218 class GlpkMip : public MipSolver, public GlpkBase { 207 219 public: 208 220 … … 212 224 GlpkMip(const GlpkMip&); 213 225 214 protected:215 216 virtual GlpkMip* _cloneSolver() const; 217 virtual GlpkMip* _newSolver() const;226 virtual GlpkMip* cloneSolver() const; 227 virtual GlpkMip* newSolver() const; 228 229 protected: 218 230 219 231 virtual const char* _solverName() const; -
lemon/lp_base.h
r514 r540 919 919 920 920 //Abstract virtual functions 921 virtual LpBase* _newSolver() const = 0;922 virtual LpBase* _cloneSolver() const = 0;923 921 924 922 virtual int _addColId(int col) { return cols.addIndex(col); } … … 987 985 /// Virtual destructor 988 986 virtual ~LpBase() {} 989 990 ///Creates a new LP problem991 LpBase* newSolver() {return _newSolver();}992 ///Makes a copy of the LP problem993 LpBase* cloneSolver() {return _cloneSolver();}994 987 995 988 ///Gives back the name of the solver. … … 1822 1815 public: 1823 1816 1817 ///Allocate a new LP problem instance 1818 virtual LpSolver* newSolver() const = 0; 1819 ///Make a copy of the LP problem 1820 virtual LpSolver* cloneSolver() const = 0; 1821 1824 1822 ///\name Solve the LP 1825 1823 … … 1936 1934 ///@} 1937 1935 1938 LpSolver* newSolver() {return _newSolver();}1939 LpSolver* cloneSolver() {return _cloneSolver();}1940 1941 1936 protected: 1942 1937 1943 virtual LpSolver* _newSolver() const = 0;1944 virtual LpSolver* _cloneSolver() const = 0;1945 1938 }; 1946 1939 … … 1976 1969 }; 1977 1970 1971 ///Allocate a new MIP problem instance 1972 virtual MipSolver* newSolver() const = 0; 1973 ///Make a copy of the MIP problem 1974 virtual MipSolver* cloneSolver() const = 0; 1975 1978 1976 ///\name Solve the MIP 1979 1977 … … 2063 2061 virtual Value _getSolValue() const = 0; 2064 2062 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;2074 2063 }; 2075 2064 -
lemon/lp_skeleton.cc
r459 r540 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
r529 r541 23 23 24 24 ///\file 25 ///\brief A skeleton file to implement LP solver interfaces 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. 26 29 namespace lemon { 27 30 28 ///A skeleton class to implement LP solver interfaces 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. 29 35 class SkeletonSolverBase : public virtual LpBase { 30 36 int col_num,row_num; … … 137 143 }; 138 144 139 /// \brief Interface for a skeleton LP solver145 /// \brief Skeleton class for an LP solver interface 140 146 /// 141 /// This class implements an interface for a skeleton LP solver. 147 ///This class does nothing, but it can serve as a skeleton when 148 ///implementing an interface to new solvers. 149 142 150 ///\ingroup lp_group 143 class LpSkeleton : public SkeletonSolverBase, public LpSolver{151 class LpSkeleton : public LpSolver, public SkeletonSolverBase { 144 152 public: 145 LpSkeleton() : SkeletonSolverBase(), LpSolver() {} 146 153 ///\e 154 LpSkeleton() : LpSolver(), SkeletonSolverBase() {} 155 ///\e 156 virtual LpSkeleton* newSolver() const; 157 ///\e 158 virtual LpSkeleton* cloneSolver() const; 147 159 protected: 148 160 … … 174 186 175 187 ///\e 176 virtual LpSkeleton* _newSolver() const;177 ///\e178 virtual LpSkeleton* _cloneSolver() const;179 ///\e180 188 virtual const char* _solverName() const; 181 189 182 190 }; 183 191 184 /// \brief Interface for a skeleton MIP solver192 /// \brief Skeleton class for a MIP solver interface 185 193 /// 186 /// This class implements an interface for a skeleton MIP solver. 194 ///This class does nothing, but it can serve as a skeleton when 195 ///implementing an interface to new solvers. 187 196 ///\ingroup lp_group 188 class MipSkeleton : public SkeletonSolverBase, public MipSolver{197 class MipSkeleton : public MipSolver, public SkeletonSolverBase { 189 198 public: 190 MipSkeleton() : SkeletonSolverBase(), MipSolver() {} 199 ///\e 200 MipSkeleton() : MipSolver(), SkeletonSolverBase() {} 201 ///\e 202 virtual MipSkeleton* newSolver() const; 203 ///\e 204 virtual MipSkeleton* cloneSolver() const; 191 205 192 206 protected: 193 207 ///\e 194 195 ///\bug Wrong interface196 ///197 208 virtual SolveExitStatus _solve(); 198 209 199 210 ///\e 200 201 ///\bug Wrong interface202 ///203 211 virtual Value _getSol(int i) const; 204 212 205 213 ///\e 206 207 ///\bug Wrong interface208 ///209 214 virtual Value _getSolValue() const; 210 215 211 216 ///\e 212 213 ///\bug Wrong interface214 ///215 217 virtual ProblemType _getType() const; 216 218 217 219 ///\e 218 virtual MipSkeleton* _newSolver() const;219 220 ///\e221 virtual MipSkeleton* _cloneSolver() const;222 ///\e223 220 virtual const char* _solverName() const; 224 225 221 }; 226 222 -
lemon/soplex.cc
r462 r540 20 20 #include <lemon/soplex.h> 21 21 22 #include <soplex /soplex.h>22 #include <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
r462 r540 74 74 /// \e 75 75 ~SoplexLp(); 76 /// \e 77 virtual SoplexLp* newSolver() const; 78 /// \e 79 virtual SoplexLp* cloneSolver() const; 76 80 77 81 protected: 78 79 virtual SoplexLp* _newSolver() const;80 virtual SoplexLp* _cloneSolver() const;81 82 82 83 virtual const char* _solverName() const; -
m4/lx_check_soplex.m4
r457 r539 21 21 SOPLEX_CXXFLAGS="-I$with_soplex_includedir" 22 22 elif test x"$with_soplex" != x"yes"; then 23 SOPLEX_CXXFLAGS="-I$with_soplex/ include"23 SOPLEX_CXXFLAGS="-I$with_soplex/src" 24 24 fi 25 25 … … 39 39 40 40 lx_soplex_test_prog=' 41 #include <soplex /soplex.h>41 #include <soplex.h> 42 42 43 43 int main(int argc, char** argv) -
test/lp_test.cc
r462 r542 198 198 check(const_cast<const LpSolver::Expr&>(e)[p2]==0, buf.str()); 199 199 200 //Test for clone/new 201 LP* lpnew = lp.newSolver(); 202 LP* lpclone = lp.cloneSolver(); 203 delete lpnew; 204 delete lpclone; 200 205 201 206 } … … 248 253 if (stat == LpSolver::OPTIMAL) { 249 254 std::ostringstream sbuf; 250 sbuf << "Wrong optimal value: the right optimum is " << exp_opt; 255 sbuf << "Wrong optimal value (" << lp.primal() <<") with " 256 << lp.solverName() <<"\n the right optimum is " << exp_opt; 251 257 check(std::abs(lp.primal()-exp_opt) < 1e-3, sbuf.str()); 252 258 } … … 356 362 } 357 363 364 template<class LP> 365 void cloneTest() 366 { 367 //Test for clone/new 368 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 358 377 int main() 359 378 { … … 366 385 lpTest(lp_glpk1); 367 386 aTest(lp_glpk2); 387 cloneTest<GlpkLp>(); 368 388 } 369 389 #endif … … 382 402 #endif 383 403 } 404 cloneTest<CplexLp>(); 384 405 #endif 385 406 … … 389 410 lpTest(lp_soplex1); 390 411 aTest(lp_soplex2); 412 cloneTest<SoplexLp>(); 391 413 } 392 414 #endif … … 397 419 lpTest(lp_clp1); 398 420 aTest(lp_clp2); 421 cloneTest<ClpLp>(); 399 422 } 400 423 #endif -
test/mip_test.cc
r462 r542 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 } 109 120 110 121 int main() … … 115 126 GlpkMip mip1; 116 127 aTest(mip1); 128 cloneTest<GlpkMip>(); 117 129 } 118 130 #endif … … 130 142 #endif 131 143 } 144 cloneTest<CplexMip>(); 132 145 #endif 133 146
Note: See TracChangeset
for help on using the changeset viewer.