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.
dekker-phd-thesis/assets/listing/rew_knapsack.mzn

17 lines
451 B
MiniZinc

predicate knapsack(
array[int] of int: w,
array[int] of int:p,
array[int] of var int:x,
var int: W, var int: P
) =
assert(
index_set(w) = index_set(p) /\ index_set(w) = index_set(x),
"index set of weights must be equal to index set of profits and index set of items",
) /\ assert(
lb_array(w) >= 0,
"weights must be non-negative",
) /\ assert(
lb_array(p) >= 0,
"profits must be non-negative",
) /\ fzn_knapsack(w, p, x, W, P);