lemon-project-template-glpk

changeset 11:4fc6ad2fb8a6 tip

Test GLPK in src/main.cc
author Alpar Juttner <alpar@cs.elte.hu>
date Sun, 06 Nov 2011 21:43:29 +0100
parents 5545663ca997
children
files src/CMakeLists.txt src/main.cc
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/src/CMakeLists.txt	Sun Nov 06 21:42:23 2011 +0100
     1.2 +++ b/src/CMakeLists.txt	Sun Nov 06 21:43:29 2011 +0100
     1.3 @@ -19,7 +19,7 @@
     1.4  ## by whitespaces.
     1.5  
     1.6  TARGET_LINK_LIBRARIES(lemon-project
     1.7 -  ${LEMON_LIBRARIES}
     1.8 +  ${LEMON_LIBRARIES} glpk
     1.9  )
    1.10  
    1.11  INSTALL(
     2.1 --- a/src/main.cc	Sun Nov 06 21:42:23 2011 +0100
     2.2 +++ b/src/main.cc	Sun Nov 06 21:43:29 2011 +0100
     2.3 @@ -16,11 +16,29 @@
     2.4   *
     2.5   */
     2.6  
     2.7 +#include<lemon/arg_parser.h>
     2.8  #include<lemon/list_graph.h>
     2.9 +#include<lemon/glpk.h>
    2.10  
    2.11  ///The main entry point
    2.12 -int main()
    2.13 +int main(int argc, char **argv)
    2.14  {
    2.15 +
    2.16 +  lemon::ArgParser ap(argc,argv);
    2.17 +  ap.run();
    2.18 +
    2.19    lemon::ListGraph g;
    2.20    g.addNode();
    2.21 +  
    2.22 +  typedef lemon::GlpkLp Solver;
    2.23 +  Solver lp;
    2.24 +  Solver::Col x = lp.addCol();
    2.25 +  Solver::Col y = lp.addCol();
    2.26 +  lp.colLowerBound(x,0);
    2.27 +  lp.colLowerBound(y,0);
    2.28 +  lp.addRow(3<=x+2*y<=10);
    2.29 +  lp.obj(-4*x+3*y);
    2.30 +  lp.max();
    2.31 +  lp.solve();
    2.32 +
    2.33  }