Knapsack#
- class Knapsack(values, weights, max_weight)[source]#
Bases:
OptimizationApplication
Optimization application for the "knapsack problem" [1].
References
[1]: "Knapsack problem", https://en.wikipedia.org/wiki/Knapsack_problem
- প্যারামিটার:
Attributes
- max_weight#
Getter of max_weight
- রিটার্নস:
The maximal weight for the knapsack problem
Methods
- interpret(result)[source]#
Interpret a result as item indices
- প্যারামিটার:
result (OptimizationResult | ndarray) -- The calculated result of the problem
- রিটার্নস:
A list of items whose corresponding variable is 1
- রিটার্ন টাইপ:
- 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.
- রিটার্ন টাইপ: