Package: minizinc
MiniZinc PythonThe python package that allows you to access all of MiniZinc's functionalities directly from Python.Explore the docs »Report Bug·Request FeatureTable of ContentsAbout the ProjectGetting StartedInstallationUsageTestingRoadmapContributingLicenseContactAbout The ProjectMiniZinc Pythonprovides an interface from Python to the MiniZinc driver. The
most important goal of this project are to allow easy access to MiniZinc using
native Python structures. This will allow you to more easily make scripts to run
MiniZinc, but will also allow the integration of MiniZinc models within bigger
(Python) projects. This module also aims to expose an interface for meta-search.
For problems that are hard to solve, meta-search can provide solutions to reach
more or better solutions quickly.Getting StartedTo get a MiniZinc Python up and running follow these simple steps.InstallationMiniZinc Pythoncan be installed by runningpip install minizinc. It
requiresMiniZinc2.5.0+ andPython3.6.0+ to be installed on the system. MiniZinc
python expects theminizincexecutable to be available on the executable path,
the$PATHenvironmental variable, or in a default installation location.For more information, please refer to theDocumentationUsageOnce all prerequisites and MiniZinc Python are installed, aminizincmodule
will be available in Python. The following Python code shows how to run a
typical MiniZinc model.importminizinc# Create a MiniZinc modelmodel=minizinc.Model()model.add_string("""var -100..100: x;int: a; int: b; int: c;constraint a*(x*x) + b*x = c;solve satisfy;""")# Transform Model into a instancegecode=minizinc.Solver.lookup("gecode")inst=minizinc.Instance(gecode,model)inst["a"]=1inst["b"]=4inst["c"]=0# Solve the instanceresult=inst.solve(all_solutions=True)foriinrange(len(result)):print("x ={}".format(result[i,"x"]))For more examples, please refer to theDocumentationTestingMiniZinc Python usesToxenvironments to test
its coding style and functionality. The code style tests are executed usingBlack,Flake8, andisort. The functionality tests are
constructed using thePyTestunit testing framework.To run all tests, simply executetoxin the repository directory.Individual environments can be triggered using the-eflag.To test the coding style of the repository runtox -e checkThepy3xenvironments are used to test a specific Python version; for
example, to test using Python version 3.7 runtox -e py37Tox can also be used to generate the documentation,tox -e docs, and to
typeset the Python code,tox -e format.RoadmapSee theopen issuesfor a
list of proposed features (and known issues).ContributingContributions are what make the open source community such an amazing place to
be learn, inspire, and create. Any contributions you make aregreatly
appreciated.Fork the ProjectCreate your Feature Branch (git checkout -b feature/AmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull RequestLicenseDistributed under the Mozilla Public License Version 2.0. SeeLICENSEfor more information.Contact👤Jip J. DekkerTwitter:@DekkerOneGithub:Dekker1🏛MiniZincWebsite:https://www.minizinc.org/