English
Languages
English
Shortcuts



Knapsack

class Knapsack(values, weights, max_weight)[source]

Bases: qiskit_optimization.applications.optimization_application.OptimizationApplication

Optimization application for the “knapsack problem” [1].

References

[1]: “Knapsack problem”, https://en.wikipedia.org/wiki/Knapsack_problem

Parameters
  • values (List[int]) – A list of the values of items

  • weights (List[int]) – A list of the weights of items

  • max_weight (int) – The maximum weight capacity

Attributes

max_weight

Getter of max_weight

Methods

interpret(result)

Interpret a result as item indices

to_quadratic_program()

Convert a knapsack problem instance into a QuadraticProgram