Changeset 2147:63d293ff1bef in lemon-0.x for test/mip_test.cc
- Timestamp:
- 07/17/06 11:31:41 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2861
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
test/mip_test.cc
r2146 r2147 1 1 #include <lemon/lp.h> 2 //#include <lemon/ilp_glpk.h>3 2 4 3 using namespace lemon; … … 6 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 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 } 12 return 0; 49 13 50 14 }
Note: See TracChangeset
for help on using the changeset viewer.