# HG changeset patch # User Alpar Juttner # Date 1336315574 -7200 # Node ID c3a7ca1087059bcab7085f801b8c3e7262fdc04c # Parent a30455cd01077c0bd30411709f576ffc729e5b7b# Parent 8d281761dea448411e2f138095495a641e1d3fae Merge bugfix #441 to branch 1.1 diff -r a30455cd0107 -r c3a7ca108705 lemon/bits/solver_bits.h --- a/lemon/bits/solver_bits.h Fri Jan 20 19:16:43 2012 +0100 +++ b/lemon/bits/solver_bits.h Sun May 06 16:46:14 2012 +0200 @@ -44,6 +44,7 @@ void clear() { first_item = -1; + last_item = -1; first_free_item = -1; items.clear(); cross.clear(); diff -r a30455cd0107 -r c3a7ca108705 lemon/cbc.cc --- a/lemon/cbc.cc Fri Jan 20 19:16:43 2012 +0100 +++ b/lemon/cbc.cc Sun May 06 16:46:14 2012 +0200 @@ -423,8 +423,6 @@ } _prob = new CoinModel(); - rows.clear(); - cols.clear(); } void CbcMip::_messageLevel(MessageLevel level) { diff -r a30455cd0107 -r c3a7ca108705 lemon/clp.cc --- a/lemon/clp.cc Fri Jan 20 19:16:43 2012 +0100 +++ b/lemon/clp.cc Sun May 06 16:46:14 2012 +0200 @@ -424,8 +424,6 @@ void ClpLp::_clear() { delete _prob; _prob = new ClpSimplex(); - rows.clear(); - cols.clear(); _col_names_ref.clear(); _clear_temporals(); } diff -r a30455cd0107 -r c3a7ca108705 lemon/cplex.cc --- a/lemon/cplex.cc Fri Jan 20 19:16:43 2012 +0100 +++ b/lemon/cplex.cc Sun May 06 16:46:14 2012 +0200 @@ -437,8 +437,6 @@ CPXfreeprob(cplexEnv(),&_prob); int status; _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem"); - rows.clear(); - cols.clear(); } void CplexBase::_messageLevel(MessageLevel level) { diff -r a30455cd0107 -r c3a7ca108705 lemon/glpk.cc --- a/lemon/glpk.cc Fri Jan 20 19:16:43 2012 +0100 +++ b/lemon/glpk.cc Sun May 06 16:46:14 2012 +0200 @@ -520,8 +520,6 @@ void GlpkBase::_clear() { glp_erase_prob(lp); - rows.clear(); - cols.clear(); } void GlpkBase::freeEnv() { diff -r a30455cd0107 -r c3a7ca108705 lemon/lp_base.h --- a/lemon/lp_base.h Fri Jan 20 19:16:43 2012 +0100 +++ b/lemon/lp_base.h Sun May 06 16:46:14 2012 +0200 @@ -1542,7 +1542,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 a30455cd0107 -r c3a7ca108705 test/lp_test.cc --- a/test/lp_test.cc Fri Jan 20 19:16:43 2012 +0100 +++ b/test/lp_test.cc Sun May 06 16:46:14 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);