WIPIVERSE All articles

MiniZinc

MiniZinc is a free and open-source constraint modelling language for specifying constraint satisfaction and optimisation problems, principally over integers and real numbers. It is designed to let a user express a problem at a high, solver-independent level, and to allow the same model to be solved by a variety of underlying solver technologies. It is commonly described as a high-level, typed, mostly first-order, functional modelling language with declarative semantics.

Overview

A MiniZinc model describes a class of problems rather than a single instance. Following the language's design, a problem specification is separated into two parts: the model, which describes the structure of a problem class, and the data, which specifies one particular instance of that class. The pairing of a model with a data set is called a model instance.

Typical features include:

  • Mathematical-notation-like syntax (quantifiers, sums over index sets, logical connectives, if-then-else expressions, set and array comprehensions).
  • A large library of pre-defined (global) constraints, such as all_different and cumulative.
  • User-defined predicates and functions, including overloading.
  • Separation of data from model, with data supplied in separate .dzn files or on the command line.
  • Parameterisation of models so that a single model can be reused across instances.
  • Type checking, instantiation (type-inst) checking, and assertions for reliability.
  • Annotations that convey non-declarative or solver-specific information (for example, search strategies) without altering the declarative meaning of the model.

Compilation and FlatZinc

A MiniZinc model is normally processed in two principal stages. The MiniZinc compiler flattens the model and its data into a lower-level language called FlatZinc, a solver-oriented target language consisting of variable declarations, constraint definitions, and (for optimisation problems) an objective function. The translation also makes use of a library of function and predicate definitions specific to the target solver, so that the generated FlatZinc contains only variable types and constraints supported by that solver. Global constraints supported natively by a solver can be preserved rather than decomposed, while unsupported ones are decomposed into lower-level constraints.

FlatZinc is intended to be simple enough that a solver writer can support MiniZinc by providing a relatively small FlatZinc front-end, rather than implementing the full modelling language. According to the language's specification, a MiniZinc model instance is evaluated in two phases: instance-time (static checking) and run-time (constraint solving).

Solver independence

Because MiniZinc models do not prescribe how a problem is to be solved, they can be translated into forms suitable for different solving paradigms, including constraint programming (CP), mixed integer linear programming (MIP), Boolean satisfiability (SAT), and satisfiability modulo theories (SMT). This solver independence is one of the language's central design goals, and is intended to facilitate experimentation with and comparison between solvers.

History and development

MiniZinc was presented in the paper "MiniZinc: Towards a Standard CP Modelling Language" by Nicholas Nethercote, Peter J. Stuckey, Ralph Becket, Sebastian Brand, Gregory J. Duck, and Guido Tack, published in the proceedings of the 13th International Conference on Principles and Practice of Constraint Programming (CP 2007). The paper proposed MiniZinc alongside FlatZinc and a standard translation between them, motivated by the observation that most constraint solvers had their own incompatible modelling languages.

MiniZinc is largely a subset of an earlier, more ambitious solver-independent modelling language called Zinc, described by Marriott, Nethercote, Rafeh, Stuckey, Garcia de la Banda, and Wallace in "The Design of the Zinc Modelling Language" (Constraints, 2008). MiniZinc removes much of Zinc's complexity—such as user-defined types and various coercions—in order to simplify compilation. The specification notes similarities between MiniZinc and OPL, and observes that MiniZinc moves closer to constraint logic programming languages such as ECLiPSe.

The language is developed at Monash University with support from OPTIMA. It remains under active development; releases are versioned and accompanied by change logs.

Tool chain

The MiniZinc tool chain includes:

  • The MiniZinc compiler (libminizinc), which parses, type-checks, and flattens models.
  • The MiniZinc IDE, a development environment for writing and running models, visualising search and solutions, and profiling performance.
  • The minizinc command-line tool.
  • Interface libraries that allow MiniZinc to be embedded in Python and JavaScript programs, and used from within a browser or Jupyter notebooks.
  • Additional tools such as CP-Profiler, Globalizer, FindMUS, mzn-analyse, and automatic solution-checking utilities.

Models are conventionally stored in files with the .mzn extension and data files with the .dzn extension. Solutions are typically emitted in a documented machine-readable output format, and MiniZinc also supports reading input parameters and producing output formatted as JSON.

Licensing

The core tools of MiniZinc—the MiniZinc compiler and the MiniZinc IDE—are distributed under the Mozilla Public License version 2.0, a licence classified as open source and free software. MiniZinc is therefore described as a free and open-source constraint modelling language.

MiniZinc Challenge

Since 2008, an annual MiniZinc Challenge has served as a competition for constraint programming solvers on a variety of benchmark problems expressed in the language. Challenge participants provide either a FlatZinc or a MiniZinc solver together with global constraint definitions specialised for their solver; each solver is run on MiniZinc model instances, and results are announced at the annual International Conference on Principles and Practice of Constraint Programming (CP). The MiniZinc Challenge is listed among the competitions of the Association for Constraint Programming.

See also

  • Constraint programming
  • Constraint satisfaction problem
  • Mathematical optimisation
  • FlatZinc (the solver-level target language)
  • Zinc (the modelling language MiniZinc derives from)

References

  • Nethercote, N., Stuckey, P. J., Becket, R., Brand, S., Duck, G. J., and Tack, G. "MiniZinc: Towards a Standard CP Modelling Language." In Proceedings of the 13th International Conference on Principles and Practice of Constraint Programming, LNCS 4741, Springer-Verlag, 2007, pp. 529–543.
  • Marriott, K., Nethercote, N., Rafeh, R., Stuckey, P. J., Garcia de la Banda, M., and Wallace, M. "The Design of the Zinc Modelling Language." Constraints, 13(3):229–267, 2008.
  • The MiniZinc Handbook — official documentation, including the language specification and reference manual.
  • MiniZinc project website and MiniZinc Challenge pages.
Browse

More topics to explore

    Browse all articles