Jérémie Vautard wrote:
I am coding a little stuff that needs to extract some potential partial solutions from a constraint problem. To do this, I have a (pointer to a)Gecode::Space S with an array of IntVar, and I do the following : - I have initially propared a set of IntVarArgs, each containing a given subset of the variables of S.
- I create S2 to be a clone of S ( via S2 = S->clone(); )
- I choose one of the IntVarArgs I initially created, let's call it V, and I create a new IntVarArgs V2(V); - I update all the variables of V2 so that they "become" variables of S2 : for (int i=0;i<V2.size();i++) V2[i].update(S2,true,V[i]); - I post a branching in S2 with the variables of V2. e.g. : Gecode::branch(S2,V2,INT_VAR_SIZE_MIN,INT_VAL_MIN);

However, when I search on S2 (with the DFS engine), the returned solution do not have the corresponding variables domain reduces to a singleton. (I check this via an IntVar public member of my Gecode::Space descendant class that I did not forget to update in the copy constructor :-) )

I join an small example that illustrates my issue : for this problem with one variable and no constraints, I obtain 2 solutions (this number is correct), but, for both of them, the 'v' member is still [0..1]...

I most likely have missed something, but I don't understand what....

The problem is that you cannot use update outside the Space's copy constructor (or any method it calls in turn). Copying uses forwarding pointers and other "magic" behind the scenes, so when you clone a space, some clean-up is done after all the updates. I think for the problem you're describing, you might want to use arrays of indices for describing the subsets instead of using IntVarArgs directly. Then you don't have to mess with update, but you can just create an IntVarArgs and initialize it directly from the IntVarArray in the space, using the indices.

Cheers,
        Guido

_______________________________________________
Gecode users mailing list
[email protected]
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to