This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

PyMzn is a Python library that wraps and enhances the MiniZinc tools for CSP modelling and solving. It is built on top of the libminizinc library and provides a number of off-the-shelf functions to readily solve problems encoded in MiniZinc and parse the solutions into Python objects.

Usage

First, you need a MiniZinc model encoding the problem you want to solve. Here is a simple 0-1 knapsack problem encoded with MiniZinc::

%% test.mzn %%
int: n;                     % number of objects
set of int: OBJ = 1..n;
int: capacity;              % the capacity of the knapsack
array[OBJ] of int: profit;  % the profit of each object
array[OBJ] of int: size;    % the size of each object

var set of OBJ: x;
constraint sum(i in x)(size[i]) <= capacity;
var int: obj = sum(i in x)(profit[i]);
solve maximize obj;


%% test.dzn %%
n = 5;
profit = [10, 3, 9, 4, 8];
size = [14, 4, 10, 6, 9];

You can solve the above problem using the pymzn.minizinc function::

import pymzn
pymzn.minizinc('test.mzn', 'test.dzn', data={'capacity': 20})

The result will be::

[{'x': {3, 5}}]

The minizinc function automatically flattens the MiniZinc model, using the provided mzn and dzn files, and the inline data provided. It executes the solver on the flattened model and parses the solution stream to get the solutions as Python dictionaries.

PyMzn is also able to:

For a follow-up of this example, read the Quick Start guide.

For more information on the PyMzn functions read the reference manual.

Install

PyMzn can be installed via Pip::

pip3 install pymzn

or from the source code available on GitHub::

python3 setup.py install

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

Requirements

PyMzn requires some additional software to be installed on your system before you can use it properly, namely:

You can use any solver you like, but the default one for PyMzn is Gecode. If you use the Gecode solver, PyMzn will work out-of-the-box, otherwise it will need some little configuration (see the Solvers section).

Detailed instructions on how to install libminizinc and Gecode can be found in the Install section of the documentation.

Contribute

If you find a bug or think of a useful feature, please submit an issue on the GitHub page of PyMzn.

Pull requests are very welcome too. If you are interested in contributing to the PyMzn source code, read about its implementation details. Some things that would be very useful are:

  • Implement specific interfaces for not yet supported solvers;
  • Enhance existing ones.

Heads up on future changes

Be aware that this project is still currently under development and thus it is not in a stable version yet. Things in the future will certainly change. This is especially due to recent changes in the minizinc library, which are introducing lots of new features that could make some of PyMzn’s features obsolete. At any rate, PyMzn will stay updated to the most recent changes in MiniZinc and keep enhancing its python interface.

Author

Paolo Dragone, PhD student at the University of Trento.

Release History

Release History

0.11.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.10.8

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.10.7

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pymzn-0.11.2.linux-x86_64.tar.gz (40.7 kB) Copy SHA256 Checksum SHA256 any Dumb Binary Nov 19, 2016
pymzn-0.11.2.tar.gz (23.6 kB) Copy SHA256 Checksum SHA256 Source Nov 19, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting