Arrangement

This module provides an interface for defining arrangements of items.

Example

Define an arangement of items for the knapsack problem:

from pykp import Arrangement, Item

items = [
   Item(value=10, weight=5),
   Item(value=20, weight=10),
   Item(value=30, weight=15),
]
state = [0, 1, 1]
arrangement = Arrangement(items=items, state=state)
print(arrangement)
class pykp.arrangement.Arrangement(items: ndarray[Item], state: ndarray[int])

Bases: object

Represents an arrangement of items for the knapsack problem.

items

An array of items for the knapsack problem.

Type:

np.ndarray[Item]

state

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

Type:

np.ndarray[int]

value

The total value of items in the arrangement.

Type:

int

weight

The total weight of items in the arrangement.

Type:

int