Hello,

I'm getting started with Gecode reading "Modeling with Gecode". I have
experience in Constraint Programming using iLog software.

I installed Gecode and I created a project to test it. I used SendMoreMoney
example. Everything is ok and I can compile and execute this example.

However, when I tried to build my own simple model, compilation is ok but I
get a segmentation fault when posting a linear constraint. It is very
strange because I imitated SendMoreMoney example. I searched in mailing list
but I didn't find anything.

I show you the code. In main.cpp we have:

int main(int argc, char* argv[]) {
  SchoolTimeTable* problem = new SchoolTimeTable();
[...]
  return 0;
}

In schoolTimeTable.h we have:

#include <gecode/int.hh>

using namespace Gecode;

class SchoolTimeTable : public Space {
protected:
  BoolVarArray m_vars;
public:
  SchoolTimeTable(void);
  SchoolTimeTable(bool share, SchoolTimeTable& s);
  virtual Space* copy(bool share);
  void print(void) const;
};

In schoolTimeTable.cpp we have:

#include "schoolTimeTable.h"
#include <gecode/search.hh>

SchoolTimeTable::SchoolTimeTable(void){
  m_vars = BoolVarArray(*this,900);

  BoolVarArgs borrame(3);
  for (int i=0; i<3; i++) borrame[i]=m_vars[i];
  linear(*this,borrame,IRT_EQ,2); // SIGSEGV IS HERE
}

SchoolTimeTable::SchoolTimeTable(bool share, SchoolTimeTable& s)
  : Space(share, s) {
  m_vars.update(*this, share, s.m_vars);
}

Space* SchoolTimeTable::copy(bool share) {
  return new SchoolTimeTable(share,*this);
}

Technical data:

OS: Debian GNU/Linux Squeeze
Gecode version: 3.1.0
gcc version: 4.3.3
gdb version: 6.8

Thank you very much,

Alfredo
_______________________________________________
Gecode users mailing list
us...@gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to