[gecode-users] cloning variable problem

Guido Tack tack at ps.uni-sb.de
Tue Oct 24 23:12:30 CEST 2006


Hi!

> I've been trying to create an IntVar X1 in a space S1, and  create a
> clone of X1 namely X2 in a space S2.  i called the update method of
> IntVar to create the clone.
> It all seems to work ok,  but when i try to impose some propagators i
> got a Segmentation Fault.

The problem is that you must not call the update method of an IntVar
outside the copy constructor of a space. You basically cannot create a
clone of an IntVar outside of the copy constructor of your space.

For copying to work, the variables need to store the location they were
copied to, so that sharing can be detected and the same variable is not
copied twice. All this is done behind your back in the clone function of
the space. The space takes care that variables are in a clean state after
copying. If you just call update, noone takes care of cleaning up the
variable's state, that's why you get a segmentation fault.

Cheers,
   Guido

-- 
Guido Tack
http://www.ps.uni-sb.de/~tack






More information about the gecode-users mailing list