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

Christian Schulte cschulte at kth.se
Sun Jan 29 20:23:03 CET 2017


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, cschulte at kth.se <mailto:cschulte at kth.se> 

Expert Researcher, SICS, cschulte at sics.se

 

From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf Of ?????? ???????
Sent: Saturday, January 28, 2017 16:02
To: users at 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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20170129/f3effece/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4599 bytes
Desc: not available
URL: <http://www.gecode.org/pipermail/users/attachments/20170129/f3effece/attachment.bin>


More information about the users mailing list