solve_knapsack
Maximize item value under a weight capacity constraint by solving the 0/1 knapsack problem. Provide item values, weights, and capacity to get the optimal selection.
Instructions
Solve the classic 0/1 knapsack problem: maximize value subject to weight capacity constraint.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"values": "<values>",
"weights": "<weights>",
"capacity": "<capacity>"
},
"name": "solve_knapsack"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| values | Yes | Value of each item | |
| weights | Yes | Weight of each item | |
| capacity | Yes | Maximum weight capacity of the knapsack |