COIN-OR::LEMON - Graph Library

Changeset 1381:998e8def9676 in lemon-0.x for src/demo/lp_maxflow_demo.cc


Ignore:
Timestamp:
04/22/05 19:47:01 (16 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1834
Message:
  • lp_cplex.h, lp_cplex.cc added
  • lp_demo.cc and lp_maxflow_demo.cc uses GLPK is it is found CPLEX otherwise
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/demo/lp_maxflow_demo.cc

    r1361 r1381  
    1 #include<lemon/lp_glpk.h>
    21#include<lemon/graph_reader.h>
    32#include<lemon/list_graph.h>
    43
     4
     5#ifdef HAVE_GLPK
     6#include <lemon/lp_glpk.h>
     7#elif HAVE_CPLEX
     8#include <lemon/lp_cplex.h>
     9#endif
     10
    511using namespace lemon;
     12
     13#ifdef HAVE_GLPK
     14typedef LpGlpk LpDefault;
     15#elif HAVE_CPLEX
     16typedef LpCplex LpDefault;
     17#endif
     18
    619
    720template<class G,class C>
    821double maxFlow(const G &g,const C &cap,typename G::Node s,typename G::Node t)
    922{
    10   LpGlpk lp;
     23  LpDefault lp;
    1124 
    1225  typedef G Graph;
     
    1831  typedef typename G::InEdgeIt InEdgeIt;
    1932 
    20   typename G::template EdgeMap<LpGlpk::Col> x(g);
     33  typename G::template EdgeMap<LpDefault::Col> x(g);
    2134  lp.addColSet(x);
    2235 
     
    2740
    2841  for(NodeIt n(g);n!=INVALID;++n) if(n!=s&&n!=t) {
    29     LpGlpk::Expr ex;
     42    LpDefault::Expr ex;
    3043    for(InEdgeIt  e(g,n);e!=INVALID;++e) ex+=x[e];
    3144    for(OutEdgeIt e(g,n);e!=INVALID;++e) ex-=x[e];
     
    3346  }
    3447  {
    35     LpGlpk::Expr ex;
     48    LpDefault::Expr ex;
    3649    for(InEdgeIt  e(g,t);e!=INVALID;++e) ex+=x[e];
    3750    for(OutEdgeIt e(g,t);e!=INVALID;++e) ex-=x[e];
     
    4053  lp.max();
    4154
     55#ifdef HAVE_GLPK
    4256  lp.presolver(true);
    43  
    4457  lp.messageLevel(3);
     58#endif
    4559
    4660  lp.solve();
Note: See TracChangeset for help on using the changeset viewer.