int: W;
set of int: COL = 1..W;
int: H;
set of int: ROW = 1..H;
array[ROW,COL] of int: cost;
int: budget;
array[1..budget] of var COL: x;
array[1..budget] of var ROW: y;
array[1..budget] of int: c;
...
constraint forall(i in 1..budget)(c[i]=cost(x[i],y[i]));
Minizinc有一个关于约束的类型错误报告:找不到具有此签名的函数或谓词:“ cost(var int,var int)”。如何使用x,y将值从数组成本分配给数组c?
答案 0 :(得分:2)
cost
被声明为数组,而不是函数。这意味着MiniZinc希望您使用方括号cost[x[i], y[i]]
来使用它。因为您当前正在使用括号,所以MiniZinc认为cost(x[i],y[i])
是一个函数调用。