diff --git a/test/mip_test.cc b/test/mip_test.cc --- a/test/mip_test.cc +++ b/test/mip_test.cc @@ -18,7 +18,6 @@ #include "test_tools.h" - #ifdef HAVE_CONFIG_H #include #endif @@ -31,6 +30,10 @@ #include #endif +#ifdef HAVE_CBC +#include +#endif + using namespace lemon; @@ -57,14 +60,13 @@ void aTest(MipSolver& mip) { - //The following example is very simple + //The following example is very simple typedef MipSolver::Row Row; typedef MipSolver::Col Col; - Col x1 = mip.addCol(); Col x2 = mip.addCol(); @@ -74,23 +76,24 @@ mip.max(); - //Unconstrained optimization mip.solve(); //Check it out! //Constraints - mip.addRow(2*x1+x2 <=2); - mip.addRow(x1-2*x2 <=0); + mip.addRow(2 * x1 + x2 <= 2); + Row y2 = mip.addRow(x1 - 2 * x2 <= 0); //Nonnegativity of the variable x1 mip.colLowerBound(x1, 0); + //Maximization of x1 //over the triangle with vertices (0,0),(4/5,2/5),(0,2) double expected_opt=4.0/5.0; solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); + //Restrict x2 to integer mip.colType(x2,MipSolver::INTEGER); expected_opt=1.0/2.0; @@ -102,10 +105,15 @@ expected_opt=0; solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); - + //Erase a variable + mip.erase(x2); + mip.rowUpperBound(y2, 8); + expected_opt=1; + solveAndCheck(mip, MipSolver::OPTIMAL, expected_opt); } + template void cloneTest() { @@ -144,6 +152,14 @@ } #endif +#ifdef HAVE_CBC + { + CbcMip mip1; + aTest(mip1); + cloneTest(); + } +#endif + return 0; }