pykp.knapsack.

Arrangement#

class pykp.knapsack.Arrangement(items: list[Item], state: list[int])#

Represents an arrangement of items for the knapsack problem.

Used to store the state of items in the knapsack, as well as the total value and weight of items in the arrangement. The state is represented as a binary array, where 1 indicates the item is in the arrangement, and 0 indicates it is not.

Parameters:
items: list[Item]

An array of items for the knapsack problem.

state: list[int]

Binary array indicating the inclusion or exclusion of items in the arrangement.

value: int

The total value of items in the arrangement.

weight int:

The total weight of items in the arrangement.

Attributes:
items: list[Item]

The items in the arrangement.

state: list[int]

The state of the arrangement.

value: float

The total value of items in the arrangement.

weight: float

The total weight of items in the arrangement.