Reputation: 373
I'm trying to populate a 10 row array such that each column contains a "1", a "2", a "3" and seven "0" s. Does anyone have any idea how to do this? I tried constraining the column total to equal 6 but that returned columns with six ones, two threes etc. Is there a 'count' function that I am unaware of? Thanks!
Upvotes: 2
Views: 784
Reputation: 6854
There are at least three constraints that can be used for this:
See https://www.minizinc.org/2.0/doc-lib/doc-globals.html for a list of the global constraints supported in MiniZinc 2. The counting constraints are here: https://www.minizinc.org/2.0/doc-lib/doc-globals-counting.html
An example of how to use global_cardinality is here: http://hakank.org/minizinc/sudoku_pi.mzn
Upvotes: 3