Changeset 589:fc6c7aab4b8d in lemon
- Timestamp:
- 03/04/09 14:43:05 (16 years ago)
- Branch:
- default
- Parents:
- 588:89e29e22d479 (diff), 585:ba124394367a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Phase:
- public
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/glpk.cc
r585 r589 541 541 } 542 542 543 GlpkLp* GlpkLp:: _newSolver() const { return new GlpkLp; }544 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); } 545 545 546 546 const char* GlpkLp::_solverName() const { return "GlpkLp"; } … … 947 947 } 948 948 949 GlpkMip* GlpkMip:: _newSolver() const { return new GlpkMip; }950 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); } 951 951 952 952 const char* GlpkMip::_solverName() const { return "GlpkMip"; } -
lemon/glpk.cc
r587 r589 522 522 cols.clear(); 523 523 } 524 525 void GlpkBase::freeEnv() { 526 glp_free_env(); 527 } 528 529 GlpkBase::FreeEnvHelper GlpkBase::freeEnvHelper; 524 530 525 531 // GlpkLp members -
lemon/glpk.h
r585 r589 132 132 /// This class implements an interface for the GLPK LP solver. 133 133 ///\ingroup lp_group 134 class GlpkLp : public GlpkBase, public LpSolver{134 class GlpkLp : public LpSolver, public GlpkBase { 135 135 public: 136 136 … … 139 139 ///\e 140 140 GlpkLp(const GlpkLp&); 141 142 ///\e 143 virtual GlpkLp* cloneSolver() const; 144 ///\e 145 virtual GlpkLp* newSolver() const; 141 146 142 147 private: … … 148 153 149 154 protected: 150 151 virtual GlpkLp* _cloneSolver() const;152 virtual GlpkLp* _newSolver() const;153 155 154 156 virtual const char* _solverName() const; … … 166 168 virtual Value _getDualRay(int i) const; 167 169 168 ///\todo It should be clarified169 ///170 170 virtual ProblemType _getPrimalType() const; 171 171 virtual ProblemType _getDualType() const; … … 216 216 /// This class implements an interface for the GLPK MIP solver. 217 217 ///\ingroup lp_group 218 class GlpkMip : public GlpkBase, public MipSolver{218 class GlpkMip : public MipSolver, public GlpkBase { 219 219 public: 220 220 … … 224 224 GlpkMip(const GlpkMip&); 225 225 226 protected:227 228 virtual GlpkMip* _cloneSolver() const; 229 virtual GlpkMip* _newSolver() const;226 virtual GlpkMip* cloneSolver() const; 227 virtual GlpkMip* newSolver() const; 228 229 protected: 230 230 231 231 virtual const char* _solverName() const; -
lemon/glpk.h
r588 r589 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 -
test/lp_test.cc
r585 r589 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
r585 r589 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.