COIN-OR::LEMON - Graph Library

Changeset 1610:893dacc1866c in lemon-0.x for demo/lp_maxflow_demo.cc


Ignore:
Timestamp:
08/01/05 23:16:08 (14 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2116
Message:

A default LP solver is defined in lp.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • demo/lp_maxflow_demo.cc

    r1583 r1610  
    2424/// constraints that arise in graph theory in our library LEMON .
    2525
    26 #ifdef HAVE_CONFIG_H
    27 #include <config.h>
    28 #endif
    29 
    3026#include<lemon/graph_reader.h>
    3127#include<lemon/list_graph.h>
     28#include <lemon/lp.h>
    3229
    3330#include <fstream>
     
    3532
    3633
    37 #ifdef HAVE_GLPK
    38 #include <lemon/lp_glpk.h>
    39 #elif HAVE_CPLEX
    40 #include <lemon/lp_cplex.h>
    41 #endif
    4234
    4335using namespace lemon;
    44 
    45 #ifdef HAVE_GLPK
    46 typedef LpGlpk LpDefault;
    47 const char default_solver_name[]="GLPK";
    48 #elif HAVE_CPLEX
    49 typedef LpCplex LpDefault;
    50 const char default_solver_name[]="CPLEX";
    51 #endif
    52 
    5336
    5437template<class G,class C>
    5538double maxFlow(const G &g,const C &cap,typename G::Node s,typename G::Node t)
    5639{
    57   LpDefault lp;
     40  Lp lp;
    5841 
    5942  typedef G Graph;
     
    6649 
    6750  //Define a map on the edges for the variables of the LP problem
    68   typename G::template EdgeMap<LpDefault::Col> x(g);
     51  typename G::template EdgeMap<Lp::Col> x(g);
    6952  lp.addColSet(x);
    7053 
     
    7861  //Flow conservation constraints for the nodes (except for 's' and 't')
    7962  for(NodeIt n(g);n!=INVALID;++n) if(n!=s&&n!=t) {
    80     LpDefault::Expr ex;
     63    Lp::Expr ex;
    8164    for(InEdgeIt  e(g,n);e!=INVALID;++e) ex+=x[e];
    8265    for(OutEdgeIt e(g,n);e!=INVALID;++e) ex-=x[e];
     
    8568 
    8669  //Objective function: the flow value entering 't'
    87   LpDefault::Expr obj;
     70  Lp::Expr obj;
    8871  for(InEdgeIt  e(g,t);e!=INVALID;++e) obj+=x[e];
    8972  for(OutEdgeIt e(g,t);e!=INVALID;++e) obj-=x[e];
     
    9477  lp.max();
    9578
    96 #ifdef HAVE_GLPK
     79#if DEFAULT_LP==GLPK
    9780  lp.presolver(true);
    9881  lp.messageLevel(3);
Note: See TracChangeset for help on using the changeset viewer.