paolodragone / pymzn

A Python wrapper for the MiniZinc tool pipeline.
MIT License
55 stars 15 forks source link

Add an option to obtain the minizinc stats #45

Open Moisan opened 4 years ago

Moisan commented 4 years ago

The command line version of minizinc has an option (-s / --statistics) that outputs solver related statistics for every solution found. I didn't find any way to obtain this data when using pymzn.minizinc. Would it be possible to add an option and return this data with the resulting dictionary?

paolodragone commented 4 years ago

Hello @Moisan, so there actually is a way to do it: pymzn.minizinc returns a Solutions object (docs) which contains a field called log, which just contains the log of the MiniZinc call:

solns = pymzn.minizinc(...)
print(solns.log)

This is just a string, no structured information (I had the plan to make it more structured, but very little time to actually do it :), so if you need to manipulate or display this information in some other way you will need to extract it from the string. I guess few simple regexps should suffice.