言語
English
Bengali
Japanese
Spanish



Knapsack

class Knapsack(values, weights, max_weight)[ソース]

ベースクラス: OptimizationApplication

Optimization application for the 「knapsack problem」 [1].

参照

[1]: 「Knapsack problem」, https://en.wikipedia.org/wiki/Knapsack_problem

パラメータ:
  • 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