Reputation: 105
I used minizinc to program a shift planning code listed below. However , there's an error occurred with the error message : MiniZinc: type error: no function or predicate with this signature found: `forall(array[int] of var int)''
I would like to seed your help to figure out the reason. Many thanks
include "globals.mzn";
include "regular.mzn";
int: No_Shift = 7 ;
int: Hour = 24 ;
int: Cap = 30 ;
array[1..No_Shift , 1..Hour] of int: Shift_Available = [|1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,
|0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,
|0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,
|0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,
|0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0|];
array[1..Hour] of int: Demand = [10,8,12,16,18,25,28,30,30,30,30,25,26,27,30,30,30,30,26,22,17,14,10,8];
array[1..No_Shift] of var 0..30: Shift_Assigned;
constraint forall(i in 1..No_Shift)(Shift_Assigned[i]>=0);
constraint forall(i in 1..Hour)(
sum(j in 1..No_Shift)
(Shift_Assigned[j]*Shift_Available[j,i])<=Cap);
solve minimize forall(i in 1..Hour)(
sum(j in 1..No_Shift)
(Shift_Assigned[j]*Shift_Available[j,i])-Demand[i]);
Upvotes: 1
Views: 77
Reputation: 7342
The issue is that you are using forall
within the definition of the optimization goal. AFAIK, this is not supported.
Notice that you can iterate over both i
and j
from within sum
as follows:
solve minimize sum(i in 1..Hour, j in 1..No_Shift)
(Shift_Assigned[j] * Shift_Available[j,i] - Demand[i]);
Upvotes: 2