If you want to write a propagator for this, the non-reified divmod
propagator that is included in the just released 2.2.0 might be a good
starting point.

 

Christian

 

--

Christian Schulte, www.ict.kth.se/~cschulte/

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Mauricio Toro
Sent: Monday, August 25, 2008 3:40 PM
To: gecode list
Subject: Re: [gecode-users] Modulo operator

 

Hello,

 

I am trying to write this reified constraint.

 

(a mod c = d) <-> b

where a,c,d are IntVars and b is BoolVar.

 

In the past, you recommend to represent

A = (B - C) mod n as  A = (B-C) + n * X.

 

But, now I am wondering how can I

write a reified propagator for (a mod c = d) <-> b.

 

Thanks,

 

Mauricio

2008/5/14 Guido Tack <[EMAIL PROTECTED]>

Malcolm Ryan wrote:

> I'd like to express the constraint:
>
> A = (B - C) mod n
> 0 <= A < n
>
> for variables A,B,C and constant n.
>
> How would you advise doing this? The obvious answer is to add an extra
> variable X:
>
> A = (B-C) + n * X
> 0 <= A < n
>
> but I'm not sure if this is best. Can you advise?

As there's no built-in propagator for the modulo constraint, you have
to decompose into other constraints, so your solution should be ok.
After all, it's just a linear equation with constant coefficients
1*A-1*B+1*C-n*X=0, right?  And X will be determined as soon as A,B,C
are, you don't even have to include X in the branching.

Guido



_______________________________________________
Gecode users mailing list
[EMAIL PROTECTED]
https://www.gecode.org/mailman/listinfo/gecode-users




-- 
Mauricio Toro Bermudez
Estudiante de Ingeniería de Sistemas
Pontificia Universidad Javeriana, Colombia

Stagiare à l'Ircam
1, place Igor-Stravinsky 75004 Paris, 
France de 2008 à 2009

_______________________________________________
Gecode users mailing list
[EMAIL PROTECTED]
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to