Search code examples
compiler-errorsconstraint-programmingminizinc

Minizinc seemingly generates invalid FZ code


I have the following piece of my model:

constraint forall(d in Day, s in Student)
(
  let {
    %groups in day
    array[int] of var opt Group: gid = [g | g in assignment[s] where group_day[g] == d];
    %groups starts in day
    array[int] of var opt Time: gsid = [group_start[g] | g in gid];
    %groups ends in day
    array[int] of var opt Time: geid = [group_end[g] | g in gid];
    %groups durations in day
    array[int] of var opt Time: gdid = [group_duration[g] | g in gid];
    var opt Time: min_start = min(gsid);
    var opt Time: max_end = max(geid);
    var opt Time: sum_dur = sum(gdid);
    var opt int: time = ((max_end - min_start) - sum_dur);
  } in
  wasted_time_units[d,s] = deopt(time)
);

I've been trying to get it working by removing opt data type from the model, by deopting the whole gid, but that threw model inconsistency detected error. Fixing and deopting gid array worked, but assignment is a variable so that produced invalid output. Finally I have arrived to the model shown above, it passed the type check but now I'm getting a cryptic error:

Error: Unknown character in line no. 1914
Error: Unknown character in line no. 1914
Error: Unknown character in line no. 1914
Error: syntax error, unexpected '(', expecting FZ_ID in line no. 1914

Below I've attached the FlatZinc output (with line numbers in square brackets):

[1913] constraint int_lin_eq([1,1,1,-1],[X_INTRODUCED_894_,X_INTRODUCED_908_,X_INTRODUCED_922_,X_INTRODUCED_955_],0):: defines_var(X_INTRODUCED_955_);
[1914] constraint '-'(X_INTRODUCED_954_,X_INTRODUCED_952_,X_INTRODUCED_956_):: defines_var(X_INTRODUCED_956_);
[1915] constraint '-'(X_INTRODUCED_956_,X_INTRODUCED_955_,X_INTRODUCED_957_):: defines_var(X_INTRODUCED_957_);
[1916] constraint int_ne_reif(X_INTRODUCED_963_,0,X_INTRODUCED_962_):: defines_var(X_INTRODUCED_962_);

What does the error mean and how can I avoid it? It seems like minizinc is generating invalid FZ code.


Solution

  • The problem was solved by patching minizinc.

    Issue was handled here: https://github.com/MiniZinc/libminizinc/issues/588

    After compiling the develop branch, the issue disappeared!