[gecode-users] Construct a variables of a model with variables from another model

Farshid Hassani Bijarbooneh farshid.hassani at gmail.com
Wed Jul 3 22:11:12 CEST 2013


Hi,

I have two Gecode models and in one (say class A) I create variables and I want the variables in the other class (say class B) be initialised with the domains of a subset of  variables from class A. This is similar to the 'kakuro.cpp' case study example in MPG with one difference that I want to initialise those variables in class B to take the exact domain as the variables passed from class A. I know this is possible by passing an array of IntSet and a Dom constraint to propagate the domains of the variables in class B, but I wanted to directly use the constructor of the IntVarArray:
IntVarArray (Space &home, const IntVarArgs &a)
Initialize from integer variable argument array a (copy elements). 
 
I attached a minimal example 'test.cpp' to demonstrate this problem. In the attached example class A is called PassVar and class B is called DistinctTest. The example finds the solutions to the model of class DistinctTest but it fails at class PassVar by throwing a segmentation fault, and I don't see why that is the case. If I remove the distinct constraint in class DistinctTest then both classes can successfully find all the solutions. According to Gecode reference initialising an IntVarArray with (Space &home, const IntVarArgs &a) should only initialise the new variables by copying the elements, but I think this might not to be the case here. Can you please have a look at the code and let me know if I'm doing something wrong here.



Best regards,
Farshid

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20130703/7df3a40c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cpp
Type: application/octet-stream
Size: 1752 bytes
Desc: not available
URL: <http://www.gecode.org/pipermail/users/attachments/20130703/7df3a40c/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20130703/7df3a40c/attachment-0001.html>


More information about the users mailing list