[Lemon-commits] [lemon_svn] alpar: r1834 - in hugo/trunk/src: demo lemon
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:48:04 CET 2006
Author: alpar
Date: Fri Apr 22 19:47:01 2005
New Revision: 1834
Added:
hugo/trunk/src/lemon/lp_cplex.cc
- copied, changed from r1833, /hugo_loc/work/athos/lp/lp_cplex.cc
hugo/trunk/src/lemon/lp_cplex.h
- copied, changed from r1833, /hugo_loc/work/athos/lp/lp_cplex.h
Modified:
hugo/trunk/src/demo/Makefile.am
hugo/trunk/src/demo/lp_demo.cc
hugo/trunk/src/demo/lp_maxflow_demo.cc
hugo/trunk/src/lemon/Makefile.am
hugo/trunk/src/lemon/lp_base.h
Log:
- lp_cplex.h, lp_cplex.cc added
- lp_demo.cc and lp_maxflow_demo.cc uses GLPK is it is found CPLEX otherwise
Modified: hugo/trunk/src/demo/Makefile.am
==============================================================================
--- hugo/trunk/src/demo/Makefile.am (original)
+++ hugo/trunk/src/demo/Makefile.am Fri Apr 22 19:47:01 2005
@@ -1,6 +1,17 @@
AM_CPPFLAGS = -I$(top_srcdir)/src
LDADD = $(top_builddir)/src/lemon/libemon.la
+if HAVE_GLPK
+LP_CFLAGS = $(GLPK_CFLAGS) -DHAVE_GLPK
+LP_LIBS = $(GLPK_LIBS)
+else !HAVE_GLPK
+if HAVE_CPLEX
+LP_CFLAGS = $(CPLEX_CFLAGS) -DHAVE_CPLEX
+LP_LIBS = $(CPLEX_LIBS)
+endif HAVE_CPLEX
+endif !HAVE_GLPK
+
+
EXTRA_DIST = sub_graph_wrapper_demo.dim
noinst_PROGRAMS = \
@@ -12,7 +23,12 @@
if HAVE_GLPK
noinst_PROGRAMS += lp_demo lp_maxflow_demo
-endif
+else !HAVE_GLPK
+if HAVE_CPLEX
+noinst_PROGRAMS += lp_demo lp_maxflow_demo
+endif HAVE_CPLEX
+endif !HAVE_GLPK
+
dim_to_dot_SOURCES = dim_to_dot.cc
@@ -27,9 +43,9 @@
tight_edge_filter_map.h
lp_demo_SOURCES = lp_demo.cc
-lp_demo_CXXFLAGS = $(GLPK_CFLAGS)
-lp_demo_LDFLAGS = $(GLPK_LIBS)
+lp_demo_CXXFLAGS = $(LP_CFLAGS)
+lp_demo_LDFLAGS = $(LP_LIBS)
lp_maxflow_demo_SOURCES = lp_maxflow_demo.cc
-lp_maxflow_demo_CXXFLAGS = $(GLPK_CFLAGS)
-lp_maxflow_demo_LDFLAGS = $(GLPK_LIBS)
+lp_maxflow_demo_CXXFLAGS = $(LP_CFLAGS)
+lp_maxflow_demo_LDFLAGS = $(LP_LIBS)
Modified: hugo/trunk/src/demo/lp_demo.cc
==============================================================================
--- hugo/trunk/src/demo/lp_demo.cc (original)
+++ hugo/trunk/src/demo/lp_demo.cc Fri Apr 22 19:47:01 2005
@@ -1,14 +1,27 @@
#include <iostream>
+
+
+#ifdef HAVE_GLPK
#include <lemon/lp_glpk.h>
+#elif HAVE_CPLEX
+#include <lemon/lp_cplex.h>
+#endif
+
using namespace lemon;
+#ifdef HAVE_GLPK
+typedef LpGlpk LpDefault;
+#elif HAVE_CPLEX
+typedef LpCplex LpDefault;
+#endif
+
int main()
{
//The following example is taken from the documentation of the GLPK library.
//See it in the GLPK reference manual and among the GLPK sample files (sample.c)
- LpGlpk lp;
- typedef LpGlpk::Row Row;
- typedef LpGlpk::Col Col;
+ LpDefault lp;
+ typedef LpDefault::Row Row;
+ typedef LpDefault::Col Col;
lp.max();
Modified: hugo/trunk/src/demo/lp_maxflow_demo.cc
==============================================================================
--- hugo/trunk/src/demo/lp_maxflow_demo.cc (original)
+++ hugo/trunk/src/demo/lp_maxflow_demo.cc Fri Apr 22 19:47:01 2005
@@ -1,13 +1,26 @@
-#include<lemon/lp_glpk.h>
#include<lemon/graph_reader.h>
#include<lemon/list_graph.h>
+
+#ifdef HAVE_GLPK
+#include <lemon/lp_glpk.h>
+#elif HAVE_CPLEX
+#include <lemon/lp_cplex.h>
+#endif
+
using namespace lemon;
+#ifdef HAVE_GLPK
+typedef LpGlpk LpDefault;
+#elif HAVE_CPLEX
+typedef LpCplex LpDefault;
+#endif
+
+
template<class G,class C>
double maxFlow(const G &g,const C &cap,typename G::Node s,typename G::Node t)
{
- LpGlpk lp;
+ LpDefault lp;
typedef G Graph;
typedef typename G::Node Node;
@@ -17,7 +30,7 @@
typedef typename G::OutEdgeIt OutEdgeIt;
typedef typename G::InEdgeIt InEdgeIt;
- typename G::template EdgeMap<LpGlpk::Col> x(g);
+ typename G::template EdgeMap<LpDefault::Col> x(g);
lp.addColSet(x);
for(EdgeIt e(g);e!=INVALID;++e) {
@@ -26,22 +39,23 @@
}
for(NodeIt n(g);n!=INVALID;++n) if(n!=s&&n!=t) {
- LpGlpk::Expr ex;
+ LpDefault::Expr ex;
for(InEdgeIt e(g,n);e!=INVALID;++e) ex+=x[e];
for(OutEdgeIt e(g,n);e!=INVALID;++e) ex-=x[e];
lp.addRow(ex==0);
}
{
- LpGlpk::Expr ex;
+ LpDefault::Expr ex;
for(InEdgeIt e(g,t);e!=INVALID;++e) ex+=x[e];
for(OutEdgeIt e(g,t);e!=INVALID;++e) ex-=x[e];
lp.setObj(ex);
}
lp.max();
+#ifdef HAVE_GLPK
lp.presolver(true);
-
lp.messageLevel(3);
+#endif
lp.solve();
Modified: hugo/trunk/src/lemon/Makefile.am
==============================================================================
--- hugo/trunk/src/lemon/Makefile.am (original)
+++ hugo/trunk/src/lemon/Makefile.am Fri Apr 22 19:47:01 2005
@@ -15,6 +15,12 @@
libemon_la_LDFLAGS = $(GLPK_LIBS)
endif
+if HAVE_CPLEX
+libemon_la_SOURCES += lp_cplex.cc
+libemon_la_CXXFLAGS = $(CPLEX_CFLAGS)
+libemon_la_LDFLAGS = $(CPLEX_LIBS)
+endif
+
nobase_pkginclude_HEADERS = \
bezier.h \
bfs.h \
@@ -32,6 +38,7 @@
kruskal.h \
list_graph.h \
lp_base.h \
+ lp_cplex.h \
lp_glpk.h \
lp_skeleton.h \
maps.h \
Modified: hugo/trunk/src/lemon/lp_base.h
==============================================================================
--- hugo/trunk/src/lemon/lp_base.h (original)
+++ hugo/trunk/src/lemon/lp_base.h Fri Apr 22 19:47:01 2005
@@ -464,7 +464,7 @@
///Creates a new LP problem
LpSolverBase &newLp() {return _newLp();}
- ///Make a copy of the LP problem
+ ///Makes a copy of the LP problem
LpSolverBase ©Lp() {return _copyLp();}
///\name Build up and modify of the LP
Copied: hugo/trunk/src/lemon/lp_cplex.cc (from r1833, /hugo_loc/work/athos/lp/lp_cplex.cc)
==============================================================================
--- /hugo_loc/work/athos/lp/lp_cplex.cc (original)
+++ hugo/trunk/src/lemon/lp_cplex.cc Fri Apr 22 19:47:01 2005
@@ -15,7 +15,7 @@
*
*/
-#include"lp_cplex.h"
+#include<lemon/lp_cplex.h>
///\file
///\brief Implementation of the LEMON-CPLEX lp solver interface.
Copied: hugo/trunk/src/lemon/lp_cplex.h (from r1833, /hugo_loc/work/athos/lp/lp_cplex.h)
==============================================================================
--- /hugo_loc/work/athos/lp/lp_cplex.h (original)
+++ hugo/trunk/src/lemon/lp_cplex.h Fri Apr 22 19:47:01 2005
@@ -21,6 +21,7 @@
///\brief Header of the LEMON-CPLEX lp solver interface.
#include <lemon/lp_base.h>
+
extern "C" {
#include <ilcplex/cplex.h>
}
More information about the Lemon-commits
mailing list