[gecode-users] Beginner Question

Jorge Sanchez jsanchez at edaptive.com
Thu Aug 14 16:38:31 CEST 2008


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]]








More information about the gecode-users mailing list