[gecode-users] Modulo operator

Mauricio Toro mauriciotorob at gmail.com
Mon Aug 25 15:40:01 CEST 2008


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 <tack at ps.uni-sb.de>

> 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
> users at gecode.org
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20080825/d0f67382/attachment.htm>


More information about the gecode-users mailing list