To solve an unbalanced assignment problem, add meaningful dummy rows or columns until the matrix is square, then apply the Hungarian method to find the minimum-cost one-to-one pairing.

An unbalanced problem has different numbers of workers and tasks. The original matrix is not invalid; it simply cannot be entered directly into a square-matrix assignment solver. Preserve the original assignments and costs, add only the slots needed to represent unmatched workers or tasks, and solve the balanced matrix.

how to solve unbalanced assignment problem
How to Solve Unbalanced Assignment Problems

What an unbalanced matrix means

Let W be the number of workers and T the number of tasks. A standard assignment model pairs every worker with one task while preventing two workers from receiving the same task. When W and T differ, one side needs temporary dummy slots before the standard algorithm can be used.

Original matrix Balancing action Meaning of the dummy slots
Equal numbers of workers and tasks Add nothing The complete square matrix can be solved directly.
More workers than tasks Add W − T dummy task columns A surplus worker can receive a dummy task, representing an unmatched worker.
More tasks than workers Add T − W dummy worker rows A surplus task can receive a dummy worker, representing an unmatched task.

The direction of the dummy addition matters because rows represent workers and columns represent tasks. A rectangular matrix is not merely a shortened square problem; the current solver rejects rectangular input because its exact Hungarian implementation assumes equally sized sets and a complete square matrix.

Set the dummy costs deliberately

A dummy is part of the mathematical model, not a cosmetic placeholder. Its cost should express what happens when a worker or task remains unmatched.

  • Zero-cost dummy: Use zero when leaving the surplus unit unmatched has no cost or benefit in the objective.
  • Penalty dummy: Use a finite penalty when leaving a worker or task unmatched has an opportunity cost. Different dummy slots can carry different values when the model permits that.
  • Maximization dummy: If the original objective rewards profit or another score, transform the objective deliberately and set dummy values to match the intended treatment of unmatched units.

Do not insert blanks to represent an impossible pairing. The solver requires a finite number in every cell. Dummy slots also do not solve a genuine resource shortage: if every worker must receive a real task, or every task must be staffed by a real worker, a dummy assignment exposes an infeasibility rather than resolving it.

Balance and solve the assignment matrix

  1. Record the original counts. Count the worker rows and task columns before making changes. Decide which side is larger and whether unmatched workers, unmatched tasks, or both are permitted.
  2. Choose the unmatched outcome. Determine the objective cost of leaving a surplus unit unpaired. Do not assume that zero is correct in every model.
  3. Add the exact number of dummy slots. Add one dummy task column for every surplus worker, or one dummy worker row for every surplus task. Keep the original cells unchanged.
  4. Format the labelled matrix. Begin the first row with a comma followed by unique task names, such as ,Task A,Task B. Begin every remaining row with a unique worker name, followed by exactly one cost for each task.
  5. Validate the completed matrix. Confirm equal row and column counts, an empty top-left field, unique names, and one finite numeric cost in every cell within the accepted range. Blanks, duplicate names, NaN, infinite values, malformed input, and rectangular matrices are rejected visibly. The browser version accepts dimensions from 1 by 1 through 20 by 20, including any dummy rows or columns.
  6. Run the solver and inspect the result. Open the Assignment Problem Solver, paste the completed matrix, and run the Hungarian solver. The result lists one task for every worker, the cost of each pairing, and the minimum total.
  7. Check the direction before copying. Confirm that the numbers are costs to be minimized rather than profits to be maximized. After checking every displayed pairing and the cost convention, copy the exact minimum-cost assignment as text and retain the input matrix for reproducibility.

The solver uses the primal-dual Hungarian method: it maintains row and column potentials and repeatedly augments a minimum reduced-cost matching until all task columns are assigned. Kuhn’s original paper on the Hungarian method explains the underlying algorithm, while Google OR-Tools’ assignment documentation describes the same one-to-one minimum-total-cost modeling pattern.

Worked example: more tasks than workers

Suppose two workers must cover three tasks. The original costs for Task X, Task Y, and Task Z are 4, 2, and 5 for Worker A, and 1, 6, and 3 for Worker B. Because there is one surplus task, add one dummy worker. Leaving that task unmatched has no penalty, so use zero in each dummy cell.

The completed square input is:

  • Header: ,Task X,Task Y,Task Z
  • Worker A: Worker A,4,2,5
  • Worker B: Worker B,1,6,3
  • Dummy Worker: Dummy Worker,0,0,0

The minimum pairing assigns Worker A to Task Y, Worker B to Task X, and the dummy worker to Task Z. The total is calculated as c(A,Y) + c(B,X) + c(Dummy,Z) = 2 + 1 + 0 = 3. In operational terms, Workers A and B cover Tasks Y and X, while Task Z remains unmatched. If every task must be covered by a real worker, this result reveals that two workers are insufficient.

Check the optimum before using it

A valid output should satisfy several checks beyond the displayed total:

  • Coverage: Every row receives one task and every column receives one worker.
  • Direction: A smaller total is preferred only when the entries represent costs. Negative values are still included in the sum.
  • Dummy interpretation: Identify which pairings represent unmatched workers or tasks rather than real assignments.
  • Cost reproduction: Add the displayed pairing costs and confirm that they reproduce the reported minimum total.
  • Tie handling: Equal-cost choices are resolved deterministically by natural row and column order. A deterministic answer does not mean the mathematical optimum is unique.

The exact optimum covers only the costs entered and the stated square, complete model. It does not imply that factors omitted from the matrix have been evaluated.

Match the matrix to the decision rules

Before accepting the pairing, compare the structure of the data with the rules that actually govern the decision:

Decision requirement Matrix treatment Important limitation
Minimize actual cost Enter a finite cost for every possible worker-task pair. The solver always minimizes the numeric sum.
Maximize profit or score Transform the values into a justified cost before solving. Pasting raw scores would incorrectly favor smaller scores.
Forbid a specific pairing The solver has no blank forbidden-cell feature. A finite penalty can discourage a pairing if justified. A penalized pair is still mathematically available, so verify that it was not selected.
Account for skills, capacity, availability, or workload Represent each factor correctly in the cost model when a single numeric cost can do so. Several rules require an explicit constrained model rather than a plain assignment matrix.

For a fixed number of real assignments, profit maximization can be converted to cost minimization with a relationship such as C = M − P, where P is profit and M is at least the maximum possible profit. The transformation and dummy treatment must both match the original objective. See the maximization assignment workflow for a focused explanation. A negative cost can also represent a benefit, but only when that sign convention genuinely fits the model.

When to use a more advanced solver

The browser solver is a transparent baseline for complete square matrices up to 20 by 20 after balancing. It does not automatically account for skill thresholds, workload capacity, team dependencies, fairness, changing travel times, precedence, multiple tasks per worker, availability, or uncertainty. Real staffing decisions may also involve legal, ethical, and human considerations that cannot be reduced to numeric costs.

For a larger or constrained schedule, use a validated mixed-integer, constraint-programming, or min-cost-flow solver that explicitly represents every rule. Independently review the final assignment before acting, and treat the minimum-cost result as a mathematical baseline rather than an automatic personnel decision.

Related reading: Bin Packing Problem: How the Minimum-Bin Objective Works.