Please read in MPG about the global cardinality constraint (which in Gecode is also called count). It is exactly what you are looking for.
Best Christian -- Christian Schulte, www.gecode.org/~schulte <http://www.gecode.org/~schulte> Professor of Computer Science, KTH, cschu...@kth.se <mailto:cschu...@kth.se> Expert Researcher, SICS, cschu...@sics.se From: users-boun...@gecode.org [mailto:users-boun...@gecode.org] On Behalf Of ?????? ??????? Sent: Saturday, January 28, 2017 16:02 To: users@gecode.org Subject: [gecode-users] constraint “each value in array appears at least k times” 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?
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Gecode users mailing list users@gecode.org https://www.gecode.org/mailman/listinfo/gecode-users