Still not final.
authorathos
Mon, 17 Jul 2006 09:16:00 +0000
changeset 21465fcb6598276d
parent 2145 73e0c8207e11
child 2147 63d293ff1bef
Still not final.
demo/mip_demo.cc
demo/mip_test.cc
test/mip_test.cc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/demo/mip_demo.cc	Mon Jul 17 09:16:00 2006 +0000
     1.3 @@ -0,0 +1,50 @@
     1.4 +#include <lemon/lp.h>
     1.5 +//#include <lemon/ilp_glpk.h>
     1.6 +
     1.7 +using namespace lemon;
     1.8 +
     1.9 +int main(){
    1.10 +
    1.11 +  //MipGlpk ilp;
    1.12 +
    1.13 +   Mip ilp;
    1.14 +
    1.15 +    
    1.16 +  typedef Mip::Row Row;
    1.17 +  typedef Mip::Col Col;
    1.18 +  
    1.19 +  ilp.max();
    1.20 +  
    1.21 +  Col x1 = ilp.addCol();
    1.22 +  Col x2 = ilp.addCol();
    1.23 +  Col x3 = ilp.addCol();
    1.24 +  
    1.25 +  ilp.integer(x1,true);
    1.26 +  ilp.integer(x2,true);
    1.27 +  ilp.integer(x3,true);
    1.28 +  
    1.29 +  ilp.addRow(x1+x2+x3 <=100);  
    1.30 +  ilp.addRow(10*x1+4*x2+5*x3<=600);  
    1.31 +  ilp.addRow(2*x1+2*x2+6*x3<=300); 
    1.32 +  
    1.33 +  ilp.colLowerBound(x1, 0);
    1.34 +  ilp.colLowerBound(x2, 0);
    1.35 +  ilp.colLowerBound(x3, 0);
    1.36 +  //Objective function
    1.37 +  ilp.setObj(10*x1+6*x2+4*x3);
    1.38 +  
    1.39 +  //Call the routine of the underlying LP solver
    1.40 +  ilp.solve();
    1.41 +  
    1.42 +  //Print results
    1.43 +  if (ilp.primalStatus()==LpSolverBase::OPTIMAL){
    1.44 +    std::cout<<"Optimal solution found!"<<std::endl;
    1.45 +    printf("optimum value = %g; x1 = %g; x2 = %g; x3 = %g\n", 
    1.46 +           ilp.primalValue(), 
    1.47 +           ilp.primal(x1), ilp.primal(x2), ilp.primal(x3));
    1.48 +  }
    1.49 +  else{
    1.50 +    std::cout<<"Optimal solution not found!"<<std::endl;
    1.51 +  }
    1.52 +
    1.53 +}
     2.1 --- a/demo/mip_test.cc	Mon Jul 17 09:10:19 2006 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,50 +0,0 @@
     2.4 -#include <lemon/lp.h>
     2.5 -//#include <lemon/ilp_glpk.h>
     2.6 -
     2.7 -using namespace lemon;
     2.8 -
     2.9 -int main(){
    2.10 -
    2.11 -  //MipGlpk ilp;
    2.12 -
    2.13 -   Mip ilp;
    2.14 -
    2.15 -    
    2.16 -  typedef Mip::Row Row;
    2.17 -  typedef Mip::Col Col;
    2.18 -  
    2.19 -  ilp.max();
    2.20 -  
    2.21 -  Col x1 = ilp.addCol();
    2.22 -  Col x2 = ilp.addCol();
    2.23 -  Col x3 = ilp.addCol();
    2.24 -  
    2.25 -  ilp.integer(x1,true);
    2.26 -  ilp.integer(x2,true);
    2.27 -  ilp.integer(x3,true);
    2.28 -  
    2.29 -  ilp.addRow(x1+x2+x3 <=100);  
    2.30 -  ilp.addRow(10*x1+4*x2+5*x3<=600);  
    2.31 -  ilp.addRow(2*x1+2*x2+6*x3<=300); 
    2.32 -  
    2.33 -  ilp.colLowerBound(x1, 0);
    2.34 -  ilp.colLowerBound(x2, 0);
    2.35 -  ilp.colLowerBound(x3, 0);
    2.36 -  //Objective function
    2.37 -  ilp.setObj(10*x1+6*x2+4*x3);
    2.38 -  
    2.39 -  //Call the routine of the underlying LP solver
    2.40 -  ilp.solve();
    2.41 -  
    2.42 -  //Print results
    2.43 -  if (ilp.primalStatus()==LpSolverBase::OPTIMAL){
    2.44 -    std::cout<<"Optimal solution found!"<<std::endl;
    2.45 -    printf("optimum value = %g; x1 = %g; x2 = %g; x3 = %g\n", 
    2.46 -           ilp.primalValue(), 
    2.47 -           ilp.primal(x1), ilp.primal(x2), ilp.primal(x3));
    2.48 -  }
    2.49 -  else{
    2.50 -    std::cout<<"Optimal solution not found!"<<std::endl;
    2.51 -  }
    2.52 -
    2.53 -}
     3.1 --- a/test/mip_test.cc	Mon Jul 17 09:10:19 2006 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,50 +0,0 @@
     3.4 -#include <lemon/lp.h>
     3.5 -//#include <lemon/ilp_glpk.h>
     3.6 -
     3.7 -using namespace lemon;
     3.8 -
     3.9 -int main(){
    3.10 -
    3.11 -  //MipGlpk ilp;
    3.12 -
    3.13 -   Mip ilp;
    3.14 -
    3.15 -    
    3.16 -  typedef Mip::Row Row;
    3.17 -  typedef Mip::Col Col;
    3.18 -  
    3.19 -  ilp.max();
    3.20 -  
    3.21 -  Col x1 = ilp.addCol();
    3.22 -  Col x2 = ilp.addCol();
    3.23 -  Col x3 = ilp.addCol();
    3.24 -  
    3.25 -  ilp.integer(x1,true);
    3.26 -  ilp.integer(x2,true);
    3.27 -  ilp.integer(x3,true);
    3.28 -  
    3.29 -  ilp.addRow(x1+x2+x3 <=100);  
    3.30 -  ilp.addRow(10*x1+4*x2+5*x3<=600);  
    3.31 -  ilp.addRow(2*x1+2*x2+6*x3<=300); 
    3.32 -  
    3.33 -  ilp.colLowerBound(x1, 0);
    3.34 -  ilp.colLowerBound(x2, 0);
    3.35 -  ilp.colLowerBound(x3, 0);
    3.36 -  //Objective function
    3.37 -  ilp.setObj(10*x1+6*x2+4*x3);
    3.38 -  
    3.39 -  //Call the routine of the underlying LP solver
    3.40 -  ilp.solve();
    3.41 -  
    3.42 -  //Print results
    3.43 -  if (ilp.primalStatus()==LpSolverBase::OPTIMAL){
    3.44 -    std::cout<<"Optimal solution found!"<<std::endl;
    3.45 -    printf("optimum value = %g; x1 = %g; x2 = %g; x3 = %g\n", 
    3.46 -           ilp.primalValue(), 
    3.47 -           ilp.primal(x1), ilp.primal(x2), ilp.primal(x3));
    3.48 -  }
    3.49 -  else{
    3.50 -    std::cout<<"Optimal solution not found!"<<std::endl;
    3.51 -  }
    3.52 -
    3.53 -}