MiniZinc tools

SolnStream(solns, complete) Represents a solution stream from the minizinc function.
minizinc(mzn, *dzn_files[, data, keep, …]) Implements the workflow to solve a CSP problem encoded with MiniZinc.
mzn2fzn(mzn_file, *dzn_files[, data, …]) Flatten a MiniZinc model into a FlatZinc one.
solns2out(soln_stream, ozn_file) Wraps the solns2out utility, executes it on the solution stream, and then returns the output stream.
MiniZincError([msg]) Generic error for the MiniZinc functions.
MiniZincUnsatisfiableError() Error raised when a minizinc problem is found to be unsatisfiable.
MiniZincUnknownError() Error raised when minizinc returns no solution (unknown).
MiniZincUnboundedError() Error raised when a minizinc problem is found to be unbounded.

PyMzn provides functions that mimic and enhance the tools from the libminizinc library. With these tools, it is possible to compile a MiniZinc model into FlatZinc, solve a given problem and get the output solutions directly into the python code.

The main function that PyMzn provides is the minizinc function, which executes the entire workflow for solving a CSP problem encoded in MiniZinc. Solving a MiniZinc problem with PyMzn is as simple as:

import pymzn
pymzn.minizinc('test.mzn')

The minizinc function is probably the way to go for most of the problems, but the mzn2fzn and solns2out functions are also included in the public API 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.