COIN-OR::LEMON - Graph Library

Opened 12 years ago

Closed 12 years ago

#441 closed defect (fixed)

LpBase::clear() bug

Reported by: Alpar Juttner Owned by: Alpar Juttner
Priority: major Milestone: LEMON 1.3 release
Component: core Version: hg main
Keywords: Cc: athos@…
Revision id:

Description

From: athos

There is something I don't understand: I add columns to an lp, then I say lp.clear(), then again I add columns, and it seems that it does not add the columns again. Can you explain this to me?

See the attached code.

#include <lemon/list_graph.h>
#include <lemon/glpk.h>
using namespace lemon;

typedef GlpkLp Lp;

  ///Query function about the LP
  int numberOfCols(Lp & lp) {
    int count=0;
    for (Lp::ColIt c(lp); c!=lemon::INVALID; ++c) ++count;
    return count;
  }

int main(){
  typedef lemon::ListGraph Graph;
  Graph g;
  Graph::Node a=g.addNode();
  Graph::Node b=g.addNode();
  g.addEdge(a,b);
  Graph::EdgeMap< Lp::Col > x(g);
  
  Lp lp;
  lp.clear();
  std::cout << "The number of columns="<<numberOfCols(lp)<< std::endl;
  lp.addColSet(x);
  std::cout << "The number of columns="<<numberOfCols(lp)<< std::endl;
  lp.clear();
  std::cout << "The number of columns="<<numberOfCols(lp)<< std::endl;
  lp.addColSet(x);
  std::cout << "The number of columns="<<numberOfCols(lp)<< std::endl;

  
}

Attachments (1)

55c6560a7c0f.patch (2.0 KB) - added by Balazs Dezso 12 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 12 years ago by Alpar Juttner

Cc: athos@… added

Changed 12 years ago by Balazs Dezso

Attachment: 55c6560a7c0f.patch added

comment:2 Changed 12 years ago by Balazs Dezso

The patch [55c6560a7c0f] should fix the problem. There was a bug in the clear() method of lemon::solver_bits::VarIndex?.

comment:3 in reply to:  2 Changed 12 years ago by Alpar Juttner

Replying to deba:

The patch [55c6560a7c0f] should fix the problem. There was a bug in the clear() method of lemon::solver_bits::VarIndex?.

Thanks for the patch. Meanwhile, I pushed [8d281761dea4] to all affected branches (1.1, 1.2, main). In addition to your fix, it also moves to re-initialization of rows and cols to LpBase::clear()

comment:4 Changed 12 years ago by Alpar Juttner

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.