[Lemon-commits] Alpar Juttner: Merge bugfix #441
Lemon HG
hg at lemon.cs.elte.hu
Sun May 6 17:26:18 CEST 2012
details: http://lemon.cs.elte.hu/hg/lemon/rev/38e1d4383262
changeset: 1143:38e1d4383262
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Sun May 06 17:18:39 2012 +0200
description:
Merge bugfix #441
diffstat:
lemon/bits/solver_bits.h | 1 +
lemon/cbc.cc | 2 --
lemon/clp.cc | 2 --
lemon/cplex.cc | 2 --
lemon/glpk.cc | 2 --
lemon/lp_base.h | 2 +-
test/lp_test.cc | 27 +++++++++++++++++++++++++++
7 files changed, 29 insertions(+), 9 deletions(-)
diffs (113 lines):
diff --git a/lemon/bits/solver_bits.h b/lemon/bits/solver_bits.h
--- a/lemon/bits/solver_bits.h
+++ b/lemon/bits/solver_bits.h
@@ -44,6 +44,7 @@
void clear() {
first_item = -1;
+ last_item = -1;
first_free_item = -1;
items.clear();
cross.clear();
diff --git a/lemon/cbc.cc b/lemon/cbc.cc
--- a/lemon/cbc.cc
+++ b/lemon/cbc.cc
@@ -435,8 +435,6 @@
}
_prob = new CoinModel();
- rows.clear();
- cols.clear();
}
void CbcMip::_messageLevel(MessageLevel level) {
diff --git a/lemon/clp.cc b/lemon/clp.cc
--- a/lemon/clp.cc
+++ b/lemon/clp.cc
@@ -437,8 +437,6 @@
void ClpLp::_clear() {
delete _prob;
_prob = new ClpSimplex();
- rows.clear();
- cols.clear();
_col_names_ref.clear();
_clear_temporals();
}
diff --git a/lemon/cplex.cc b/lemon/cplex.cc
--- a/lemon/cplex.cc
+++ b/lemon/cplex.cc
@@ -470,8 +470,6 @@
CPXfreeprob(cplexEnv(),&_prob);
int status;
_prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem");
- rows.clear();
- cols.clear();
}
void CplexBase::_messageLevel(MessageLevel level) {
diff --git a/lemon/glpk.cc b/lemon/glpk.cc
--- a/lemon/glpk.cc
+++ b/lemon/glpk.cc
@@ -556,8 +556,6 @@
void GlpkBase::_clear() {
glp_erase_prob(lp);
- rows.clear();
- cols.clear();
}
void GlpkBase::freeEnv() {
diff --git a/lemon/lp_base.h b/lemon/lp_base.h
--- a/lemon/lp_base.h
+++ b/lemon/lp_base.h
@@ -1556,7 +1556,7 @@
void min() { _setSense(MIN); }
///Clears the problem
- void clear() { _clear(); }
+ void clear() { _clear(); rows.clear(); cols.clear(); }
/// Sets the message level of the solver
void messageLevel(MessageLevel level) { _messageLevel(level); }
diff --git a/test/lp_test.cc b/test/lp_test.cc
--- a/test/lp_test.cc
+++ b/test/lp_test.cc
@@ -41,11 +41,38 @@
using namespace lemon;
+int countCols(LpBase & lp) {
+ int count=0;
+ for (LpBase::ColIt c(lp); c!=INVALID; ++c) ++count;
+ return count;
+}
+
+int countRows(LpBase & lp) {
+ int count=0;
+ for (LpBase::RowIt r(lp); r!=INVALID; ++r) ++count;
+ return count;
+}
+
+
void lpTest(LpSolver& lp)
{
typedef LpSolver LP;
+ // Test LpBase::clear()
+ check(countRows(lp)==0, "Wrong number of rows");
+ check(countCols(lp)==0, "Wrong number of cols");
+ lp.addCol(); lp.addRow(); lp.addRow();
+ check(countRows(lp)==2, "Wrong number of rows");
+ check(countCols(lp)==1, "Wrong number of cols");
+ lp.clear();
+ check(countRows(lp)==0, "Wrong number of rows");
+ check(countCols(lp)==0, "Wrong number of cols");
+ lp.addCol(); lp.addCol(); lp.addCol(); lp.addRow();
+ check(countRows(lp)==1, "Wrong number of rows");
+ check(countCols(lp)==3, "Wrong number of cols");
+ lp.clear();
+
std::vector<LP::Col> x(10);
// for(int i=0;i<10;i++) x.push_back(lp.addCol());
lp.addColSet(x);
More information about the Lemon-commits
mailing list