COIN-OR::LEMON - Graph Library

Changeset 1381:998e8def9676 in lemon-0.x


Ignore:
Timestamp:
04/22/05 19:47:01 (19 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
Location:
src
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • src/demo/Makefile.am

    r1362 r1381  
    11AM_CPPFLAGS = -I$(top_srcdir)/src
    22LDADD = $(top_builddir)/src/lemon/libemon.la
     3
     4if HAVE_GLPK
     5LP_CFLAGS = $(GLPK_CFLAGS) -DHAVE_GLPK
     6LP_LIBS = $(GLPK_LIBS)
     7else !HAVE_GLPK
     8if HAVE_CPLEX
     9LP_CFLAGS = $(CPLEX_CFLAGS) -DHAVE_CPLEX
     10LP_LIBS = $(CPLEX_LIBS)
     11endif HAVE_CPLEX
     12endif !HAVE_GLPK
     13
    314
    415EXTRA_DIST = sub_graph_wrapper_demo.dim
     
    1324if HAVE_GLPK
    1425noinst_PROGRAMS += lp_demo lp_maxflow_demo
    15 endif
     26else !HAVE_GLPK
     27if HAVE_CPLEX
     28noinst_PROGRAMS += lp_demo lp_maxflow_demo
     29endif HAVE_CPLEX
     30endif !HAVE_GLPK
     31
    1632
    1733dim_to_dot_SOURCES = dim_to_dot.cc
     
    2844
    2945lp_demo_SOURCES = lp_demo.cc
    30 lp_demo_CXXFLAGS = $(GLPK_CFLAGS)
    31 lp_demo_LDFLAGS = $(GLPK_LIBS)
     46lp_demo_CXXFLAGS = $(LP_CFLAGS)
     47lp_demo_LDFLAGS = $(LP_LIBS)
    3248
    3349lp_maxflow_demo_SOURCES = lp_maxflow_demo.cc
    34 lp_maxflow_demo_CXXFLAGS = $(GLPK_CFLAGS)
    35 lp_maxflow_demo_LDFLAGS = $(GLPK_LIBS)
     50lp_maxflow_demo_CXXFLAGS = $(LP_CFLAGS)
     51lp_maxflow_demo_LDFLAGS = $(LP_LIBS)
  • src/demo/lp_demo.cc

    r1362 r1381  
    11#include <iostream>
     2
     3
     4#ifdef HAVE_GLPK
    25#include <lemon/lp_glpk.h>
     6#elif HAVE_CPLEX
     7#include <lemon/lp_cplex.h>
     8#endif
     9
    310using namespace lemon;
     11
     12#ifdef HAVE_GLPK
     13typedef LpGlpk LpDefault;
     14#elif HAVE_CPLEX
     15typedef LpCplex LpDefault;
     16#endif
    417
    518int main()
     
    720 //The following example is taken from the documentation of the GLPK library.
    821 //See it in the GLPK reference manual and among the GLPK sample files (sample.c)
    9   LpGlpk lp;
    10   typedef LpGlpk::Row Row;
    11   typedef LpGlpk::Col Col;
     22  LpDefault lp;
     23  typedef LpDefault::Row Row;
     24  typedef LpDefault::Col Col;
    1225
    1326  lp.max();
  • 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();
  • src/lemon/Makefile.am

    r1378 r1381  
    1414libemon_la_CXXFLAGS = $(GLPK_CFLAGS)
    1515libemon_la_LDFLAGS = $(GLPK_LIBS)
     16endif
     17
     18if HAVE_CPLEX
     19libemon_la_SOURCES += lp_cplex.cc
     20libemon_la_CXXFLAGS = $(CPLEX_CFLAGS)
     21libemon_la_LDFLAGS = $(CPLEX_LIBS)
    1622endif
    1723
     
    3339        list_graph.h \
    3440        lp_base.h \
     41        lp_cplex.h \
    3542        lp_glpk.h \
    3643        lp_skeleton.h \
  • src/lemon/lp_base.h

    r1379 r1381  
    465465    ///Creates a new LP problem
    466466    LpSolverBase &newLp() {return _newLp();}
    467     ///Make a copy of the LP problem
     467    ///Makes a copy of the LP problem
    468468    LpSolverBase &copyLp() {return _copyLp();}
    469469   
Note: See TracChangeset for help on using the changeset viewer.