[Lemon-commits] Alpar Juttner: Remove lp_ prefix from the solver...

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/08d495d48089
changeset: 484:08d495d48089
user:      Alpar Juttner <alpar [at] cs.elte.hu>
date:      Mon Jan 12 12:26:01 2009 +0000
description:
	Remove lp_ prefix from the solver's header name

diffstat:

20 files changed, 3609 insertions(+), 3609 deletions(-)
lemon/Makefile.am  |   16 
lemon/clp.cc       |  437 +++++++++++++++++++++++
lemon/clp.h        |  179 +++++++++
lemon/cplex.cc     |  925 ++++++++++++++++++++++++++++++++++++++++++++++++++
lemon/cplex.h      |  256 +++++++++++++
lemon/glpk.cc      |  952 ++++++++++++++++++++++++++++++++++++++++++++++++++++
lemon/glpk.h       |  259 ++++++++++++++
lemon/lp.h         |   26 -
lemon/lp_clp.cc    |  437 -----------------------
lemon/lp_clp.h     |  179 ---------
lemon/lp_cplex.cc  |  925 --------------------------------------------------
lemon/lp_cplex.h   |  256 -------------
lemon/lp_glpk.cc   |  952 ----------------------------------------------------
lemon/lp_glpk.h    |  259 --------------
lemon/lp_soplex.cc |  423 -----------------------
lemon/lp_soplex.h  |  151 --------
lemon/soplex.cc    |  423 +++++++++++++++++++++++
lemon/soplex.h     |  151 ++++++++
test/lp_test.cc    |    8 
test/mip_test.cc   |    4 

diffs (truncated from 7424 to 300 lines):

diff --git a/lemon/Makefile.am b/lemon/Makefile.am
--- a/lemon/Makefile.am
+++ b/lemon/Makefile.am
@@ -28,19 +28,19 @@
 	$(CLP_LIBS)
 
 if HAVE_GLPK
-lemon_libemon_la_SOURCES += lemon/lp_glpk.cc
+lemon_libemon_la_SOURCES += lemon/glpk.cc
 endif
 
 if HAVE_CPLEX
-lemon_libemon_la_SOURCES += lemon/lp_cplex.cc
+lemon_libemon_la_SOURCES += lemon/cplex.cc
 endif
 
 if HAVE_SOPLEX
-lemon_libemon_la_SOURCES += lemon/lp_soplex.cc
+lemon_libemon_la_SOURCES += lemon/soplex.cc
 endif
 
 if HAVE_CLP
-lemon_libemon_la_SOURCES += lemon/lp_clp.cc
+lemon_libemon_la_SOURCES += lemon/clp.cc
 endif
 
 lemon_HEADERS += \
@@ -50,10 +50,12 @@
 	lemon/bfs.h \
 	lemon/bin_heap.h \
 	lemon/circulation.h \
+	lemon/clp.h \
 	lemon/color.h \
 	lemon/concept_check.h \
 	lemon/counter.h \
 	lemon/core.h \
+	lemon/cplex.h \
 	lemon/dfs.h \
 	lemon/dijkstra.h \
 	lemon/dim2.h \
@@ -61,6 +63,7 @@
 	lemon/elevator.h \
 	lemon/error.h \
 	lemon/full_graph.h \
+	lemon/glpk.h \
 	lemon/graph_to_eps.h \
 	lemon/grid_graph.h \
 	lemon/hypercube_graph.h \
@@ -71,11 +74,7 @@
 	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/list_graph.h \
 	lemon/maps.h \
 	lemon/math.h \
@@ -86,6 +85,7 @@
 	lemon/radix_sort.h \
 	lemon/random.h \
 	lemon/smart_graph.h \
+	lemon/soplex.h \
 	lemon/suurballe.h \
 	lemon/time_measure.h \
 	lemon/tolerance.h \
