Gecode: Gecode/FlatZinc
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.
FlatZinc for Gecode
Starting with Gecode version 3.2.0, the FlatZinc interpreter for Gecode is part of the standard Gecode distribution. Please check our download pages for more information on how to get a copy of Gecode. Source packages as well as binary packages are available.
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 at 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/gecode if you use the Mac OS binary package, or in <prefix>/share/gecode if you installed Gecode 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.