Search code examples
minizinc

Increasing optimization level results in errors


Here is a simple model that requires all elements of one array to be equal to elements of the other one:

int: n = 3;
set of int: N = 1..n;
array[N, N] of var bool: P1 = [|true, false, false|
                          false, true, false|
                          false, false, false|];
array[N, N] of var bool: P2;

% constraint forall (x, y in N) (if P1[x,y] then P2[x,y] else true endif);

% constraint forall (x, y in N) (P1[x,y] == P2[x,y]);

constraint forall (x, y in N) (P1[x,y] <-> P2[x,y]);

solve satisfy;

When I run it with optimization levels -O0 or -O1, everything works fine, but when I switch to higher optimization levels, I get several errors of this kind:

Error: undefined identifier for type bool X_INTRODUCED_0_ in line no. 10

As you can see, I have tried many approaches. What could possibly cause a problem in such a simple program?

This happens even in the simplest case, with only one decision variable inside the array:

array[1..1] of bool: n = [true];
array[1..1] of var bool: k;

constraint n[1] == k[1];

solve satisfy;

Solution

  • This actually seems to be the same issue as this one. It might not look the same, but because it probably is as it seems that the optimisation phase is removing an identifier that is not yet marked to be part of the output. The issue should be solved in the next MiniZinc release.