Gecode constraint "each value in array appears at least k times"

127 Views Asked by At

it's Gecode c++

I have an IntVarArgs value of length n and I want to push a constraint that each value in array appears at least k times (or 0) f.e array [1, 2, 3, 1, 2, 3, 4, 4, 4] satisfies this constraint with k = 2

what I do now is

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

However, as n grows, the number of constraints grows, but I feel like it could be expressed by a single constraint. I also think that closure of array to itself is not optimal for the solver.

0

There are 0 best solutions below