MiniZinc tools

minizinc(mzn, *dzn_files[, args, data, …])

Implements the workflow for solving a CSP problem encoded with MiniZinc.

mzn2fzn(mzn, *dzn_files[, args, data, …])

Flatten a MiniZinc model into a FlatZinc one.

solns2out(stream, ozn_file)

Wraps the solns2out utility, executes it on the solution stream, and then returns the output stream.


Status of the solution stream.

Solutions(queue, *[, keep])

Solution stream returned by the pymzn.minizinc function.

MiniZincError(mzn_file, args[, stderr])

Generic error raised by the PyMzn functions.

PyMzn provides an interface to the minizinc executable to compile a MiniZinc model into a FlatZinc one, solve a given problem and get back the resulting solutions directly as Python objects.

The main function that PyMzn provides is the pymzn.minizinc function, which executes the entire workflow for solving a constranint program encoded in MiniZinc, just like using the minizinc executable from command line. As added benefit, the pymzn.minizinc function takes care of adding solver-dependent parameters and converts the solutions into Python dictionaries by default. Solving a MiniZinc problem with PyMzn is as simple as:

import pymzn

The pymzn.minizinc function is probably the way to go for most of the problems, but the pymzn.mzn2fzn and pymzn.solns2out functions are also included in the library to allow for maximum flexibility. The latter two functions are wrappers of the two homonym MiniZinc tools for, respectively, converting a MiniZinc model into a FlatZinc one and getting custom output from the solution stream of a solver.