dimod.generators.bin_packing#

bin_packing(weights: list[float], capacity: float) ConstrainedQuadraticModel[source]#

Generate a bin packing problem as a constrained quadratic model.

The bin packing problem, BPP, seeks to find the smallest number of bins that will fit a set of weighted items given that each bin has a weight capacity.

Parameters:
  • weights – The weights for each item.

  • capacity – The capacity of the bin.

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.