FlatZinc is a low-level modelling language for constraint problems. It is designed to be easily interfaceable to constraint solvers (like Gecode). For more information on FlatZinc, please refer to the MiniZinc pages of the G12 project.
We provide a parser that reads a FlatZinc model from a file, and returns a Gecode Space object that represents the model. We also provide a simple front-end, an executable program that reads a FlatZinc model and prints the solution (if any) on the standard output.
Downloading FlatZinc for Gecode
The current version of the FlatZinc interpreter for Gecode is 1.6. You can download the source archive:
The URL of Gecode/FlatZinc in our subversion repository is
https://svn.gecode.org/svn/interfaces/flatzinc/tags/release-1.6
Please check our download pages for more information on how to use our subversion repository.
Binary packages
The Windows installer package and the Mac OS package (see the Gecode download page) contain precompiled executable versions of the Gecode/FlatZinc interpreter.
Compiling and Installing FlatZinc for Gecode
You have to install Gecode 3.1.0 prior to compiling and installing the FlatZinc parser. Please follow the installation instructions on the Gecode web site. Also, make sure that pkg-config is available when configuring Gecode, so that the pkg-config files are generated and installed.
The prerequisites for compiling the FlatZinc parser are the same as for compiling the Gecode library.
Configuration
The FlatZinc parser uses GNU autoconf to acquire information about the system it is compiled on. Typically, you need to run configure in the toplevel source directory.
To setup Gecode for your particular system, you may need to add one or more of the following options to configure:
- To specify the location of your Gecode installation, use the --with-gecode switch.
- To install the parser somewhere else than the default /usr/local, use the --prefix=[...] switch
- You can get a list of all supported configuration options by calling configure with the --help switch.
Compilation and Installation
Just invoke make to compile and link the FlatZinc parser. The command make install will install the library and the executable.
Running the parser
The executable is called fz. You can run it with the -help switch to get an overview of how to invoke it:
$ ./fz -help Usage: fz [options]Options for Gecode/FlatZinc: -help, --help, -? print this help message -solutions (unsigned int) default: 1 number of solutions (0 = all) -threads (double) default: 1 number of threads (0 = #processing units) -c-d (unsigned int) default: 8 recomputation commit distance -a-d (unsigned int) default: 2 recomputation adaption distance --all-solutions whether to return all solutions -node (unsigned int) default: 0 node cutoff (0 = none, solution mode) -fail (unsigned int) default: 0 failure cutoff (0 = none, solution mode) -time (unsigned int) default: 0 time (in ms) cutoff (0 = none, solution mode) -mode (solution, stat, gist) default: solution how to execute script
Global constraint definitions for MiniZinc
The MiniZinc-to-FlatZinc converter provided by the G12 project can produce specialized FlatZinc that is targeted to a certain solver. Gecode/FlatZinc provides suitable definitions of global constraints in the directory mznlib. This directory is located in the Gecode directory installed in your program files folder (if you use the Windows binary package), in /usr/local/share/gecodef if you use the Mac OS binary package, or in <prefix>/share/gecodef if you installed Gecode/FlatZinc from the sources.
In order to make the MiniZinc-to-FlatZinc converter aware of these global constraint definitions, you can either
- copy the mznlib directory into the lib/minizinc directory of your MiniZinc installation, rename it to gecode, and use the -G gecode flag of mzn2fzn;
- or use the -I flag of mzn2fzn with the complete path to the mznlib directory.
