[gecode-users] Copying Integer Variables between spaces

Guido Tack tack at gecode.org
Wed Jan 9 23:42:56 CET 2013


On 09/01/2013, at 10:51 PM, ostrowsk at uni-potsdam.de wrote:

> I want to use the information about pruned values from an Integer Variable in another space.
> 
> So i have a Space with variable x and some constraints.
> I do propagation, now x is constrained somehow according to the constraints and the propagator strength, e.g. x = {1..3,5..9}.
> 
> Now i want to create a second Space with a variable y, whose domain is is a copy of the current domain of x. (so that y={1..3,5..9})
> 
> These variables do have nothing in common and are not connected somehow by the constraints.
> 
> I tried to use the IntVar constructor that takes another IntVar or the IntView of x, but i think this is wrong (get segfault when copying spaces).

Right, that won't work.

> So, how do i transfer the domain, without sharing the VarImp.

You have to use iterators. Let's say you want to create a new variable y in space s with the domain of x:

    IntVarRanges ir(x);
    IntVar y(s,IntSet(ir));

Cheers,
Guido




More information about the users mailing list