random_bin_packing(num_items: int, seed: int | None = None, weight_range: Tuple[int, int] = (10, 30)) ConstrainedQuadraticModel[source]#

Generate a bin packing problem as a constrained quadratic model.

The weights for each item are integers uniformly drawn from in the weight_range. The bin capacity is set to num_items * mean(weights) / 5.

  • num_items – Number of items to choose from.

  • seed – Seed for NumPy random number generator.

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


The constrained quadratic model encoding the bin packing problem. Variables are labeled as y_{j} where y_{j} == 1 means that bin j has been used and x_{i}_{j} where x_{i}_{j} == 1 means that item i has been placed in bin j.