There are two types in Python that are associated with MiniZinc’s sets: set
and range. Generally a set in MiniZinc will be of the type set. For
example, the minizinc set {-2,4,12} will be represented in MiniZinc Python
as {-2,4,12} or set([-2,4,12]). However, contiguous sets, like index sets in MiniZinc,
can be more efficiently represented in a range object, as this only records
the start and end of the set. For example, the MiniZinc set -90..310 is
represented using range(-90,311) in MiniZinc Python. When creating a set in
Python, either object can be translated to a MiniZinc set.

Note

The end given Python range objects is non-inclusive. This means the
object range(1,3) only contains 1 and 2. This is unlike the MiniZinc
range syntax, which is inclusive. The MiniZinc set 1..3 contains 1, 2,
and 3.

The following example shows how to assign set parameters and how to use the
solutions for set variables.

The support for enumerated types in MiniZinc Python is still limited. It is,
however, already supported to assign enumerated types in MiniZinc using a Python
enumeration. When a enumeration is assigned, the values in the solution are
ensured to be of the assigned enumerated type. This is demonstrated in the
following example:

Enumerations that are defined in MiniZinc are currently not translated into
Python enumerations. Their values are currently returned as strings. The
following adaptation of the previous example declares an enumerated type in
MiniZinc and contains a string in it’s solution.

MiniZinc does not support finding all optimal solutions for a specific
optimisation problem. However, a scheme that is often used to find all
optimal solutions is to first find one optimal solution and then find all
other solutions with the same optimal value. The following example shows this
process for a toy model that maximises the value of an array of unique integers:

MiniZinc Python supports the use of MiniZinc solution checkers. The solution
checker file can be added to a Model/Instance just like any normal
MiniZinc file. Once a checker has been added, any solve operation will
automatically run the checker. The output of the Solution checker can be
accessed using the Solution.check() method. The following example follows
shows the usage for a trivial Solution checking model.