# HG changeset patch # User Alpar Juttner # Date 1336317519 -7200 # Node ID 38e1d4383262a146b119291383c65007f7704ec3 # Parent cfbabca1b4e9b8d4ce408f853db728509d020110# Parent 8d281761dea448411e2f138095495a641e1d3fae Merge bugfix #441 diff -r cfbabca1b4e9 -r 38e1d4383262 lemon/bits/solver_bits.h --- a/lemon/bits/solver_bits.h Fri Feb 03 05:55:39 2012 +0100 +++ b/lemon/bits/solver_bits.h Sun May 06 17:18:39 2012 +0200 @@ -44,6 +44,7 @@ void clear() { first_item = -1; + last_item = -1; first_free_item = -1; items.clear(); cross.clear(); diff -r cfbabca1b4e9 -r 38e1d4383262 lemon/cbc.cc --- a/lemon/cbc.cc Fri Feb 03 05:55:39 2012 +0100 +++ b/lemon/cbc.cc Sun May 06 17:18:39 2012 +0200 @@ -435,8 +435,6 @@ } _prob = new CoinModel(); - rows.clear(); - cols.clear(); } void CbcMip::_messageLevel(MessageLevel level) { diff -r cfbabca1b4e9 -r 38e1d4383262 lemon/clp.cc --- a/lemon/clp.cc Fri Feb 03 05:55:39 2012 +0100 +++ b/lemon/clp.cc Sun May 06 17:18:39 2012 +0200 @@ -437,8 +437,6 @@ void ClpLp::_clear() { delete _prob; _prob = new ClpSimplex(); - rows.clear(); - cols.clear(); _col_names_ref.clear(); _clear_temporals(); } diff -r cfbabca1b4e9 -r 38e1d4383262 lemon/cplex.cc --- a/lemon/cplex.cc Fri Feb 03 05:55:39 2012 +0100 +++ b/lemon/cplex.cc Sun May 06 17:18:39 2012 +0200 @@ -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 -r cfbabca1b4e9 -r 38e1d4383262 lemon/glpk.cc --- a/lemon/glpk.cc Fri Feb 03 05:55:39 2012 +0100 +++ b/lemon/glpk.cc Sun May 06 17:18:39 2012 +0200 @@ -556,8 +556,6 @@ void GlpkBase::_clear() { glp_erase_prob(lp); - rows.clear(); - cols.clear(); } void GlpkBase::freeEnv() { diff -r cfbabca1b4e9 -r 38e1d4383262 lemon/lp_base.h --- a/lemon/lp_base.h Fri Feb 03 05:55:39 2012 +0100 +++ b/lemon/lp_base.h Sun May 06 17:18:39 2012 +0200 @@ -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 -r cfbabca1b4e9 -r 38e1d4383262 test/lp_test.cc --- a/test/lp_test.cc Fri Feb 03 05:55:39 2012 +0100 +++ b/test/lp_test.cc Sun May 06 17:18:39 2012 +0200 @@ -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 x(10); // for(int i=0;i<10;i++) x.push_back(lp.addCol()); lp.addColSet(x);