Closed dan1221 closed 1 year ago
Your initial solution would be the preferred MiniZinc way is to use the solution count as produced in the statistics.
There is a nSolutions
statistic field that is produced by the MiniZinc driver, and thus is independent from the solver used. It seems, however, that there is currently an issue where the command line flag used by the IDE does not output this statistic. We will resolve this for the next MiniZinc release.
A workaround is to use the command line:
minizinc -a -s --solver chuffed model.mzn
which outputs %%%mzn-stat: nSolutions=9496
for your model.
Or, you can manually add the -s
parameter using the "Add custom parameter" option in the IDE.
Yay!!!! The -s solved my problem of getting solution counts from Chuffed! Thank you!
I still have the separate issue that the solution counts apparently aren't available inside the model, when using global constraints. They are available when using "sum", but as you note, that isn't the preferred MiniZinc way.
I'd like the program to print out the first 10 or so terms of the sequence for OEIS:A000085:
1, 1, 2, 4, 10, 26, 76, 232, 764, 2620
But that doesn't work if the solution counts are only available in the IDE statistics, and only apply to one value of the parameter n.
Thanks!!
On 22.02.2023 20:42, Guido Tack wrote:
Closed #607 [1] as completed via 2e78416 [2].
-- Reply to this email directly, view it on GitHub [3], or unsubscribe [4]. You are receiving this because you authored the thread.Message ID: @.***>
Links:
[1] https://github.com/MiniZinc/libminizinc/issues/607 [2] https://github.com/MiniZinc/libminizinc/commit/2e78416acfe49d9bac780d522368c618c979fa24 [3] https://github.com/MiniZinc/libminizinc/issues/607#event-8587667506 [4] https://github.com/notifications/unsubscribe-auth/AUOVUCX5GYRYCR5BJYZ5U63WY3TEPANCNFSM6AAAAAAQBFAQ2Y
I'm trying to count solutions using the MiniZinc IDE. This seems like a common desire when considering combinatorial objects. But the MiniZinc Handbook is strangely silent on the topic, except for Section 2.6.2. Effective Generators: "Imagine we want to count the number of triangles (K3 subgraphs) appearing in a graph," involving using "sum" to count true predicates by iterating over an integer range. But "sum" apparently isn't able to count solutions to global constraints, which typically involve a search space consisting of arrays, not just integer ranges.
The IDE Configuration Editor has a checkbox for "Output Solving Statistics". That works fine with the Gecode solver, but not with Chuffed. Unfortunately, Gecode is much slower than Chuffed on the models I've tried, so I can't use it on the larger models. Is there a way to get Chuffed to output the number of solutions?
Can "sum" be enhanced to iterate over an array, like global constraints, instead of just integer ranges?
Here's an example:
If we use "sum" to count involutions, we have to do some serious rearrangement of the above code, and it runs a lot slowerl