[gecode-users] (no subject)

Malcolm Ryan malcolmr at cse.unsw.edu.au
Sun Feb 10 09:48:56 CET 2008


I may have asked this before. If I have, please forgive me for asking  
again.

Suppose I have variables X1 ... Xn and Y1 ... Yn, with the constraints

distinct(X1, ..., Xn)
distinct(Y1, ..., Yn)

I now want to add the constraint:

Yi notin {Xj | j != i}, for i = 1 ... n

What would be the most efficient way to do this?

I could, of course, express it as:

Yi != X0
Yi != X1
...
Yi != Xi-1
Yi != Xi+ 1
...
Yi != Xn

The downside of this is that it would introduce a bunch of boolean  
variables to keep track of.

Alternatively. I could say:

distinct(X1, .., Xi-1, Yi, Xi+1, ... Xn)

which is overkill, but doesn't add any extra constraints that are not  
already covered by the original distinct(X1, ..., Xn) constraint.

Any suggestions as to which is likely to be better? Or is there  
another way?

Malcolm

--
            "Cleanliness is not next to godliness nowadays,
                 for cleanliness is made an essential
               and godliness is regarded as an offence.
                                     - G.K.Chesterton, On Lying in Bed







More information about the gecode-users mailing list