Skip to main content
Glama
IBM
by IBM

solve_constraint_model

Define decision variables, constraints, and objectives to find feasible or optimal solutions for scheduling, resource allocation, puzzles, and more.

Instructions

Solve a general constraint or optimization model.

This tool solves discrete optimization and constraint satisfaction problems. It supports integer and boolean variables, linear constraints, global constraints (all_different, element, table), implications, and linear objectives.

Use cases include:

  • Project scheduling and resource allocation

  • Sudoku and logic puzzles

  • Configuration optimization

  • Tool/model selection under constraints

  • Routing and assignment problems

  • Budget allocation

Args: mode: Solver mode - 'satisfy' to find any feasible solution, 'optimize' to find the best solution according to the objective. variables: List of decision variables, each with: - id (str): Unique identifier - domain (dict): Domain specification with: - type (str): 'bool' or 'integer' - lower (int): Lower bound for integers (default 0) - upper (int): Upper bound for integers (default 1) - metadata (dict, optional): Context for explanations constraints: List of constraints, each with: - id (str): Unique identifier - kind (str): Constraint type - 'linear', 'all_different', 'element', 'table', or 'implication' - params (dict): Constraint-specific parameters: For 'linear': terms (list of {var, coef}), sense ('<=', '>=', '=='), rhs (number) For 'all_different': vars (list of variable ids) For 'element': index_var (str), array (list of int), target_var (str) For 'table': vars (list of str), allowed_tuples (list of lists) For 'implication': if_var (str), then (nested constraint dict) - metadata (dict, optional): Description and context objective: Optional objective function (required if mode='optimize'): - sense (str): 'min' or 'max' - terms (list): Linear terms as {var, coef} - metadata (dict, optional): Description search: Optional search configuration: - max_time_ms (int): Maximum solver time in milliseconds - max_solutions (int): Maximum solutions to return (default 1)

Returns: SolveConstraintModelResponse containing: - status: 'optimal', 'feasible', 'satisfied', 'infeasible', 'unbounded', 'timeout', or 'error' - objective_value: Objective value if applicable - solutions: List of solutions with variable assignments - explanation: Human-readable summary and binding constraints

Tips for LLMs: - Start with a small model to test; gradually add complexity. - For Sudoku: use 'all_different' constraints for rows, columns, and blocks. - For scheduling: use linear constraints for precedence and capacity. - Variable metadata is useful for building readable explanations. - Constraint metadata helps identify which constraints are tight. - If infeasible, check constraint metadata to diagnose conflicts. - Use 'satisfy' mode for puzzles; 'optimize' mode for cost/time minimization.

Example (simple knapsack): python response = await solve_constraint_model( mode="optimize", variables=[ {"id": "take_item_1", "domain": {"type": "bool"}}, {"id": "take_item_2", "domain": {"type": "bool"}}, ], constraints=[ { "id": "capacity", "kind": "linear", "params": { "terms": [ {"var": "take_item_1", "coef": 3}, {"var": "take_item_2", "coef": 5}, ], "sense": "<=", "rhs": 7, }, } ], objective={ "sense": "max", "terms": [ {"var": "take_item_1", "coef": 10}, {"var": "take_item_2", "coef": 15}, ], }, )

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeYes
searchNo
objectiveNo
variablesYes
constraintsYes
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description fully discloses the tool's behavior: it supports discrete optimization with integer/bool variables, multiple constraint types, and linear objectives. It explains return statuses and provides tips for interpretation. It does not explicitly state whether the tool is read-only or has side effects, but the nature of solving implies no state mutation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-organized with clear sections (intro, use cases, args, returns, tips, example). Every sentence adds value, no redundancy. Despite length, it is front-loaded with purpose and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (5 parameters, nested objects, no output schema), the description covers all input details, return fields, and provides practical tips. It is sufficient for an agent to use the tool correctly without external references.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, yet the description completely explains all parameters, including nested structures (variables, constraints, objective, search). Each constraint kind has detailed param specs, and an example illustrates usage. This fully compensates for the lack of schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states 'Solve a general constraint or optimization model' and lists diverse use cases (scheduling, puzzles, assignment, routing). This clearly differentiates it from sibling tools that target specific problems like scheduling or routing, establishing a clear general-purpose scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use 'satisfy' vs 'optimize' modes, tips for diagnosing infeasibility, and examples. However, it does not explicitly mention when to prefer sibling specialized tools (e.g., solve_scheduling_problem) over this general solver, leaving the decision to the agent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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/IBM/chuk-mcp-solver'

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