Assignment Problem (Hungarian) Calculator

Enter the 3×3 cost matrix to find the minimum-cost assignment.

How it is calculated

The tool solves a fixed 3×3 problem: three agents A, B and C, three tasks 1, 2 and 3, and nine costs cij where i is the agent and j the task. Each agent gets exactly one task and each task goes to exactly one agent, which gives 3! = 6 possible matchings. The tool adds up the three costs of every matching, total = cA,p(A) + cB,p(B) + cC,p(C), and returns the smallest. It tries every case, so the answer matches what the Hungarian method gives for this size. If two matchings tie, the first in the tool's fixed order is shown. It always minimises, and all nine cells must be filled. Costs can be any numbers, including negative ones or decimals.

Worked example

Costs for agents A, B, C across tasks 1, 2, 3: A is 14, 9, 11; B is 8, 12, 10; C is 13, 7, 15. The six matchings cost 41 (A1 B2 C3), 31 (A1 B3 C2), 32 (A2 B1 C3), 32 (A2 B3 C1), 26 (A3 B1 C2) and 36 (A3 B2 C1). The lowest is 26. The tool shows a total of 26.00 with the assignment A→3, B→1, C→2: 11 + 8 + 7 = 26. A takes task 3 although its cheapest cell is task 2, because C needs task 2 more.

Try this example →

Common mistakes

  • Taking each agent's cheapest task independently. In this example A would pick task 2 and C would also want task 2, so the choices clash; the true optimum accepts a higher cost for A.
  • Entering profits and expecting the best match. The tool minimises; to maximise, enter each profit as a negative number, or subtract each from the largest value.
  • Trying a 4×4 or a rectangular matrix. This tool is fixed at 3 agents and 3 tasks.
  • Leaving a cell blank for a forbidden pair. All nine cells are required; use a very large cost to make a pair practically impossible.
  • Reading the A→3 notation as a time or a count. It means agent A is assigned to task 3.

About this calculator

The assignment problem asks: given a set of agents and a set of tasks, each with a different cost depending on who does what, how do you match every agent to exactly one task so the total cost is as small as possible? For a 3×3 cost matrix, this calculator finds the optimal answer by evaluating all 6 possible permutations of assignments — the same optimal result the more scalable Hungarian algorithm (developed by Harold Kuhn in 1955, building on work by Hungarian mathematicians König and Egerváry) would produce for larger matrices in polynomial time.

This is a foundational problem in operations research and combinatorial optimization, with direct applications in assigning workers to jobs, machines to production orders, delivery drivers to routes, or students to project teams so as to minimize total cost or maximize total efficiency. Logistics planners, HR schedulers, and computer scientists studying bipartite matching all encounter this exact problem.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    If you have fewer agents than tasks, pad the matrix with a dummy agent whose costs are all zero. Whichever task the dummy lands on is simply left undone, and the real agents get the cheapest feasible split. With more agents than tasks, add a dummy task column of zeros instead. The tool stays limited to three by three. What kind of assignment problem are you working on?

Popular calculators

All Calculators