[gecode-users] constraint “each value in array appears at least k times”

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


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.

Is there any other solutions for this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20170128/fe41ab56/attachment.html>


More information about the users mailing list