How to use this calculator
Assign every worker to a different task while minimizing the sum of entered costs.
- Enter Row-major worker task cost matrix, Workers and tasks on each side. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Minimum cost square assignment explained
Find the minimum-cost one-to-one assignment in a square worker-by-task cost matrix.
How the calculation works
Hungarian primal-dual assignment algorithm
The square assignment model chooses one entry in every row and column. A Hungarian primal-dual update adjusts row/column potentials and augments the assignment until all tasks are filled. The reported cost is summed from the original selected entries.
Set up the calculation
a— Row-major worker task cost matrix- Flattened n×n matrix in row-major order: the first n costs are worker 1 across all tasks, the next n are worker 2, and so on. Negative costs are allowed.
n— Workers and tasks on each side- Matrix dimension n; supply exactly n² finite costs, with one task assigned to each worker.
Limits of this model
Square finite matrix with every assignment allowed; negative costs are supported. Use cardinality matching when only compatibility matters.
Check this example
Row-major worker task cost matrix = 4, 1, 3, 2, 0, 5, 3, 2, 2; Workers and tasks on each side = 3.
- Minimum assignment cost: 5 cost units
- Worker-to-task assignment: 1 → 2; 2 → 1; 3 → 3
Selecting worker 1→task 2, worker 2→task 1, and worker 3→task 3 costs 1+2+2=5. No row or column is reused.
Interpreting the result
The assignment uses each worker and task once; a total cost of 5 is the least sum among the square matrix’s one-to-one matchings.
Frequently asked questions
Does each task receive one worker?
Yes.
Can tasks outnumber workers?
This square version needs dummy rows or columns under an appropriate cost convention.
Are tied optima unique?
No, one optimum is returned.
How do I use the Minimum cost square assignment calculator?
Enter Row-major worker task cost matrix, Workers and tasks on each side. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of Minimum cost square assignment?
Row-major worker task cost matrix = 4, 1, 3, 2, 0, 5, 3, 2, 2; Workers and tasks on each side = 3. Minimum assignment cost: 5 cost units Worker-to-task assignment: 1 → 2; 2 → 1; 3 → 3 Selecting worker 1→task 2, worker 2→task 1, and worker 3→task 3 costs 1+2+2=5. No row or column is reused.
Method reference: SciPy linear-sum assignment problem.
Read our calculation methodology.