Knapsack Select
knapsack_selectChoose the items that maximise value under one or more capacity limits. FREE.
Typical input {"items": [{"id": "a", "value": 60, "weight": 10, "cost": 120}, {"id": "b", "value": 100, "weight": 20, "cost": 300}], "limits": {"weight": 25, "cost": 400}} returns {"selected": ["a"], "value": 60, "used": {"weight": 10, "cost": 120}, "slack": {"weight": 15, "cost": 280}, "solver_status": "OPTIMAL"}. Any numeric item field named in limits is a constrained resource; qty lets an item be taken several times. Use for budgets, cargo, campaign or feature selection. Not for dependencies between items. Errors: on invalid, missing, or malformed input this tool never raises a protocol error — it returns {"error": ""} (for example {"error": "items must be a non-empty list of "}). Every call is read-only and idempotent, so after correcting the input it is always safe to retry.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| items | Yes | {id, value, qty, <resource fields>}: value to maximise plus one number per limited resource. | |
| limits | Yes | {resource_name: capacity} for each constrained field. | |
| time_limit_s | No | solver time budget in seconds (default 3, max 15). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||