Skip to content

Assignment Problem Solver

Find the exact minimum-cost one-to-one pairing between equally sized worker and task sets with the deterministic Hungarian algorithm.

Privacy: your files never leave your device. All processing happens locally in your browser.

How to use

  1. 1.Write a header beginning with a comma followed by unique task names.
  2. 2.Add one worker per row with exactly one finite cost for every task, keeping worker and task counts equal.
  3. 3.Run the Hungarian solver, inspect each pairing and cost convention, then copy the exact minimum-cost assignment.

About Assignment Problem Solver

Assignment Problem Solver finds a minimum-cost one-to-one pairing between workers and tasks. Paste a square comma-separated matrix whose first row names the tasks and whose remaining rows name workers followed by their costs. The result lists one task for every worker, the cost of each pairing, and the minimum total. Everything runs locally in the browser and the assignment can be copied as text.

The assignment problem models a complete weighted bipartite graph. One side contains workers, machines, agents, or other resources; the other contains tasks, jobs, locations, or choices. Every matrix cell is the cost of one possible pairing. A valid solution selects exactly one cell from every row and exactly one from every column. Google OR-Tools describes this as minimizing total assignment cost while preventing two workers from taking the same task.

This implementation uses the Hungarian algorithm, also known as the Kuhn–Munkres method. It maintains row and column potentials and repeatedly augments a minimum reduced-cost matching. After all rows are incorporated, every task column points to exactly one worker. The method runs in cubic time for an n by n matrix and returns an exact optimum for the stated complete, square, finite-cost model. Natural row and column order resolves equal-cost choices deterministically.

Enter the matrix with an empty top-left field. A three-task example begins “,Task A,Task B,Task C”; each following line begins with a unique worker name and then exactly three numeric costs. Worker and task counts must match. The current browser bound is 20 by 20, which is small enough for immediate interaction while covering classroom examples and modest scheduling drafts. Costs may be positive, zero, or negative, provided they are finite and within the stated range.

A negative cost can represent a benefit only if that sign convention genuinely fits your model. The solver always minimizes the numeric sum. If your data contains profits or scores to maximize, transform them deliberately or use a maximization model; do not paste scores and assume that “best” automatically means largest. Similarly, blank or forbidden pairings are not supported as missing cells. This version assumes every worker can take every task.

The exact optimum covers only the costs entered. It does not account for skill thresholds, workload capacity, team dependencies, fairness, travel time changes, precedence, multiple tasks per worker, worker availability, or uncertainty unless those effects are already represented correctly. Real staffing decisions may also involve legal, ethical, and human considerations that cannot be reduced to a cost matrix. Treat the result as a transparent mathematical baseline, not an automatic personnel decision.

Eight matrices were independently checked by enumerating every permutation, including 1×1 and 2×2 boundaries, a standard 3×3 example with total cost 5, complete ties, and a cyclic 4×4 zero-cost solution. Tests assert that returned tasks are unique and every worker is assigned. Malformed or rectangular matrices, duplicate names, blanks, NaN, and infinite costs are rejected visibly.

Use this page to verify homework, compare a manual Hungarian calculation, allocate a small set of machines to jobs, or build a reproducible minimum-cost baseline. For larger or constrained schedules, use a validated mixed-integer, constraint-programming, or min-cost-flow solver that explicitly represents all rules, then independently review the final assignment before acting.

Methodology & sources

Parse a complete square matrix of 1–20 uniquely named workers and tasks, validate finite costs, then run the primal-dual Hungarian algorithm with deterministic row/column tie order. Return one unique task per worker, one unique worker per task, and the exact minimum total for the entered matrix.

Frequently asked questions

Does this always find the minimum total cost?
Yes for a complete square matrix of finite costs with exactly one task per worker and one worker per task.
Can I have more workers than tasks?
Not in this version. Add meaningful dummy rows or columns yourself only if their costs correctly represent leaving a worker or task unmatched.
Can I maximize profit instead?
The solver minimizes numbers. Convert profits using a justified transformation or use a model designed for maximization.
Can a cell be forbidden?
There is no blank forbidden-cell feature; every matrix cell must contain a finite cost.

Calculators guides

View all