[gecode-users] Getting domain values after posting

Christian Schulte schulte at imit.kth.se
Tue Mar 28 20:09:29 CEST 2006


Hi,

propagation in Gecode is not automatic (some simple cases are done
immediately as you report, others are not). This is not a bug but an
essential feature (this is what enables batch recomputation). In order to
actually perform constraint propagation one has to invoke the
status(unsigned int&) member function of a space. Not only will that perform
constraint propagation but it also reports about the status of a space: is
it failed, solved, does it require branching. So in your case just add
something along the lines:
	unsigned int alt;
	(void) status(alt); // Discard status result

After that you will be able to observe the result of constraint propagation.

Christian


--
Christian Schulte, http://web.imit.kth.se/~schulte/



-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Efstratios Kalogirou
Sent: Tuesday, March 28, 2006 5:35 PM
To: users at gecode.org
Subject: [gecode-users] Getting domain values after posting


Hi all, 

I am trying to get the remaining (valid) values and the size of the domain
of a variable after posting some constraints (assuming that due to the
constraints some values inside the domain are no longer valid). It seems
that everything is fine when I don't use any BoolVar to wrap the contraint.
For example: 

IntVarArray q(this,1,0,10);
post(this,q[0]==3);
cout<<"The size of the domain is now "<<q[0].size()<<endl;

In the above case the size of the domain is indeed 1 and the solution is
correctly the value 3. 

But things are different when I try to wrap the equality constraint in a
BoolVar:

IntVarArray q(this,1,0,10);
BoolVar wrapper(this,0,1);
rel(this,q[0],IRT_EQ,3,wrapper,ICL_BND);
post(this, wrapper==1);
cout<<"The size of the domain is now "<<q[0].size()<<endl;

In the latter example I get again the corrent solution 3 but after posting
the constraint the size of the domain remains 11 and doesn't shrink to 1 as
I would expect. 

Since I am solving problems using the second way I am wondering if there is
a way to shrink the domain of the variable after posting as showed in the
second example. Also how can I get all the valid values of the domain of a
variable after posting? I assume this can be done by using iterators but I
am not certain how exactly to relate the iterator with the IntVar or the
IntSet that represents the variable, so any enlightening on that, would be
highly appreciated. 

Best, 
Stratos Kalogirou





More information about the gecode-users mailing list