[gecode-users] Beginner Question

Guido Tack tack at ps.uni-sb.de
Thu Aug 14 16:58:16 CEST 2008


Hi!

Jorge Sanchez wrote:

> Hello,
> I am new to Gecode (and to constraints programming for the most part),
> and am using Gecode/J 2.1.1. My question relates to undefined  
> variables.
> I have a simple example where I have 2 arrays of Integer Variables  
> which
> may take on a 0 or 1. And a basic constraint saying that none of the
> variables are equal. I am getting 4 results which all have their
> variables as printed as [0..1]. The fact that I am getting 4 value is
> valid ([0, 0] [1, 1]; [0, 1] [1, 0]; [1, 0], [0, 1]; [1, 1] [0, 0]),  
> but
> I cannot see the actual values. I have attached my code to the  
> bottom of
> this message, is there any way I can force the actual values to be
> displayed (or defined)?
[...]
>    public GecodeTest(Boolean share, GecodeTest gecodeTest){
>        super(share, gecodeTest);
>        test = new VarArray(gecodeTest.test);
>        test_mut = new VarArray(gecodeTest.test_mut);
>    }

Here, you have to use the "copy constructor" for test and test_mut:

public GecodeTest(Boolean share, GecodeTest gecodeTest) {
   super(share, gecodeTest);
   test = new VarArray<IntVar>(this, share, gecodeTest.test);
   test_mut = new VarArray<IntVar>(this, share, gecodeTest.test_mut);
}

Otherwise, every solution will reference the variables in the original  
space, and that's what you print.

Cheers,
	Guido





More information about the gecode-users mailing list