equal
deleted
inserted
replaced
1 #include <lemon/lp.h> |
1 #include <lemon/lp.h> |
2 //#include <lemon/ilp_glpk.h> |
|
3 |
2 |
4 using namespace lemon; |
3 using namespace lemon; |
5 |
4 |
6 int main(){ |
5 int main(){ |
7 |
6 |
8 //MipGlpk ilp; |
|
9 |
7 |
10 Mip ilp; |
8 #ifdef HAVE_GLPK |
|
9 //This needs some thinking |
|
10 #endif |
11 |
11 |
12 |
12 return 0; |
13 typedef Mip::Row Row; |
|
14 typedef Mip::Col Col; |
|
15 |
|
16 ilp.max(); |
|
17 |
|
18 Col x1 = ilp.addCol(); |
|
19 Col x2 = ilp.addCol(); |
|
20 Col x3 = ilp.addCol(); |
|
21 |
|
22 ilp.integer(x1,true); |
|
23 ilp.integer(x2,true); |
|
24 ilp.integer(x3,true); |
|
25 |
|
26 ilp.addRow(x1+x2+x3 <=100); |
|
27 ilp.addRow(10*x1+4*x2+5*x3<=600); |
|
28 ilp.addRow(2*x1+2*x2+6*x3<=300); |
|
29 |
|
30 ilp.colLowerBound(x1, 0); |
|
31 ilp.colLowerBound(x2, 0); |
|
32 ilp.colLowerBound(x3, 0); |
|
33 //Objective function |
|
34 ilp.setObj(10*x1+6*x2+4*x3); |
|
35 |
|
36 //Call the routine of the underlying LP solver |
|
37 ilp.solve(); |
|
38 |
|
39 //Print results |
|
40 if (ilp.primalStatus()==LpSolverBase::OPTIMAL){ |
|
41 std::cout<<"Optimal solution found!"<<std::endl; |
|
42 printf("optimum value = %g; x1 = %g; x2 = %g; x3 = %g\n", |
|
43 ilp.primalValue(), |
|
44 ilp.primal(x1), ilp.primal(x2), ilp.primal(x3)); |
|
45 } |
|
46 else{ |
|
47 std::cout<<"Optimal solution not found!"<<std::endl; |
|
48 } |
|
49 |
13 |
50 } |
14 } |