Skip to main content
Glama

mcp-optimizer

solve_knapsack_problem_tool

Optimize selection of items to maximize value within weight or volume constraints using OR-Tools. Ideal for cargo loading, portfolio selection, resource allocation, advertising planning, menu planning, and inventory management.

Instructions

Solve knapsack optimization problems using OR-Tools.

This tool solves knapsack problems where items need to be selected to maximize value while staying within capacity constraints. Use cases: - Cargo loading: Optimize loading of trucks, ships, or planes by weight and volume - Portfolio selection: Choose optimal set of investments within budget constraints - Resource allocation: Select projects or activities with limited budget or resources - Advertising planning: Choose optimal mix of advertising channels within budget - Menu planning: Select dishes for a restaurant menu considering costs and popularity - Inventory optimization: Decide which products to stock in limited warehouse space Args: items: List of items, each with 'name', 'value', 'weight', and optionally 'volume', 'quantity' capacity: Weight capacity constraint volume_capacity: Volume capacity constraint (optional) knapsack_type: Type of knapsack problem ('0-1', 'bounded', 'unbounded') max_items_per_type: Maximum items per type for bounded knapsack Returns: Knapsack result with total value and selected items Example: # Select items to maximize value within weight limit solve_knapsack_problem( items=[ {"name": "Item1", "value": 10, "weight": 5, "volume": 2}, {"name": "Item2", "value": 15, "weight": 8, "volume": 3}, {"name": "Item3", "value": 8, "weight": 3, "volume": 1} ], capacity=10, volume_capacity=5 )

Input Schema

NameRequiredDescriptionDefault
capacityYes
itemsYes
knapsack_typeNo0-1
max_items_per_typeNo
volume_capacityNo

Input Schema (JSON Schema)

{ "properties": { "capacity": { "title": "Capacity", "type": "number" }, "items": { "items": { "additionalProperties": true, "type": "object" }, "title": "Items", "type": "array" }, "knapsack_type": { "default": "0-1", "title": "Knapsack Type", "type": "string" }, "max_items_per_type": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Max Items Per Type" }, "volume_capacity": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "title": "Volume Capacity" } }, "required": [ "items", "capacity" ], "type": "object" }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dmitryanchikov/mcp-optimizer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server