Changeset 2218:50f1a780a5ff in lemon-0.x for test/mip_test.cc
- Timestamp:
- 09/21/06 16:46:28 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2952
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/mip_test.cc
r2213 r2218 1 #include <lemon/lp.h>2 1 #include "test_tools.h" 2 3 4 #include <lemon/mip_cplex.h> 5 #include <lemon/mip_glpk.h> 6 #include<lemon/config.h> 3 7 4 8 using namespace lemon; 5 9 6 void solveAndCheck(Mip & lp, LpSolverBase::SolutionStatus stat,10 void solveAndCheck(MipSolverBase& lp, MipSolverBase::SolutionStatus stat, 7 11 double exp_opt) { 8 12 using std::string; 13 9 14 lp.solve(); 10 15 //int decimal,sign; … … 12 17 buf << "Primalstatus should be: " << int(stat)<<" and it is "<<int(lp.primalStatus()); 13 18 19 14 20 // itoa(stat,buf1, 10); 15 21 check(lp.mipStatus()==stat, buf.str()); 16 22 17 if (stat == LpSolverBase::OPTIMAL) {23 if (stat == MipSolverBase::OPTIMAL) { 18 24 std::ostringstream buf; 19 25 buf << "Wrong optimal value: the right optimum is " << exp_opt; … … 23 29 } 24 30 25 void aTest(Mip & mip)31 void aTest(MipSolverBase& mip) 26 32 { 27 33 //The following example is very simple 28 34 29 typedef Mip::Row Row; 30 typedef Mip::Col Col; 35 36 typedef MipSolverBase::Row Row; 37 typedef MipSolverBase::Col Col; 38 31 39 32 40 33 41 Col x1 = mip.addCol(); 34 42 Col x2 = mip.addCol(); 35 36 37 38 39 43 40 44 … … 61 65 //over the triangle with vertices 62 66 double expected_opt=4.0/5.0; 63 solveAndCheck(mip, Mip ::OPTIMAL, expected_opt);67 solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt); 64 68 65 69 //Restrict x2 to integer 66 mip.colType(x2,Mip ::INTEGER);70 mip.colType(x2,MipSolverBase::LEMON_INTEGER); 67 71 expected_opt=1.0/2.0; 68 solveAndCheck(mip, Mip ::OPTIMAL, expected_opt);72 solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt); 69 73 70 74 71 75 //Restrict both to integer 72 mip.colType(x1,Mip ::INTEGER);76 mip.colType(x1,MipSolverBase::LEMON_INTEGER); 73 77 expected_opt=0; 74 solveAndCheck(mip, Mip ::OPTIMAL, expected_opt);78 solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt); 75 79 76 80 … … 87 91 #endif 88 92 93 94 95 #ifdef HAVE_CPLEX 96 //std::cout<<ATTILA<<INTEGER; 97 MipCplex mip2; 98 aTest(mip2); 99 #endif 100 89 101 return 0; 90 102
Note: See TracChangeset
for help on using the changeset viewer.