Knapsack#
- class Knapsack(values, weights, max_weight)[fuente]#
Bases:
OptimizationApplication
Optimization application for the «knapsack problem» [1].
Referencias
[1]: «Knapsack problem», https://en.wikipedia.org/wiki/Knapsack_problem
- Parámetros:
Attributes
- max_weight#
Getter of max_weight
- Devuelve:
The maximal weight for the knapsack problem
Methods
- interpret(result)[fuente]#
Interpret a result as item indices
- Parámetros:
result (OptimizationResult | ndarray) – The calculated result of the problem
- Devuelve:
A list of items whose corresponding variable is 1
- Tipo del valor devuelto:
- 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: