BinPacking#

class BinPacking(weights, max_weight, max_number_of_bins=None)[ソース]#

ベースクラス: OptimizationApplication

Optimization application for the 「bin packing」 [1] problem.

参照

[1]: 「Bin packing」, https://en.wikipedia.org/wiki/Bin_packing_problem

パラメータ:
  • weights (List[int]) – A list of the weights of items

  • max_weight (int) – The maximum bin weight capacity

  • max_number_of_bins (int | None) – The maximum number of bins by default equal to the number of items

Methods

get_figure(result)[ソース]#

Get plot of the solution of the Bin Packing Problem.

パラメータ:

result (OptimizationResult | ndarray) – The calculated result of the problem

戻り値:

A plot of the solution, where x and y represent the bins and sum of the weights respectively.

戻り値の型:

fig

interpret(result)[ソース]#

Interpret a result as item indices

パラメータ:

result (OptimizationResult | ndarray) – The calculated result of the problem

戻り値:

A list of lists with the items in each bin

戻り値の型:

items_in_bins

static sample_most_likely(state_vector)#

Compute the most likely binary string from state vector.

パラメータ:

state_vector (QuasiDistribution | Statevector | ndarray | Dict) – state vector or counts or quasi-probabilities.

戻り値:

binary string as numpy.ndarray of ints.

例外:

ValueError – if state_vector is not QuasiDistribution, Statevector, np.ndarray, or dict.

戻り値の型:

ndarray

to_quadratic_program()[ソース]#

Convert a bin packing problem instance into a QuadraticProgram

戻り値:

The QuadraticProgram created from the bin packing problem instance.

戻り値の型:

QuadraticProgram