minizinc

Convert Boolean FlatZinc to CNF DIMACS

大城市里の小女人 提交于 2019-12-21 04:43:15
问题 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 = 3; int: noOfProducts = 23; % Dependent parameters int: bRows = aCols; int: cRows = aRows; int: cCols = bCols; set of int: products = 1..noOfProducts; % Corefficients are stored in arrays array[1..aRows, 1..aCols, products] of var bool: A; array[1..bRows, 1

Call Minizinc model from Java

老子叫甜甜 提交于 2019-12-13 07:38:23
问题 How to call a Minizinc model from a Java program with arrays as passed-on parameters? Is there any special command for doing this? 回答1: I frequently do the same but in python. There is probably not any module or extension that can integrate the call in any convenient way but it is quite easy to just call another program. Since I have not tried it in Java, I will let another stack overflow post guide you: Execute external program in java. You can pass the parameters either as -D "var_int_name

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

浪尽此生 提交于 2019-12-12 11:23:46
问题 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 'array[int] of int', actual 'array[int] of var opt int' in the code: % [0,5,2,0,7,0,3,0] -> true % [0,5,2,0,4,0,3,0] -> false (no circuit) % [0,5,2,0,3,0,8,7] -> false (two circuits) predicate circuit_ignoring_0(array[int] of var int: x) = let { array

MiniZinc “cannot determine bounds”

不羁的心 提交于 2019-12-12 06:06:10
问题 Writing my first non-trivial MiniZinc app, I keep running into the error "cannot determine bounds". How does one generally resolve this error? 回答1: In general “cannot determine bounds” means that the solver cannot determine the bounds (the domain) of a decision variable. Using "var int" as the domain of a decision variable should be avoided if possible, since it will probably slow down the solving process. There are times where the solver can figure out the domain, e.g. in cases likes % ...

(MiniZinc) unrecognized option `--solver'

女生的网名这么多〃 提交于 2019-12-11 17:13:06
问题 After resolving the problem I had with the PATH at Unable to run MiniZinc from command line - Even after adding installation location to PATH, I soon encountered another problem when invoking the solver via the command minizinc -c --solver Gecode model.mzn data.dzn . I obtained the error: minizinc: unrecognized option "--solver" . How can I resolve this? I also want to use the CBC and Gurobi solvers (mzn-cbc, mzn-gurobi) as well.. I am following the instructions given at http://www.minizinc

Unable to run MiniZinc from command line - Even after adding installation location to PATH

随声附和 提交于 2019-12-11 15:15:23
问题 Initially, I had the error: minizinc is not recognized as an internal or external command, operable program or batch file. when running minizinc mzn-cbc model.mzn data.mzn in the Git CMD. Later on, following the instructions found at https://github.com/MiniZinc/libminizinc/issues/213 with suggestions from https://groups.google.com/forum/#!topic/minizinc/IFpUM_TSNGU, I did: export PATH=$PATH:{MINIZINC} where {MINIZINC} is the installation location. However, my terminal returned the error:

Initialize only certain elements of array in dzn file

喜欢而已 提交于 2019-12-11 14:23:27
问题 I'm messing arround with minizinc and I want to have a static mzn file where I make the solving using only the dzn. For a better understanding of the question, here's a sample: include "globals.mzn"; include "data.dzn"; int: time; int: n; int: l=n*n; array[1..4,0..time,1..l] of var bool: X; solve satisfy; I now want to initialize only few elements of X using the dzn file (the other elements should be vars). The dzn would look like this time=1; n=3; X[4,1,7]=true; Since this initialization is

minizinc constraint solving with large string data

懵懂的女人 提交于 2019-12-11 12:25:51
问题 I'm working on a Highschool scheduling project with Minizinc. I have a list of teachers, classes, rooms, times, and events all of type string and a list of duration of type integer. I found on stackoverflow that I need to represent these data with numbers but my data is large. How do I go about this without manually converting each one of them? Thank you 回答1: Unfortunately, MiniZinc don't have any tools to convert strings to data in the appropriate format, so I'm afraid that you have to

How to obtain an exact infinite-precision representation of rational numbers via a non-standard FlatZinc extension?

ぃ、小莉子 提交于 2019-12-11 07:19:51
问题 By default mzn2fzn automatically computes the result of a floating point division within a MiniZinc model, and stores it as a constant float value in the resulting FlatZinc model. Example: The file test.mzn var float: x; constraint 1.0 / 1000000000000000000000000000000000.0 <= x; constraint x <= 2.0 / 1000000000000000000000000000000000.0; solve satisfy; translated with mzn2fzn test.mzn becomes equal to var 1e-33..2e-33: x; solve satisfy; What we would like to obtain***, instead, is a FlatZinc

Minizinc nested for loop

梦想的初衷 提交于 2019-12-11 01:39:35
问题 How could I use nested for loop(like what java does below) to generate/populate arrays in Minizinc? int[][] input1 = {{1,1,1}, {3,3,3}, {5,5,5} }; int[][] input2 = {{2,6,9},{7,7,7}, {9,9,9}, {11,11,11} }; int[][] diff = new int[input1.length][input2.length]; for(int i = 0; i < input1.length; i++){ for(int j = 0; j < input2.length; j++){ for(int k = 0; k < 3; k++){ diff[i][j] += input1[i][k]-input2[j][k]; } } } 回答1: There are two approaches doing this, depending on the nature of the diff