Anyone can help me to slove this gramma error? I do know how to rewrite this code
constraint
forall(i in 1..LINENUMBER,j in 1..DAYSETNUMBER )
( PACKOUTCAP[i,j] -( sum(k in 1..j)(INPUTCAP[i,k] * rate[i,k,j-k+1])) >0 );
As mentioned in the comment: What is your full model (with some explanation what it should do). What error do you get? Which MiniZinc version?
The following model is your code with some fictive data added. It don't give any errors, and yield a lot of solutions.
int: LINENUMBER = 3;
int: DAYSETNUMBER = 3;
array[1..LINENUMBER,1..DAYSETNUMBER] of var 1..10: PACKOUTCAP;
array[1..LINENUMBER,1..DAYSETNUMBER] of var 1..10: INPUTCAP;
array[1..LINENUMBER,1..DAYSETNUMBER,1..LINENUMBER] of var 1..10: rate;
constraint
forall(i in 1..LINENUMBER,j in 1..DAYSETNUMBER )
( PACKOUTCAP[i,j] -( sum(k in 1..j)(INPUTCAP[i,k] * rate[i,k,j-k+1])) >0 );
Regarding cumulative sum, here's a simple model where the array y
contains the cumulative sum of the values in the array x
. Perhaps that help you?
int: n = 5;
array[1..n] of var 1..10: x;
array[1..n] of var 1..100: y; % cumulative sum
constraint
y[1] = x[1] /\
forall(i in 2..n) (
y[i] = y[i-1] + x[i]
)
;