diff --git a/lemon/clp.cc b/lemon/clp.cc
new file mode 100644
--- /dev/null
+++ b/lemon/clp.cc
@@ -0,0 +1,437 @@
+/* -*- 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.
+ *
+ */
+
+#include <lemon/clp.h>
+#include <coin/ClpSimplex.hpp>
+
+namespace lemon {
+
+  LpClp::LpClp() {
+    _prob = new ClpSimplex();
+    _init_temporals();
+    messageLevel(MESSAGE_NO_OUTPUT);
+  }
+
+  LpClp::LpClp(const LpClp& other) {
+    _prob = new ClpSimplex(*other._prob);
+    rows = other.rows;
+    cols = other.cols;
+    _init_temporals();
+    messageLevel(MESSAGE_NO_OUTPUT);
+  }
+
+  LpClp::~LpClp() {
+    delete _prob;
+    _clear_temporals();
+  }
+
+  void LpClp::_init_temporals() {
+    _primal_ray = 0;
+    _dual_ray = 0;
+  }
+
+  void LpClp::_clear_temporals() {
+    if (_primal_ray) {
+      delete[] _primal_ray;
+      _primal_ray = 0;
+    }
+    if (_dual_ray) {
+      delete[] _dual_ray;
+      _dual_ray = 0;
+    }
+  }
+
+  LpClp* LpClp::_newSolver() const {
+    LpClp* newlp = new LpClp;
+    return newlp;
+  }
+
+  LpClp* LpClp::_cloneSolver() const {
+    LpClp* copylp = new LpClp(*this);
+    return copylp;
+  }
+
+  const char* LpClp::_solverName() const { return "LpClp"; }
+
+  int LpClp::_addCol() {
+    _prob->addColumn(0, 0, 0, -COIN_DBL_MAX, COIN_DBL_MAX, 0.0);
+    return _prob->numberColumns() - 1;
+  }
+
+  int LpClp::_addRow() {
+    _prob->addRow(0, 0, 0, -COIN_DBL_MAX, COIN_DBL_MAX);
+    return _prob->numberRows() - 1;
+  }
+
+
+  void LpClp::_eraseCol(int c) {
+    _col_names_ref.erase(_prob->getColumnName(c));
+    _prob->deleteColumns(1, &c);
+  }
+
+  void LpClp::_eraseRow(int r) {
+    _row_names_ref.erase(_prob->getRowName(r));
+    _prob->deleteRows(1, &r);
+  }
+
+  void LpClp::_eraseColId(int i) {
+    cols.eraseIndex(i);
+    cols.shiftIndices(i);
+  }
+
+  void LpClp::_eraseRowId(int i) {
+    rows.eraseIndex(i);
+    rows.shiftIndices(i);
+  }
+
+  void LpClp::_getColName(int c, std::string& name) const {
+    name = _prob->getColumnName(c);
+  }
+
+  void LpClp::_setColName(int c, const std::string& name) {
+    _prob->setColumnName(c, const_cast<std::string&>(name));
+    _col_names_ref[name] = c;
+  }
+
+  int LpClp::_colByName(const std::string& name) const {
+    std::map<std::string, int>::const_iterator it = _col_names_ref.find(name);
+    return it != _col_names_ref.end() ? it->second : -1;
+  }
+
+  void LpClp::_getRowName(int r, std::string& name) const {
+    name = _prob->getRowName(r);
+  }
+
+  void LpClp::_setRowName(int r, const std::string& name) {
+    _prob->setRowName(r, const_cast<std::string&>(name));
+    _row_names_ref[name] = r;
+  }
+
+  int LpClp::_rowByName(const std::string& name) const {
+    std::map<std::string, int>::const_iterator it = _row_names_ref.find(name);
+    return it != _row_names_ref.end() ? it->second : -1;
+  }
+
+
+  void LpClp::_setRowCoeffs(int ix, ExprIterator b, ExprIterator e) {
+    std::map<int, Value> coeffs;
+
+    int n = _prob->clpMatrix()->getNumCols();
+
+    const int* indices = _prob->clpMatrix()->getIndices();
+    const double* elements = _prob->clpMatrix()->getElements();
+
+    for (int i = 0; i < n; ++i) {
+      CoinBigIndex begin = _prob->clpMatrix()->getVectorStarts()[i];
+      CoinBigIndex end = begin + _prob->clpMatrix()->getVectorLengths()[i];
+
+      const int* it = std::lower_bound(indices + begin, indices + end, ix);
+      if (it != indices + end && *it == ix && elements[it - indices] != 0.0) {
+        coeffs[i] = 0.0;
+      }
+    }
+
+    for (ExprIterator it = b; it != e; ++it) {
+      coeffs[it->first] = it->second;
+    }
+
+    for (std::map<int, Value>::iterator it = coeffs.begin();
+         it != coeffs.end(); ++it) {
+      _prob->modifyCoefficient(ix, it->first, it->second);
+    }
+  }
+
+  void LpClp::_getRowCoeffs(int ix, InsertIterator b) const {
+    int n = _prob->clpMatrix()->getNumCols();
+
+    const int* indices = _prob->clpMatrix()->getIndices();
+    const double* elements = _prob->clpMatrix()->getElements();
+
+    for (int i = 0; i < n; ++i) {
+      CoinBigIndex begin = _prob->clpMatrix()->getVectorStarts()[i];
+      CoinBigIndex end = begin + _prob->clpMatrix()->getVectorLengths()[i];
+
+      const int* it = std::lower_bound(indices + begin, indices + end, ix);
+      if (it != indices + end && *it == ix) {
+        *b = std::make_pair(i, elements[it - indices]);
+      }
+    }
+  }
+
+  void LpClp::_setColCoeffs(int ix, ExprIterator b, ExprIterator e) {
+    std::map<int, Value> coeffs;
+
+    CoinBigIndex begin = _prob->clpMatrix()->getVectorStarts()[ix];
+    CoinBigIndex end = begin + _prob->clpMatrix()->getVectorLengths()[ix];
+
+    const int* indices = _prob->clpMatrix()->getIndices();
+    const double* elements = _prob->clpMatrix()->getElements();
+
+    for (CoinBigIndex i = begin; i != end; ++i) {
+      if (elements[i] != 0.0) {
+        coeffs[indices[i]] = 0.0;
+      }
+    }
+    for (ExprIterator it = b; it != e; ++it) {
+      coeffs[it->first] = it->second;
+    }
+    for (std::map<int, Value>::iterator it = coeffs.begin();
+         it != coeffs.end(); ++it) {
+      _prob->modifyCoefficient(it->first, ix, it->second);
+    }
+  }
+
+  void LpClp::_getColCoeffs(int ix, InsertIterator b) const {
+    CoinBigIndex begin = _prob->clpMatrix()->getVectorStarts()[ix];
+    CoinBigIndex end = begin + _prob->clpMatrix()->getVectorLengths()[ix];
+
+    const int* indices = _prob->clpMatrix()->getIndices();
+    const double* elements = _prob->clpMatrix()->getElements();
+
+    for (CoinBigIndex i = begin; i != end; ++i) {
+      *b = std::make_pair(indices[i], elements[i]);
+      ++b;
+    }
+  }
+
+  void LpClp::_setCoeff(int ix, int jx, Value value) {
+    _prob->modifyCoefficient(ix, jx, value);
+  }
+
+  LpClp::Value LpClp::_getCoeff(int ix, int jx) const {
+    CoinBigIndex begin = _prob->clpMatrix()->getVectorStarts()[ix];
+    CoinBigIndex end = begin + _prob->clpMatrix()->getVectorLengths()[ix];
+
+    const int* indices = _prob->clpMatrix()->getIndices();
+    const double* elements = _prob->clpMatrix()->getElements();
+
+    const int* it = std::lower_bound(indices + begin, indices + end, jx);
+    if (it != indices + end && *it == jx) {
+      return elements[it - indices];
+    } else {
+      return 0.0;



More information about the Lemon-commits mailing list