Gecode pair counting constraint

49 Views Asked by At

I work with Gecode on C++ 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

0

There are 0 best solutions below