Project Description

PyMzn is a Python library that wraps and enhances the MiniZinc tools for constraint programming. PyMzn is built on top
of the minizinc toolkit and
provides a number of off-the-shelf functions to readily solve problems encoded
with the MiniZinc language and parse the solutions into Python objects.

Usage

First, we need to define a constraint program via MiniZinc.
Here is a simple 0-1 knapsack problem encoded with MiniZinc:

The returned object is a lazy solution stream, which can however be directly
referenced as a list. The minizinc function takes care of flattening the
MiniZinc model, launching the solver, and parsing the solutions into Python
dictionaries.

Install

Currently, PyMzn is developed and maintained in Python 3.5 with a
porting to Python 2.7 at every release (the python2 branch does not always
contain the most recent changes).

Requirements

PyMzn requires the MiniZinc toolkit to be installed on your machine, along with
at least one solver. The easiest way to install MiniZinc is to download the
MiniZincIDE package, which
contains both the MiniZinc binaries and several solvers. After downloading the
package, make sure the executables are visible to PyMzn by either setting the
PATH environment variable or by configuring it using the pymzn.config
module.