dimod.generators.quadratic_multi_knapsack#
- quadratic_multi_knapsack(values: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], weights: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], profits: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], capacities: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ConstrainedQuadraticModel [source]#
Generate a constrained quadratic model encoding a quadratic multiple knapsack problem.
The quadratic multiple knapsack problem seeks to fit the most value into each knapsack of weight less than or equal to each knapsack’s capacity and maximize profits associated with adding any two items to the same knapsack.
- Parameters:
values – A list of each item’s value.
weights – A list of each item’s associated weight.
profits – A matrix where entry (i, j) is the value of adding items i and j together.
capacities – A list of the maximum weights each knapsack can hold.
- Returns:
A constrained quadratic model encoding the quadratic multiple knapsack problem. Variables are labelled as
x_{i}_{j}
, wherex_{i}_{j} == 1
means that itemi
is placed in knapsackj
.