solve_assignment_problem
Assign tasks to agents while respecting capacity and skill constraints. Optimize for cost, maximum assignments, or balanced load.
Instructions
Solve a task assignment problem.
This is a high-level interface for assignment and matching problems. Use this instead of solve_constraint_model when you need to assign tasks to agents/workers with capacity and skill constraints.
Args: agents: List of agents available to perform tasks, each with: - id (str): Unique agent identifier - capacity (int, optional): Maximum number of tasks (default 1) - skills (list, optional): Skills this agent possesses - cost_multiplier (float, optional): Cost multiplier (default 1.0) - metadata (dict, optional): Additional context tasks: List of tasks to be assigned, each with: - id (str): Unique task identifier - required_skills (list, optional): Skills required for this task - duration (int, optional): Task duration/workload (default 1) - priority (int, optional): Task priority (default 1) - metadata (dict, optional): Additional context cost_matrix: Optional cost matrix where [i][j] = cost to assign task i to agent j. If not provided, uses agent.cost_multiplier * task.duration objective: Optimization goal - 'minimize_cost', 'maximize_assignments', or 'balance_load' force_assign_all: If True, all tasks must be assigned (infeasible if not possible). If False, some tasks can remain unassigned. max_time_ms: Maximum solver time in milliseconds (default 60000)
Returns: SolveAssignmentProblemResponse containing: - status: Solution status - assignments: List of task-to-agent assignments - unassigned_tasks: Tasks that could not be assigned - agent_load: Number of tasks assigned to each agent - total_cost: Total cost of all assignments - solve_time_ms: Actual solve time - optimality_gap: Gap from best bound - explanation: Human-readable summary
Tips for LLMs: - For task assignment: agents are workers/machines, tasks are jobs/work items - For matching: agents are resources, tasks are requests to match - Skills create hard constraints (incompatible if skills don't match) - Use minimize_cost for cost-optimal assignments - Use maximize_assignments when some tasks are optional - Use balance_load to distribute work evenly across agents
Example (Simple Assignment)::
response = await solve_assignment_problem(
agents=[
{"id": "worker_1", "capacity": 2, "cost_multiplier": 1.0},
{"id": "worker_2", "capacity": 2, "cost_multiplier": 1.5},
],
tasks=[
{"id": "task_A", "duration": 3},
{"id": "task_B", "duration": 2},
{"id": "task_C", "duration": 1},
],
objective="minimize_cost"
)
# Returns cost-optimal assignment respecting capacityExample (With Skills)::
response = await solve_assignment_problem(
agents=[
{"id": "dev_1", "capacity": 3, "skills": ["python", "docker"]},
{"id": "dev_2", "capacity": 2, "skills": ["python", "react"]},
],
tasks=[
{"id": "backend", "duration": 5, "required_skills": ["python", "docker"]},
{"id": "frontend", "duration": 4, "required_skills": ["react"]},
],
objective="minimize_cost"
)
# Only assigns tasks to agents with matching skillsExample (Balance Load)::
response = await solve_assignment_problem(
agents=[
{"id": "server_1", "capacity": 10},
{"id": "server_2", "capacity": 10},
{"id": "server_3", "capacity": 10},
],
tasks=[
{"id": f"job_{i}", "duration": 1} for i in range(15)
],
objective="balance_load"
)
# Distributes tasks evenly across servers (5 per server)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tasks | Yes | ||
| agents | Yes | ||
| objective | No | minimize_cost | |
| cost_matrix | No | ||
| max_time_ms | No | ||
| force_assign_all | No |