Questions tagged [minizinc]

MiniZinc is a solver-independent Constraint-Programming modelling language.

MiniZinc as modelling language is high-level enough to express most constraint problems easily, but low-level enough that it can be mapped onto existing solvers easily and consistently. This is done by converting the MiniZinc model to a lower-level language, FlatZinc. It is a subset of the higher-level language Zinc.

Around MiniZinc, several FlatZinc solvers and an IDE for development are freely available.

The MiniZinc home is here: http://www.minizinc.org

Hakan Kjellerstrand's MiniZinc page has lots of MiniZinc models and global constraint definitions.

426 questions
9
votes
1 answer

How can i install Google's CP solver OR-Tools in MiniZinc?

I'm currently working on MiniZinc, and i have been running my models with the two solvers integrated in MiniZinc: Gecode and Chuffed. I've been running it in the IDE, but i am aware that it can be runned in bash too (using minizinc command). But i…
6
votes
1 answer

Cardinality constraints in MiniZinc

The MiniZinc constraint solver allows to express cardinality constraints very easily using the built-in sum() function: % This predicate is true, iff 2 of the array % elements are true predicate exactly_two_sum(array[int] of var bool: x) = …
Axel Kemper
  • 10,544
  • 2
  • 31
  • 54
6
votes
1 answer

Map upper triangular matrix on vector skipping the diagonal

I have a problem that could be boiled down to finding a way of mapping a triangular matrix to a vector skipping the diagonal. Basically I need to translate this C++ code using the Gecode libraries // implied constraints for (int k=0, i=0; i
Agostino
  • 2,723
  • 9
  • 48
  • 65
6
votes
1 answer

Convert Boolean FlatZinc to CNF DIMACS

To solve a set of Boolean equations, I am experimenting with the Constraint-Programming Solver MiniZinc using the following input: % Solve system of Brent's equations modulo 2 % Matrix dimensions int: aRows = 3; int: aCols = 3; int: bCols =…
Axel Kemper
  • 10,544
  • 2
  • 31
  • 54
5
votes
2 answers

Count the number of different elements in an array

I am new to constraint programming and to Minizinc. I have look for a solution to this not relly hard task but I found nothing. I want to count the number of different elements that appear in an array: This is the declaration of my…
5
votes
1 answer

How to use Picat to create CNF files from Minizinc files?

I'm interested in counting the number of solutions a problem have (not enumerating the solutions). For that, I have tools that uses CNF files. I want to convert Minizinc files (mzn or Flatzinc fzn format) and convert it to CNF. I learned Picat has…
Exeloz
  • 89
  • 6
5
votes
1 answer

Counting total number of solutions with minizinc

Let's say I want to count the number of 80 element subsets of {1,2,..100} such that their sum is 3690. I have the following model: array[1..100] of var 0..1: b; constraint (sum (i in 1..100) (i*b[i])) == 3690; constraint (sum (i in 1..100) (b[i]))…
5
votes
1 answer

MiniZinc: type error: expected `array[int] of int', actual `array[int] of var opt int

I am trying to write a predicate that performs the same operation as circuit, but ignores zeros in the array, and I keep getting the following error: MiniZinc: type error: initialisation value for 'x_without_0' has invalid type-inst: expected…
5
votes
1 answer

Check if there is a path that connects two vertices in a graph using MiniZinc

I'm trying to make a constraint to check if there is a path from a vertex A to a vertex B in a graph. I've already made a constraint that returns the path itself, but I also need a function that returns a bool indicating if the path exists or…
5
votes
1 answer

Easy way to print full solution (all decision variables) in minizinc

The zinc spec says this: If no output item is present, the implementation should print all the global variables and their values in a readable format. However this does not appear to work with minizinc version 1.6.0: G12 MiniZinc evaluation…
esl
  • 245
  • 1
  • 9
4
votes
3 answers

Finding all the Combinations - N Rectangles inside the Square

I am a beginner in Constraint Programming using Minizinc and I need help from experts in the field. How can I compute all the possible combinations: 6 Rectangles inside the Square (10x10) using Minizinc? Considering that the RESTRICTIONS of the…
Carl S.
  • 51
  • 5
4
votes
1 answer

Optimise multiple objectives in MiniZinc

I am newbie in CP but I want to solve problem which I got in college. I have a Minizinc model which minimize number of used Machines doing some Tasks. Machines have some resource and Tasks have resource requirements. Except minimize that number, I…
badej60
  • 57
  • 5
4
votes
1 answer

minizinc python installation

I installed minizinc on python through anaconda prompt as normally with other packages. pip install minizinc The package says it was installed successfully and I can import the module. However, I'm following the basic example…
AGH
  • 300
  • 3
  • 12
4
votes
1 answer

How does the minizinc pentominoes regular constraint example work?

The minizinc benchmarks repository contains several pentomino examples. Here is the data for the first example: width = 5; height = 4; filled = 1; ntiles = 5; size = 864; tiles = [|63,6,1,2,0, |9,6,1,2,378, |54,6,1,2,432, |4,6,1,2,756, …
makeyourownmaker
  • 1,558
  • 2
  • 13
  • 33
4
votes
1 answer

Clarification on `failures` solver statistic in MiniZinc

I have been playing around with a simple n-queens model in MiniZinc: include "globals.mzn"; int: n_queens = 8; array[1..n_queens] of var 1..n_queens: queens; constraint alldifferent(queens); constraint alldifferent(i in 1..n_queens) (queens[i] +…
1
2 3
28 29