Missing cplex files: sorry.
1 #include "test_tools.h"
4 #include <lemon/mip_cplex.h>
5 #include <lemon/mip_glpk.h>
6 #include<lemon/config.h>
10 void solveAndCheck(MipSolverBase& lp, MipSolverBase::SolutionStatus stat,
16 std::ostringstream buf;
17 buf << "Primalstatus should be: " << int(stat)<<" and it is "<<int(lp.primalStatus());
20 // itoa(stat,buf1, 10);
21 check(lp.mipStatus()==stat, buf.str());
23 if (stat == MipSolverBase::OPTIMAL) {
24 std::ostringstream buf;
25 buf << "Wrong optimal value: the right optimum is " << exp_opt;
26 check(std::abs(lp.primalValue()-exp_opt) < 1e-3, buf.str());
31 void aTest(MipSolverBase& mip)
33 //The following example is very simple
36 typedef MipSolverBase::Row Row;
37 typedef MipSolverBase::Col Col;
41 Col x1 = mip.addCol();
42 Col x2 = mip.addCol();
51 //Unconstrained optimization
56 mip.addRow(2*x1+x2 <=2);
57 mip.addRow(x1-2*x2 <=0);
59 //Nonnegativity of the variable x1
60 mip.colLowerBound(x1, 0);
65 //over the triangle with vertices
66 double expected_opt=4.0/5.0;
67 solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt);
69 //Restrict x2 to integer
70 mip.colType(x2,MipSolverBase::LEMON_INTEGER);
72 solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt);
75 //Restrict both to integer
76 mip.colType(x1,MipSolverBase::LEMON_INTEGER);
78 solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt);
96 //std::cout<<ATTILA<<INTEGER;