Changeset 1610:893dacc1866c in lemon-0.x for demo/lp_maxflow_demo.cc
- Timestamp:
- 08/01/05 23:16:08 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2116
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
demo/lp_maxflow_demo.cc
r1583 r1610 24 24 /// constraints that arise in graph theory in our library LEMON . 25 25 26 #ifdef HAVE_CONFIG_H27 #include <config.h>28 #endif29 30 26 #include<lemon/graph_reader.h> 31 27 #include<lemon/list_graph.h> 28 #include <lemon/lp.h> 32 29 33 30 #include <fstream> … … 35 32 36 33 37 #ifdef HAVE_GLPK38 #include <lemon/lp_glpk.h>39 #elif HAVE_CPLEX40 #include <lemon/lp_cplex.h>41 #endif42 34 43 35 using namespace lemon; 44 45 #ifdef HAVE_GLPK46 typedef LpGlpk LpDefault;47 const char default_solver_name[]="GLPK";48 #elif HAVE_CPLEX49 typedef LpCplex LpDefault;50 const char default_solver_name[]="CPLEX";51 #endif52 53 36 54 37 template<class G,class C> 55 38 double maxFlow(const G &g,const C &cap,typename G::Node s,typename G::Node t) 56 39 { 57 Lp Defaultlp;40 Lp lp; 58 41 59 42 typedef G Graph; … … 66 49 67 50 //Define a map on the edges for the variables of the LP problem 68 typename G::template EdgeMap<Lp Default::Col> x(g);51 typename G::template EdgeMap<Lp::Col> x(g); 69 52 lp.addColSet(x); 70 53 … … 78 61 //Flow conservation constraints for the nodes (except for 's' and 't') 79 62 for(NodeIt n(g);n!=INVALID;++n) if(n!=s&&n!=t) { 80 Lp Default::Expr ex;63 Lp::Expr ex; 81 64 for(InEdgeIt e(g,n);e!=INVALID;++e) ex+=x[e]; 82 65 for(OutEdgeIt e(g,n);e!=INVALID;++e) ex-=x[e]; … … 85 68 86 69 //Objective function: the flow value entering 't' 87 Lp Default::Expr obj;70 Lp::Expr obj; 88 71 for(InEdgeIt e(g,t);e!=INVALID;++e) obj+=x[e]; 89 72 for(OutEdgeIt e(g,t);e!=INVALID;++e) obj-=x[e]; … … 94 77 lp.max(); 95 78 96 #if def HAVE_GLPK79 #if DEFAULT_LP==GLPK 97 80 lp.presolver(true); 98 81 lp.messageLevel(3);
Note: See TracChangeset
for help on using the changeset viewer.