BinPacking#

class BinPacking(weights, max_weight, max_number_of_bins=None)[fuente]#

Bases: OptimizationApplication

Optimization application for the «bin packing» [1] problem.

Referencias

[1]: «Bin packing», https://en.wikipedia.org/wiki/Bin_packing_problem

Parámetros:
  • 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)[fuente]#

Get plot of the solution of the Bin Packing Problem.

Parámetros:

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

Devuelve:

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

Tipo del valor devuelto:

fig

interpret(result)[fuente]#

Interpret a result as item indices

Parámetros:

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

Devuelve:

A list of lists with the items in each bin

Tipo del valor devuelto:

items_in_bins

static sample_most_likely(state_vector)#

Compute the most likely binary string from state vector.

Parámetros:

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

Devuelve:

binary string as numpy.ndarray of ints.

Muestra:

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

Tipo del valor devuelto:

ndarray

to_quadratic_program()[fuente]#

Convert a bin packing problem instance into a QuadraticProgram

Devuelve:

The QuadraticProgram created from the bin packing problem instance.

Tipo del valor devuelto:

QuadraticProgram