MiniZinc / libminizinc

The MiniZinc compiler
http://www.minizinc.org
Other
519 stars 81 forks source link


Logo

MiniZinc

A high-level constraint modelling language that allows you to easily express and solve discrete optimisation problems.
Visit our website »

View Documentation · Report Bug · Request Feature

Table of Contents

About The Project

MiniZinc is a free and open-source constraint modeling language.

You can use MiniZinc to model constraint satisfaction and optimisation problems in a high-level, solver-independent way, taking advantage of a large library of pre-defined constraints. Your model is then compiled into FlatZinc, a solver input language that is understood by a wide range of solvers.

MiniZinc is developed at Monash University in collaboration with Data61 Decision Sciences.

Getting Started

To get a MiniZinc up and running follow these simple steps.

Installation

The recommended way to install MiniZinc is by the use of the bundled binary packages. These packages are available for machines running Linux, Mac, and Windows.

The latest release can be found on the MiniZinc website.

Usage

Once the MiniZinc bundle is installed on your machine, you can start expressing and solving discrete optimisation problems. The following code segment shows a MiniZinc model for the well known n-queens problem.

int: n = 8; % The number of queens.

array [1..n] of var 1..n: q;

include "alldifferent.mzn";

constraint alldifferent(q);
constraint alldifferent(i in 1..n)(q[i] + i);
constraint alldifferent(i in 1..n)(q[i] - i);

You have two easy options to solve this model:

For more example MiniZinc models and more information about working with MiniZinc, please refer to our Documentation

Building

The following instructions will help you compile the MiniZinc compiler. Note that this repository does not include the IDE, findMUS, or any solvers that are part of the MiniZinc project. These can be found in the following repositories:

Prerequisites

Compilation

The MiniZinc compiler is compiled as a CMake project. CMake's User Interaction Guide can provide you with a quick introduction to compiling CMake projects. The following CMake variables can be used in the MiniZinc project to instruct the compilation behaviour:

Variable Default Description
CMAKE_BUILD_TYPE Release Build type of single-configuration generators.
CMAKE_INSTALL_PREFIX Install directory used by --target install.
CMAKE_POSITION_INDEPENDENT_CODE TRUE Whether to create a position-independent targets
_ROOT Additional directory to look for
CMAKE*DISABLE_FIND_PACKAGE* FALSE Disable compilation of 's solver interface
CPLEX_PLUGIN TRUE Load CPLEX at runtime (instead of static compilation)

Possible values for are CPlex, Geas, Gecode, and OsiCBC.

Testing

The correctness of the MiniZinc compiler is tested using a PyTest test suite. Instruction on how to run the test suite and how to add new tests can be found here

License

Distributed under the Mozilla Public License Version 2.0. See LICENSE for more information.

Contact

🏛 MiniZinc Community

🏛 Monash Optimisation Group