Changeset 567:3314f58e7b25 in lemon-1.2 for test/mip_test.cc
- Timestamp:
- 04/01/09 22:58:58 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/mip_test.cc
r551 r567 19 19 #include "test_tools.h" 20 20 21 22 21 #ifdef HAVE_CONFIG_H 23 22 #include <lemon/config.h> … … 30 29 #ifdef HAVE_GLPK 31 30 #include <lemon/glpk.h> 31 #endif 32 33 #ifdef HAVE_CBC 34 #include <lemon/cbc.h> 32 35 #endif 33 36 … … 58 61 void aTest(MipSolver& mip) 59 62 { 60 //The following example is very simple63 //The following example is very simple 61 64 62 65 63 66 typedef MipSolver::Row Row; 64 67 typedef MipSolver::Col Col; 65 66 68 67 69 … … 75 77 mip.max(); 76 78 77 78 79 //Unconstrained optimization 79 80 mip.solve(); … … 81 82 82 83 //Constraints 83 mip.addRow(2 *x1+x2 <=2);84 mip.addRow(x1-2*x2 <=0);84 mip.addRow(2 * x1 + x2 <= 2); 85 Row y2 = mip.addRow(x1 - 2 * x2 <= 0); 85 86 86 87 //Nonnegativity of the variable x1 87 88 mip.colLowerBound(x1, 0); 89 88 90 89 91 //Maximization of x1 … … 91 93 double expected_opt=4.0/5.0; 92 94 solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); 95 93 96 94 97 //Restrict x2 to integer … … 103 106 solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); 104 107 105 108 //Erase a variable 109 mip.erase(x2); 110 mip.rowUpperBound(y2, 8); 111 expected_opt=1; 112 solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); 106 113 107 114 } 115 108 116 109 117 template<class MIP> … … 145 153 #endif 146 154 155 #ifdef HAVE_CBC 156 { 157 CbcMip mip1; 158 aTest(mip1); 159 cloneTest<CbcMip>(); 160 } 161 #endif 162 147 163 return 0; 148 164
Note: See TracChangeset
for help on using the changeset viewer.