demo/lp_maxflow_demo.cc
changeset 1579 ed7da82bbecf
parent 1571 68ce4302fb0b
child 1583 2b329fd595ef
equal deleted inserted replaced
4:58d0d0fe966a 5:a4b3962b8af6
    42 
    42 
    43 using namespace lemon;
    43 using namespace lemon;
    44 
    44 
    45 #ifdef HAVE_GLPK
    45 #ifdef HAVE_GLPK
    46 typedef LpGlpk LpDefault;
    46 typedef LpGlpk LpDefault;
       
    47 const char default_solver_name[]="GLPK";
    47 #elif HAVE_CPLEX
    48 #elif HAVE_CPLEX
    48 typedef LpCplex LpDefault;
    49 typedef LpCplex LpDefault;
       
    50 const char default_solver_name[]="CPLEX";
    49 #endif
    51 #endif
    50 
    52 
    51 
    53 
    52 template<class G,class C>
    54 template<class G,class C>
    53 double maxFlow(const G &g,const C &cap,typename G::Node s,typename G::Node t)
    55 double maxFlow(const G &g,const C &cap,typename G::Node s,typename G::Node t)
    94 #ifdef HAVE_GLPK
    96 #ifdef HAVE_GLPK
    95   lp.presolver(true);
    97   lp.presolver(true);
    96   lp.messageLevel(3);
    98   lp.messageLevel(3);
    97 #endif
    99 #endif
    98 
   100 
       
   101   std::cout<<"Solver used: "<<default_solver_name<<std::endl;
       
   102 
    99   //Solve with the underlying solver
   103   //Solve with the underlying solver
   100   lp.solve();
   104   lp.solve();
   101 
   105 
   102   return lp.primalValue();
   106   return lp.primalValue();
   103 }
   107 }
   104 
   108 
   105 int main(int argc, char *argv[]) 
   109 int main(int argc, char *argv[]) 
   106 {
   110 {
   107   if(argc<2)
   111   if(argc<2)
   108   {
   112   {
   109       std::cerr << "  USAGE: lp_maxflow_demo <input_file.lgf>" << std::endl;
   113       std::cerr << "  USAGE: lp_maxflow_demo input_file.lgf" << std::endl;
   110       std::cerr << "  The file 'input_file.lgf' has to contain a max "
   114       std::cerr << "  The file 'input_file.lgf' has to contain a max "
   111 		<< "flow instance in\n"
   115 		<< "flow instance in\n"
   112 		<< "  LEMON format (e.g. sample.lgf is such a file)."
   116 		<< "  LEMON format (e.g. sample.lgf is such a file)."
   113 		<< std::endl;
   117 		<< std::endl;
   114       return 0;
   118       return 0;