[gecode-users] Beginner Question

Ujhelyi Zoltan uz602 at hszk.bme.hu
Thu Aug 14 16:58:17 CEST 2008


Hello,

If I am correct, the result is caused by the fact that Gecode  
calculates all the possible solutions, and in your case they are in  
the form of result. If you say, none of them can be equal, it can  
happen both by the array element 1 to be 0 or 1; your constraint does  
not allow Gecode to reduce the domains.

But if you add a constraint, in which you state, that a value is zero,  
than Gecode will be able to calculate, that the other one has to be one.
(A constraint like that: rel(this, this.get(0), IRT_EQ, 0);)

I hope, I was at some help,
Zoltán Ujhelyi
On 2008.08.14., at 16:38, 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)?
>
> Thanks,
> Jorge
>
> ///////////code:
> import org.gecode.BABIterator;
> import org.gecode.BExpr;
> import org.gecode.Gecode;
> import org.gecode.GecodeEnumConstants;
> import org.gecode.IntRelType;
> import org.gecode.IntVar;
> import org.gecode.Space;
> import org.gecode.VarArray;
>
> public class GecodeTest extends Space {
>
>    public VarArray<IntVar> test;
>    public VarArray<IntVar> test_mut;
>
>    public GecodeTest() {
>        super("GecodeTest");
>        test = new VarArray<IntVar>(this, 2, IntVar.class,  0, 1);
>        test_mut = new VarArray<IntVar>(this, 2, IntVar.class,  0, 1);
>
>        for(int i = 0; i < 2; i++){
>            Gecode.post(this, new BExpr(test.get(i),  
> IntRelType.IRT_NQ, test_mut.get(i)));
>        }
>        Gecode.branch(this, test, GecodeEnumConstants.INT_VAR_MAX_MIN,
>                GecodeEnumConstants.INT_VAL_MAX);
>        Gecode.branch(this, test_mut,  
> GecodeEnumConstants.INT_VAR_MAX_MIN,
>                GecodeEnumConstants.INT_VAL_MAX);
>    }
>    public GecodeTest(Boolean share, GecodeTest gecodeTest){
>        super(share, gecodeTest);
>        test = new VarArray(gecodeTest.test);
>        test_mut = new VarArray(gecodeTest.test_mut);
>    }
>    public static void main(String[] args){
>        GecodeTest test = new GecodeTest();
>        BABIterator<Space> iterator = new BABIterator(test);
>        Space s = null;
>        try{
>            while(iterator.hasNext()){
>                s = iterator.next();
>                System.out.println(s);
>            }
>        } catch(Exception e){
>
>        }
>
>    }
>
> }
>
> ---- and the output I see is the following:
>
> GecodeTest:
> test=[[0..1],[0..1]]
> test_mut=[[0..1],[0..1]]
>
> GecodeTest:
> test=[[0..1],[0..1]]
> test_mut=[[0..1],[0..1]]
>
> GecodeTest:
> test=[[0..1],[0..1]]
> test_mut=[[0..1],[0..1]]
>
> GecodeTest:
> test=[[0..1],[0..1]]
> test_mut=[[0..1],[0..1]]
>
>
>
>
>
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users





More information about the gecode-users mailing list