qlauncher.problems.optimization.knapsack

qlauncher.problems.optimization.knapsack#

This module contains the Knapsack class.

Summary#

Classes:

Knapsack

Class for 0/1 Knapsack Problem.

Reference#

class qlauncher.problems.optimization.knapsack.Knapsack(values: Sequence[int], weights: Sequence[int], capacity: int, instance_name: str = 'unnamed')[source]#

Bases: Problem

Class for 0/1 Knapsack Problem.

This class represents the 0/1 Knapsack problem: maximize the total value of chosen items subject to a capacity constraint on total weight. The class wraps a concrete instance and can be passed into QLauncher.

static from_preset(instance_name: Literal['default', 'small'], **kwargs) Knapsack[source]#
to_bqm(penalty_weight: float = 2.0, value_weight: float = 1.0) BQM[source]#

Returns BQM for Knapsack problem.