random_multi_knapsack(num_items: int, num_bins: int, seed: int = 32, value_range: Tuple[int, int] = (10, 50), weight_range: Tuple[int, int] = (10, 50)) dimod.constrained.ConstrainedQuadraticModel[source]

Return a constrained quadratic model encoding a multiple knapsack problem.

Given the number of items and the number of bins, the code generates a multiple-knapsack problem, formulated as a Constrained Quadratic Model. Values and weights for each item are uniformly sampled within the provided ranges. Capacities of bins are randomly assigned.

  • num_items – Number of items.

  • num_bins – Number of bins.

  • seed – seed for RNG.

  • value_range – The range of the randomly generated values for each item.

  • weight_range – The range of the randomly generated weights for each item.


A constrained quadratic model encoding the multiple knapsack problem. Variables are labelled as x_{i}_{j}, where x_{i}_{j} == 1 means that item i is placed in bin j.