问题
I'm wondering if there is a generalisation of solver.AllDifferent(x) in google or-tools that allows for the specification of how many different elements I allow.
So if len(x) = 4, then AllDifferent(x) means that len(set(x)) = 4. But what if I just want to enforce "at least 2 different", so: len(set(x)) >=2 ?
Is there a constraint that generalises AllDifferent to be able to set the cardinality of the solution variable ?
来源:https://stackoverflow.com/questions/48021694/make-k-different-cardinality-google-or-tools