1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
Jip J. Dekker f2a1c4e389 Squashed 'software/mza/' content from commit f970a59b17
git-subtree-dir: software/mza
git-subtree-split: f970a59b177c13ca3dd8aaef8cc6681d83b7e813
2021-07-11 16:34:30 +10:00

15 lines
558 B
MiniZinc

/** @group globals
Requires that in each subsequence \a vs[\p i], ..., \a vs[\p i + \a seq - 1] the sum of the
values belongs to the interval [\a low, \a up].
*/
predicate fzn_sliding_sum(int: low, int: up, int: seq, array[int] of var int: vs) =
let { int: lx = min(index_set(vs)),
int: ux = max(index_set(vs)),
} in
forall (i in lx .. ux - seq + 1) (
let {
var int: sum_of_l = sum(j in i..i + seq - 1) (vs[j])
} in
low <= sum_of_l /\ sum_of_l <= up
);