[Lemon-commits] Balazs Dezso: Thorough redesign of the LP/MIP in...

Lemon HG hg at lemon.cs.elte.hu
Mon Jan 12 13:44:45 CET 2009


details:   http://lemon.cs.elte.hu/hg/lemon/rev/ed54c0d13df0
changeset: 482:ed54c0d13df0
user:      Balazs Dezso <deba [at] inf.elte.hu>
date:      Tue Dec 02 22:48:28 2008 +0100
description:
	Thorough redesign of the LP/MIP interface (#44)

	 - Redesigned class structure
	 - Redesigned iterators
	 - Some functions in the basic interface redesigned
	 - More complete setting functions
	 - Ray retrieving functions
	 - Lot of improvements
	 - Cplex common env
	 - CLP macro definition to config.h.in
	 - Update lp.h to also use soplex and clp
	 - Remove default_solver_name
	 - New solverName() function in solvers
	 - Handle exceptions for MipCplex test
	 - Rename tolerance parameter to epsilon
	 - Rename MapIt to CoeffIt
	 - Lot of documentation improvements
	 - Various bugfixes

diffstat:

27 files changed, 4579 insertions(+), 2969 deletions(-)
configure.ac             |    2 
lemon/CMakeLists.txt     |    3 
lemon/Makefile.am        |   20 
lemon/bits/lp_id.h       |  157 ---
lemon/bits/solver_bits.h |  191 ++++
lemon/config.h.in        |    5 
lemon/lp.h               |   41 
lemon/lp_base.cc         |   11 
lemon/lp_base.h          | 2083 +++++++++++++++++++++++++++-------------------
lemon/lp_clp.cc          |  437 +++++++++
lemon/lp_clp.h           |  179 +++
lemon/lp_cplex.cc        | 1170 +++++++++++++++----------
lemon/lp_cplex.h         |  219 +++-
lemon/lp_glpk.cc         | 1254 +++++++++++++++++----------
lemon/lp_glpk.h          |  232 +++--
lemon/lp_skeleton.cc     |  217 +---
lemon/lp_skeleton.h      |  170 ++-
lemon/lp_soplex.cc       |  307 ++++--
lemon/lp_soplex.h        |   91 +-
lemon/mip_cplex.cc       |  141 ---
lemon/mip_cplex.h        |   61 -
lemon/mip_glpk.cc        |  154 ---
lemon/mip_glpk.h         |   59 -
m4/lx_check_clp.m4       |   73 +
m4/lx_check_glpk.m4      |    5 
test/lp_test.cc          |  214 ++--
test/mip_test.cc         |   52 -

diffs (truncated from 9417 to 300 lines):

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -53,6 +53,7 @@
 LX_CHECK_GLPK
 LX_CHECK_CPLEX
 LX_CHECK_SOPLEX
+LX_CHECK_CLP
 
 AM_CONDITIONAL([HAVE_LP], [test x"$lx_lp_found" = x"yes"])
 AM_CONDITIONAL([HAVE_MIP], [test x"$lx_mip_found" = x"yes"])
@@ -120,6 +121,7 @@
 echo GLPK support.................. : $lx_glpk_found
 echo CPLEX support................. : $lx_cplex_found
 echo SOPLEX support................ : $lx_soplex_found
+echo CLP support................... : $lx_clp_found
 echo
 echo Build demo programs........... : $enable_demo
 echo Build additional tools........ : $enable_tools
diff --git a/lemon/CMakeLists.txt b/lemon/CMakeLists.txt
--- a/lemon/CMakeLists.txt
+++ b/lemon/CMakeLists.txt
@@ -4,9 +4,6 @@
   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
@@ -18,25 +18,31 @@
 lemon_libemon_la_CXXFLAGS = \
 	$(GLPK_CFLAGS) \
 	$(CPLEX_CFLAGS) \
-	$(SOPLEX_CXXFLAGS)
+	$(SOPLEX_CXXFLAGS) \
+	$(CLP_CXXFLAGS)
 
 lemon_libemon_la_LDFLAGS = \
 	$(GLPK_LIBS) \
 	$(CPLEX_LIBS) \
-	$(SOPLEX_LIBS)
+	$(SOPLEX_LIBS) \
+	$(CLP_LIBS)
 
 if HAVE_GLPK
-lemon_libemon_la_SOURCES += lemon/lp_glpk.cc lemon/mip_glpk.cc
+lemon_libemon_la_SOURCES += lemon/lp_glpk.cc
 endif
 
 if HAVE_CPLEX
-lemon_libemon_la_SOURCES += lemon/lp_cplex.cc lemon/mip_cplex.cc
+lemon_libemon_la_SOURCES += lemon/lp_cplex.cc
 endif
 
 if HAVE_SOPLEX
 lemon_libemon_la_SOURCES += lemon/lp_soplex.cc
 endif
 
+if HAVE_CLP
+lemon_libemon_la_SOURCES += lemon/lp_clp.cc
+endif
+
 lemon_HEADERS += \
 	lemon/adaptors.h \
 	lemon/arg_parser.h \
@@ -65,12 +71,12 @@
 	lemon/list_graph.h \
 	lemon/lp.h \
 	lemon/lp_base.h \
+	lemon/lp_clp.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/list_graph.h \
 	lemon/maps.h \
 	lemon/math.h \
 	lemon/max_matching.h \
@@ -94,9 +100,9 @@
 	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/solver_bits.h \
 	lemon/bits/traits.h \
 	lemon/bits/variant.h \
 	lemon/bits/vector_map.h
diff --git a/lemon/bits/lp_id.h b/lemon/bits/lp_id.h
deleted file mode 100644
--- a/lemon/bits/lp_id.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/* -*- 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/bits/solver_bits.h b/lemon/bits/solver_bits.h
new file mode 100644
--- /dev/null
+++ b/lemon/bits/solver_bits.h
@@ -0,0 +1,191 @@
+/* -*- 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_SOLVER_BITS_H
+#define LEMON_BITS_SOLVER_BITS_H
+
+namespace lemon {
+
+  namespace _solver_bits {
+
+    class VarIndex {
+    private:
+      struct ItemT {
+        int prev, next;
+        int index;
+      };
+      std::vector<ItemT> items;
+      int first_item, last_item, first_free_item;
+
+      std::vector<int> cross;
+



More information about the Lemon-commits mailing list