[Lemon-commits] Balazs Dezso: Port LP and MIP solvers from SVN -...
Lemon HG
hg at lemon.cs.elte.hu
Mon Jan 12 13:44:44 CET 2009
details: http://lemon.cs.elte.hu/hg/lemon/rev/7afc121e0689
changeset: 481:7afc121e0689
user: Balazs Dezso <deba [at] inf.elte.hu>
date: Tue Dec 02 21:40:33 2008 +0100
description:
Port LP and MIP solvers from SVN -r3509 (#44)
diffstat:
24 files changed, 5409 insertions(+), 9 deletions(-)
configure.ac | 14
lemon/CMakeLists.txt | 3
lemon/Makefile.am | 35 -
lemon/bits/lp_id.h | 157 ++++
lemon/config.h.in | 3
lemon/lp.h | 90 ++
lemon/lp_base.cc | 35 +
lemon/lp_base.h | 1705 ++++++++++++++++++++++++++++++++++++++++++++++++++
lemon/lp_cplex.cc | 699 ++++++++++++++++++++
lemon/lp_cplex.h | 113 +++
lemon/lp_glpk.cc | 644 ++++++++++++++++++
lemon/lp_glpk.h | 139 ++++
lemon/lp_skeleton.cc | 187 +++++
lemon/lp_skeleton.h | 183 +++++
lemon/lp_soplex.cc | 316 +++++++++
lemon/lp_soplex.h | 120 +++
lemon/mip_cplex.cc | 141 ++++
lemon/mip_cplex.h | 61 +
lemon/mip_glpk.cc | 154 ++++
lemon/mip_glpk.h | 59 +
test/CMakeLists.txt | 2
test/Makefile.am | 9
test/lp_test.cc | 423 ++++++++++++
test/mip_test.cc | 126 +++
diffs (truncated from 5597 to 300 lines):
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -50,9 +50,9 @@
AC_SUBST([WARNINGCXXFLAGS])
dnl Checks for libraries.
-#LX_CHECK_GLPK
-#LX_CHECK_CPLEX
-#LX_CHECK_SOPLEX
+LX_CHECK_GLPK
+LX_CHECK_CPLEX
+LX_CHECK_SOPLEX
AM_CONDITIONAL([HAVE_LP], [test x"$lx_lp_found" = x"yes"])
AM_CONDITIONAL([HAVE_MIP], [test x"$lx_mip_found" = x"yes"])
@@ -117,10 +117,10 @@
echo C++ compiler.................. : $CXX
echo C++ compiles flags............ : $WARNINGCXXFLAGS $CXXFLAGS
echo
-#echo GLPK support.................. : $lx_glpk_found
-#echo CPLEX support................. : $lx_cplex_found
-#echo SOPLEX support................ : $lx_soplex_found
-#echo
+echo GLPK support.................. : $lx_glpk_found
+echo CPLEX support................. : $lx_cplex_found
+echo SOPLEX support................ : $lx_soplex_found
+echo
echo Build demo programs........... : $enable_demo
echo Build additional tools........ : $enable_tools
echo
diff --git a/lemon/CMakeLists.txt b/lemon/CMakeLists.txt
--- a/lemon/CMakeLists.txt
+++ b/lemon/CMakeLists.txt
@@ -4,6 +4,9 @@
arg_parser.cc
base.cc
color.cc
+ lp_base.cc
+ lp_skeleton.cc
+ lp_utils.cc
random.cc)
INSTALL(
diff --git a/lemon/Makefile.am b/lemon/Makefile.am
--- a/lemon/Makefile.am
+++ b/lemon/Makefile.am
@@ -10,10 +10,32 @@
lemon/arg_parser.cc \
lemon/base.cc \
lemon/color.cc \
+ lemon/lp_base.cc \
+ lemon/lp_skeleton.cc \
lemon/random.cc
-#lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS) $(AM_CXXFLAGS)
-#lemon_libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS) $(SOPLEX_LIBS)
+
+lemon_libemon_la_CXXFLAGS = \
+ $(GLPK_CFLAGS) \
+ $(CPLEX_CFLAGS) \
+ $(SOPLEX_CXXFLAGS)
+
+lemon_libemon_la_LDFLAGS = \
+ $(GLPK_LIBS) \
+ $(CPLEX_LIBS) \
+ $(SOPLEX_LIBS)
+
+if HAVE_GLPK
+lemon_libemon_la_SOURCES += lemon/lp_glpk.cc lemon/mip_glpk.cc
+endif
+
+if HAVE_CPLEX
+lemon_libemon_la_SOURCES += lemon/lp_cplex.cc lemon/mip_cplex.cc
+endif
+
+if HAVE_SOPLEX
+lemon_libemon_la_SOURCES += lemon/lp_soplex.cc
+endif
lemon_HEADERS += \
lemon/adaptors.h \
@@ -41,6 +63,14 @@
lemon/lgf_reader.h \
lemon/lgf_writer.h \
lemon/list_graph.h \
+ lemon/lp.h \
+ lemon/lp_base.h \
+ lemon/lp_cplex.h \
+ lemon/lp_glpk.h \
+ lemon/lp_skeleton.h \
+ lemon/lp_soplex.h \
+ lemon/mip_cplex.h \
+ lemon/mip_glpk.h \
lemon/maps.h \
lemon/math.h \
lemon/max_matching.h \
@@ -64,6 +94,7 @@
lemon/bits/enable_if.h \
lemon/bits/graph_adaptor_extender.h \
lemon/bits/graph_extender.h \
+ lemon/bits/lp_id.h \
lemon/bits/map_extender.h \
lemon/bits/path_dump.h \
lemon/bits/traits.h \
diff --git a/lemon/bits/lp_id.h b/lemon/bits/lp_id.h
new file mode 100644
--- /dev/null
+++ b/lemon/bits/lp_id.h
@@ -0,0 +1,157 @@
+/* -*- mode: C++; indent-tabs-mode: nil; -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library.
+ *
+ * Copyright (C) 2003-2008
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#ifndef LEMON_BITS_LP_SOLVER_ID_H
+#define LEMON_BITS_LP_SOLVER_ID_H
+
+namespace lemon {
+
+ namespace _lp_bits {
+
+ struct LpIdImpl {
+ std::vector<int> index;
+ std::vector<int> cross;
+ int first_index;
+ int first_free;
+ };
+
+ class LpId {
+ public:
+
+ class IdHandler {
+ public:
+ virtual ~IdHandler() {}
+ virtual int addId(LpIdImpl&) = 0;
+ virtual void eraseId(LpIdImpl&, int xn) = 0;
+ };
+
+ LpId(int min_index = 0) {
+ id_handler = 0;
+ impl.first_free = -1;
+ impl.first_index = min_index;
+ impl.cross.resize(impl.first_index);
+ }
+
+ LpId(const LpId& li) {
+ id_handler = 0;
+ impl = li.impl;
+ }
+
+ LpId& operator=(const LpId& li) {
+ id_handler = 0;
+ impl = li.impl;
+ return *this;
+ }
+
+ void setIdHandler(IdHandler& ih) {
+ id_handler = &ih;
+ }
+
+ int fixId(int fn) const {return impl.cross[fn];}
+ int floatingId(int xn) const {return impl.index[xn];}
+
+ int addId() {
+ if (id_handler == 0) {
+ int xn, fn = impl.cross.size();
+ if (impl.first_free == -1) {
+ xn = impl.index.size();
+ impl.index.push_back(fn);
+ } else {
+ xn = impl.first_free;
+ impl.first_free = impl.index[impl.first_free];
+ impl.index[xn] = fn;
+ }
+ impl.cross.push_back(xn);
+ return xn;
+ } else {
+ return id_handler->addId(impl);
+ }
+ }
+
+ void eraseId(int xn) {
+ if (id_handler == 0) {
+ int fn = impl.index[xn];
+ impl.index[xn] = impl.first_free;
+ impl.first_free = xn;
+ for(int i = fn + 1; i < int(impl.cross.size()); ++i) {
+ impl.cross[i - 1] = impl.cross[i];
+ impl.index[impl.cross[i]]--;
+ }
+ impl.cross.pop_back();
+ } else {
+ id_handler->eraseId(impl, xn);
+ }
+ }
+
+ void firstFloating(int& fn) const {
+ fn = impl.first_index;
+ if (fn == int(impl.cross.size())) fn = -1;
+ }
+
+ void nextFloating(int& fn) const {
+ ++fn;
+ if (fn == int(impl.cross.size())) fn = -1;
+ }
+
+ void firstFix(int& xn) const {
+ int fn;
+ firstFloating(fn);
+ xn = fn != -1 ? fixId(fn) : -1;
+ }
+
+ void nextFix(int& xn) const {
+ int fn = floatingId(xn);
+ nextFloating(fn);
+ xn = fn != -1 ? fixId(fn) : -1;
+ }
+
+ protected:
+ LpIdImpl impl;
+ IdHandler *id_handler;
+ };
+
+ class RelocateIdHandler : public LpId::IdHandler {
+ public:
+
+ virtual int addId(LpIdImpl& impl) {
+ int xn, fn = impl.cross.size();
+ if (impl.first_free == -1) {
+ xn = impl.index.size();
+ impl.index.push_back(fn);
+ } else {
+ xn = impl.first_free;
+ impl.first_free = impl.index[impl.first_free];
+ impl.index[xn] = fn;
+ }
+ impl.cross.push_back(xn);
+ return xn;
+ }
+
+ virtual void eraseId(LpIdImpl& impl, int xn) {
+ int fn = impl.index[xn];
+ impl.index[xn] = impl.first_free;
+ impl.first_free = xn;
+ impl.cross[fn] = impl.cross.back();
+ impl.index[impl.cross.back()] = fn;
+ impl.cross.pop_back();
+ }
+ };
+ }
+}
+
+#endif
diff --git a/lemon/config.h.in b/lemon/config.h.in
--- a/lemon/config.h.in
+++ b/lemon/config.h.in
@@ -9,3 +9,6 @@
/* Define to 1 if you have GLPK. */
#undef HAVE_GLPK
+
+/* Define to 1 if you have SOPLEX */
+#undef HAVE_SOPLEX
\ No newline at end of file
diff --git a/lemon/lp.h b/lemon/lp.h
new file mode 100644
--- /dev/null
+++ b/lemon/lp.h
@@ -0,0 +1,90 @@
+/* -*- mode: C++; indent-tabs-mode: nil; -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library.
+ *
+ * Copyright (C) 2003-2008
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
More information about the Lemon-commits
mailing list