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 tonum_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}wherey_{j} == 1means that binjhas been used andx_{i}_{j}wherex_{i}_{j} == 1means that itemihas been placed in binj.