dimod.generators.random_bin_packing#

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

Generate a random 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.

Parameters:
  • num_items – Number of items to choose from.

  • seed – Seed for the random number generator. Passed to numpy.random.default_rng().

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

Returns:

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.