[gecode-users] Pair counting constraint

Сергей Солонец ssolonets at gmail.com
Sat Jan 28 16:00:35 CET 2017


I have two IntVarArgs variables both of length of n, with domain from 0 to k

I need a constraint expression that counts unique pairs between these 2
arrays

f.e I want constraint count(a, b, {1, 2}, 3) to hold if there are 3 pairs
of values 1, 2 on the same index, what I do now is introducing a new
variable called classes

for (int i = 0; i < n; i++)
{
    classes[i] = expr(*this, a[i] * k + b[i]);
}

where classes variable is different for different pairs, and after I apply
counting constraint on it, but I feel like there should be a better solution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20170128/f5a6e6d7/attachment.html>


More information about the users mailing list