小编Und*_*lin的帖子

MiniZinc:类型错误:预期的`array[int] of int',实际的`array[int] of var opt int

我正在尝试编写一个与 执行相同操作的谓词circuit,但忽略数组中的零,并且我不断收到以下错误:

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'

在代码中:

% [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[int] of int: x_without_0 = [x[i] | i in 1..length(x) where x[i] != 0],
        int: lbx = min(x_without_0),
        int: ubx = max(x_without_0),
        int: len = length(x_without_0),
        array[1..len] of var lbx..ubx: …
Run Code Online (Sandbox Code Playgroud)

minizinc

5
推荐指数
1
解决办法
3636
查看次数

标签 统计

minizinc ×1