Assignment hungarian solve
assignment-hungarian-solve · version 1.0.0 · Optimization & voting · free, no key needed
Solve a bounded rectangular integer minimum-cost assignment with explicit unmatched costs.
Use when you need to: solve minimum cost assignment · run Hungarian assignment · assign rows to columns.
Decide before calling
Read the versioned contract and the supported scope below. Reuse assignment-hungarian-solve@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use assignment-hungarian-solve@1.0.0 for solve minimum cost assignment. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- solve minimum cost assignment
- run Hungarian assignment
- assign rows to columns
- optimize rectangular matching
- compute bipartite assignment
- handle unmatched assignment rows
- find deterministic optimal matching
Not supported
- maximum-weight matching without cost conversion
- capacitated or many-to-one assignment
Behavior
- An r-by-c input becomes an (r+c)-square assignment: c dummy rows charge unmatched column costs, r dummy columns charge unmatched row costs, and dummy-to-dummy edges cost zero.
- Among equal-cost solutions, the public row-to-column sequence is lexicographically smallest, with real columns before the null unmatched choice.
- The returned total is an exact safe integer; an unsafe total is rejected instead of rounded.
Input
costs(array of array of integer, required): max items 20; each max items 20; each each min -9007199254740991; each each max 9007199254740991unmatched_row_cost(integer, required): min -9007199254740991; max 9007199254740991unmatched_column_cost(integer, required): min -9007199254740991; max 9007199254740991
Output
assignments(array of object, required): max items 20unmatched_columns(array of integer, required): max items 20; each min 0; each max 19total_cost(integer, required): min -9007199254740991; max 9007199254740991
Limits
- max dimension: 20
- max abs cost: 9007199254740991
Example
Request input:
{
"costs": [
[
4,
1
],
[
2,
3
]
],
"unmatched_row_cost": 9,
"unmatched_column_cost": 9
}
Response:
{
"result": {
"assignments": [
{
"row": 0,
"column": 1,
"cost": 1
},
{
"row": 1,
"column": 0,
"cost": 2
}
],
"unmatched_columns": [],
"total_cost": 3
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "assignment-hungarian-solve",
"version": "1.0.0",
"input": {
"costs": [
[
4,
1
],
[
2,
3
]
],
"unmatched_row_cost": 9,
"unmatched_column_cost": 9
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/assignment-hungarian-solve/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"costs":[[4,1],[2,3]],"unmatched_row_cost":9,"unmatched_column_cost":9}'
The machine-readable contract is at /v1/tools/assignment-hungarian-solve/versions/1.0.0.
CLI
node cli.mjs run assignment-hungarian-solve 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Knapsack 01 solve: Solve bounded 0/1 knapsack exactly and return the optimum value, weight, and lexicographically smallest index list.
- Pareto front find: Find stable nondominated row indices and a domination witness for every excluded row using exact rational criteria.
- Vote condorcet winner: Compute weighted pairwise counts, a strict Condorcet winner, and the generalized Smith set.
- Rank borda aggregate: Aggregate weighted complete or partial rankings into exact Borda scores, rank groups, and audit contributions.
- Round robin schedule generate: Generate a deterministic single or double round-robin schedule with ordered rounds, home/away assignments, and byes.