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, [email protected] <mailto:[email protected]> 

Expert Researcher, SICS, [email protected]

 

From: [email protected] [mailto:[email protected]] On Behalf Of 
?????? ???????
Sent: Saturday, January 28, 2017 16:02
To: [email protected]
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?

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Gecode users mailing list
[email protected]
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to