BinPacking#
- class BinPacking(weights, max_weight, max_number_of_bins=None)[source]#
Bases:
OptimizationApplication
Optimization application for the “bin packing” [1] problem.
References
[1]: “Bin packing”, https://en.wikipedia.org/wiki/Bin_packing_problem
- Parameters:
Methods
- get_figure(result)[source]#
Get plot of the solution of the Bin Packing Problem.
- Parameters:
result (OptimizationResult | ndarray) – The calculated result of the problem
- Returns:
A plot of the solution, where x and y represent the bins and sum of the weights respectively.
- Return type:
fig
- interpret(result)[source]#
Interpret a result as item indices
- Parameters:
result (OptimizationResult | ndarray) – The calculated result of the problem
- Returns:
A list of lists with the items in each bin
- Return type:
items_in_bins
- static sample_most_likely(state_vector)#
Compute the most likely binary string from state vector.
- Parameters:
state_vector (QuasiDistribution | Statevector | ndarray | Dict) – state vector or counts or quasi-probabilities.
- Returns:
binary string as numpy.ndarray of ints.
- Raises:
ValueError – if state_vector is not QuasiDistribution, Statevector, np.ndarray, or dict.
- Return type: