liang
liang

Reputation: 11

MiniZinc: type error: no function or predicate with this signature found: `cost(var int,var int)'

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 has a type error report for constraint: no function or predicate with this signature found: `cost(var int,var int)'. How can I assign value from array cost to array c by using x,y ?

Upvotes: 1

Views: 84

Answers (1)

Magnus Åhlander
Magnus Åhlander

Reputation: 1446

cost is declared as an array, not a function. This means that MiniZinc expects you to use it using square brackets, i.e. cost[x[i], y[i]]. Because you are currently using parentheses MiniZinc thinks that cost(x[i],y[i]) is a function call.

Upvotes: 2

Related Questions