Merge bugfix #441
authorAlpar Juttner <alpar@cs.elte.hu>
Sun, 06 May 2012 17:18:39 +0200
changeset 98938e1d4383262
parent 987 cfbabca1b4e9
parent 988 8d281761dea4
child 991 a10624ed1997
child 1054 c40a9d94442d
Merge bugfix #441
lemon/bits/solver_bits.h
lemon/cbc.cc
lemon/clp.cc
lemon/cplex.cc
lemon/glpk.cc
lemon/lp_base.h
     1.1 --- a/lemon/bits/solver_bits.h	Fri Feb 03 05:55:39 2012 +0100
     1.2 +++ b/lemon/bits/solver_bits.h	Sun May 06 17:18:39 2012 +0200
     1.3 @@ -44,6 +44,7 @@
     1.4  
     1.5        void clear() {
     1.6          first_item = -1;
     1.7 +        last_item = -1;
     1.8          first_free_item = -1;
     1.9          items.clear();
    1.10          cross.clear();
     2.1 --- a/lemon/cbc.cc	Fri Feb 03 05:55:39 2012 +0100
     2.2 +++ b/lemon/cbc.cc	Sun May 06 17:18:39 2012 +0200
     2.3 @@ -435,8 +435,6 @@
     2.4      }
     2.5  
     2.6      _prob = new CoinModel();
     2.7 -    rows.clear();
     2.8 -    cols.clear();
     2.9    }
    2.10  
    2.11    void CbcMip::_messageLevel(MessageLevel level) {
     3.1 --- a/lemon/clp.cc	Fri Feb 03 05:55:39 2012 +0100
     3.2 +++ b/lemon/clp.cc	Sun May 06 17:18:39 2012 +0200
     3.3 @@ -437,8 +437,6 @@
     3.4    void ClpLp::_clear() {
     3.5      delete _prob;
     3.6      _prob = new ClpSimplex();
     3.7 -    rows.clear();
     3.8 -    cols.clear();
     3.9      _col_names_ref.clear();
    3.10      _clear_temporals();
    3.11    }
     4.1 --- a/lemon/cplex.cc	Fri Feb 03 05:55:39 2012 +0100
     4.2 +++ b/lemon/cplex.cc	Sun May 06 17:18:39 2012 +0200
     4.3 @@ -470,8 +470,6 @@
     4.4      CPXfreeprob(cplexEnv(),&_prob);
     4.5      int status;
     4.6      _prob = CPXcreateprob(cplexEnv(), &status, "Cplex problem");
     4.7 -    rows.clear();
     4.8 -    cols.clear();
     4.9    }
    4.10  
    4.11    void CplexBase::_messageLevel(MessageLevel level) {
     5.1 --- a/lemon/glpk.cc	Fri Feb 03 05:55:39 2012 +0100
     5.2 +++ b/lemon/glpk.cc	Sun May 06 17:18:39 2012 +0200
     5.3 @@ -556,8 +556,6 @@
     5.4  
     5.5    void GlpkBase::_clear() {
     5.6      glp_erase_prob(lp);
     5.7 -    rows.clear();
     5.8 -    cols.clear();
     5.9    }
    5.10  
    5.11    void GlpkBase::freeEnv() {
     6.1 --- a/lemon/lp_base.h	Fri Feb 03 05:55:39 2012 +0100
     6.2 +++ b/lemon/lp_base.h	Sun May 06 17:18:39 2012 +0200
     6.3 @@ -1556,7 +1556,7 @@
     6.4      void min() { _setSense(MIN); }
     6.5  
     6.6      ///Clears the problem
     6.7 -    void clear() { _clear(); }
     6.8 +    void clear() { _clear(); rows.clear(); cols.clear(); }
     6.9  
    6.10      /// Sets the message level of the solver
    6.11      void messageLevel(MessageLevel level) { _messageLevel(level); }
     7.1 --- a/test/lp_test.cc	Fri Feb 03 05:55:39 2012 +0100
     7.2 +++ b/test/lp_test.cc	Sun May 06 17:18:39 2012 +0200
     7.3 @@ -41,11 +41,38 @@
     7.4  
     7.5  using namespace lemon;
     7.6  
     7.7 +int countCols(LpBase & lp) {
     7.8 +  int count=0;
     7.9 +  for (LpBase::ColIt c(lp); c!=INVALID; ++c) ++count;
    7.10 +  return count;
    7.11 +}
    7.12 +
    7.13 +int countRows(LpBase & lp) {
    7.14 +  int count=0;
    7.15 +  for (LpBase::RowIt r(lp); r!=INVALID; ++r) ++count;
    7.16 +  return count;
    7.17 +}
    7.18 +
    7.19 +
    7.20  void lpTest(LpSolver& lp)
    7.21  {
    7.22  
    7.23    typedef LpSolver LP;
    7.24  
    7.25 +  // Test LpBase::clear()
    7.26 +  check(countRows(lp)==0, "Wrong number of rows");
    7.27 +  check(countCols(lp)==0, "Wrong number of cols");
    7.28 +  lp.addCol(); lp.addRow(); lp.addRow();
    7.29 +  check(countRows(lp)==2, "Wrong number of rows");
    7.30 +  check(countCols(lp)==1, "Wrong number of cols");
    7.31 +  lp.clear();
    7.32 +  check(countRows(lp)==0, "Wrong number of rows");
    7.33 +  check(countCols(lp)==0, "Wrong number of cols");
    7.34 +  lp.addCol(); lp.addCol(); lp.addCol(); lp.addRow();
    7.35 +  check(countRows(lp)==1, "Wrong number of rows");
    7.36 +  check(countCols(lp)==3, "Wrong number of cols");
    7.37 +  lp.clear();
    7.38 +
    7.39    std::vector<LP::Col> x(10);
    7.40    //  for(int i=0;i<10;i++) x.push_back(lp.addCol());
    7.41    lp.addColSet(x);