demo/lp_demo.cc
changeset 1619 f0700b9e6418
parent 1577 15098fb5275c
child 1636 260ac104190f
equal deleted inserted replaced
3:19ffa0923f6f 4:ebbf6db55b6b
    22 /// interface: we formulate a linear programming (LP) problem and then
    22 /// interface: we formulate a linear programming (LP) problem and then
    23 /// solve it using the underlying solver (GLPK or CPLEX for
    23 /// solve it using the underlying solver (GLPK or CPLEX for
    24 /// example). For the detailed documentation of the LEMON LP solver
    24 /// example). For the detailed documentation of the LEMON LP solver
    25 /// interface read \ref lemon::LpSolverBase "this".
    25 /// interface read \ref lemon::LpSolverBase "this".
    26 
    26 
    27 #ifdef HAVE_CONFIG_H
    27 #include <lemon/lp.h>
    28 #include <config.h>
       
    29 #endif
       
    30 
    28 
    31 #include <iostream>
    29 #include <iostream>
    32 
    30 
    33 
       
    34 #ifdef HAVE_GLPK
       
    35 #include <lemon/lp_glpk.h>
       
    36 #elif HAVE_CPLEX
       
    37 #include <lemon/lp_cplex.h>
       
    38 #endif
       
    39 
       
    40 using namespace lemon;
    31 using namespace lemon;
    41 
       
    42 
       
    43 
       
    44 #ifdef HAVE_GLPK
       
    45 typedef LpGlpk LpDefault;
       
    46 const char default_solver_name[]="GLPK";
       
    47 #elif HAVE_CPLEX
       
    48 typedef LpCplex LpDefault;
       
    49 const char default_solver_name[]="CPLEX";
       
    50 #endif
       
    51 
    32 
    52 int main()
    33 int main()
    53 {     
    34 {     
    54  //The following example is taken from the documentation of the GLPK library.
    35  //The following example is taken from the documentation of the GLPK library.
    55  //See it in the GLPK reference manual and among the GLPK sample files (sample.c)
    36  //See it in the GLPK reference manual and among the GLPK sample files (sample.c)
    56 
    37 
    57   //A default solver is taken
    38   //A default solver is taken
    58   LpDefault lp;
    39   Lp lp;
    59   typedef LpDefault::Row Row;
    40   typedef Lp::Row Row;
    60   typedef LpDefault::Col Col;
    41   typedef Lp::Col Col;
    61   
    42   
    62 
    43 
    63   std::cout<<"A program demonstrating the LEMON LP solver interface"<<std::endl; 
    44   std::cout<<"A program demonstrating the LEMON LP solver interface"<<std::endl; 
    64   std::cout<<"Solver used: "<<default_solver_name<<std::endl;
    45   std::cout<<"Solver used: "<<default_solver_name<<std::endl;
    65 
    46