[gecode-users] random / mod

Christian Schulte schulte at imit.kth.se
Wed Aug 23 10:34:02 CEST 2006


Hi,

an easy way to get div/mod is to use multiplication and addition, that is:
if you want to compute a mod b then we know:
	(a div b) * b + (a mod b) = a
So introduce new variables d (for a div b), m (for a mod b) and p (for b*d)
subject to:
	m < b,  p+m=a, b*d=p

Hope that helps
Christian

PS: A word of caution: the propagation is very weak by the nature of mod. A
different approach for variables with a small domain and where b is constant
in a mod b is to use the element constraint: the array just contains a mod b
for different a's.

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

-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Kilian Sprotte
Sent: Tuesday, August 22, 2006 10:55 AM
To: users at gecode.org
Subject: [gecode-users] random / mod


Hello,

I would like to announce myself as a new Gecode user on the mac  
platform -- first experiences are very good !! :)

I admit that I have been reading on this list a little and followed  
with great curiosity the thread on random branching.... This really  
seems to be quite difficult and if I understand correctly, a final  
solution of this problem does not really exist, yet... (?)

Anyway, for the moment, I wanted to ask you a more simple question:

I would like to use a modulo constraint - it seems that I would have  
to implement it myself or am I missing something?

Thank you for this wonderful library!
Cheers,
   Kilian Sprotte



_______________________________________________
Gecode users mailing list
users at gecode.org https://www.gecode.org/mailman/listinfo/gecode-users





More information about the gecode-users mailing list