Re: Propagation of Arithmetic Constraints

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Mon 09 Feb 2004 02:05:20 PM GMT
Message-ID: <402793A0.2060800@icparc.ic.ac.uk>
Karen Petrie wrote:
> Hi all,
> 
> I have a constraint linking two sets of variables together. Binary variables x_{i,j} :: [0,1] and variables y_{i,j} :: [0..511]. 
> 
> The constraint is (using fd library): 
> 
> y_{i,j} #= x_{i,j} +  (2 * x_{i,j+1}) + (4 * x_{i,j+2}) + (8 * x_{i+1,j}) + (16 * x_{i+1,j+1}) + (32 * x_{i+1,j+2}) + (64 * x_{i+2,j}) + (128* x_{i+2,j+1}) + (256* x_{i+2,j+2})
> 
> The y variables are the search variables. On a value being set for the y variable I would expect each of the x variables to automatically be set,


This seems to work fine (both in fd and ic):

?- (for(I,0,8), foreach(C*B,Sum) do B::0..1, C is 2^I), X #= sum(Sum).
B = B
C = C
I = I
X = X{[0..511]}
Sum = [1 * B{[0, 1]}, 2 * B{[0, 1]}, 4 * B{[0, 1]}, 8 * B{[0, 1]}, 16 * B{[0, 1]}, 32 * B{[0, 1]}, 64 * B{[0, 1]}, 128 * B{[0, 1]}, 256 * B{[0, 1]}]
There is 1 delayed goal.
Yes (0.00s cpu)

?- (for(I,0,8), foreach(C*B,Sum) do B::0..1, C is 2^I), X #= sum(Sum), X=235.
B = B
C = C
I = I
Sum = [1*1, 2*1, 4*0, 8*1, 16*0, 32*1, 64*1, 128*1, 256*0]
X = 235
Yes (0.00s cpu)


 > but on looking at the seach through the visulisation tools this does not seem to be the case.

If you are watching during execution, maybe the constraints have woken up,
but haven't been executed and done their work at the time you are looking.



-- 
  Joachim Schimpf              /             phone: +44 20 7594 8187
  IC-Parc                     /      mailto:J.Schimpf@imperial.ac.uk
  Imperial College London    /    http://www.icparc.ic.ac.uk/eclipse
Received on Mon Feb 09 14:10:38 2004

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:27 PM GMT GMT