How this calculation works
The assignment problem pairs items from two sets while minimizing the total cost of the selected pairs. Each row and column can appear at most once. This calculator accepts a rectangular matrix and requires a full assignment of the smaller side, leaving unmatched items on the larger side without inventing a penalty. It uses exact integer subset dynamic programming to compare all supported assignments and keeps the chosen row-column pairs. Forbidden entries are absent options, not large artificial costs that could accidentally be selected.
Minimize Σ cᵢⱼxᵢⱼ with xᵢⱼ∈{0,1}; use each row and column at most once and match every item on the smaller side.A worked example
For cost rows (4,1,3), (2,0,5) and (3,2,2), choose row one to column two at cost one, row two to column one at cost two and row three to column three at cost two. Total cost is five. Greedily assigning the cheapest entry first would choose row two to column two at cost zero, potentially forcing costlier remaining pairs. The optimal solution evaluates the effect of each allocation on the options left for every other row.
Good to know
Supports integer cost matrices from 1×1 through 12×12, with each cost within ±1,000,000. Use X to forbid a pair. Negative and zero costs are valid. The smaller side must be completely matched; an instance without enough permitted disjoint pairs is infeasible. A larger side can remain partly unmatched, but no dummy penalty is assumed. Returns one optimum, not all tied assignments. Capacitated tasks, many-to-one allocations, side constraints and general integer scheduling are outside this one-to-one model.
Reference: SciPy — rectangular linear sum assignment (opens in a new tab) ↗
A cheap local pair can block a better global allocation
Selecting one pair consumes both its row and column. A locally cheap entry therefore changes which combinations remain feasible. The dynamic program records the best cost for each occupied-column subset after processing a given number of smaller-side items. Two partial assignments with the same occupied subset have the same remaining options, so only the cheaper partial cost must be retained for that state.
When there are more rows than columns, the calculation transposes its internal viewpoint so the smaller side still drives the stages. The output maps selected pairs back to the original row and column labels. This is an algorithmic convenience, not permission to change what a worker or task means. The explicit unmatched-row and unmatched-column lists help check the original rectangular interpretation after the optimum is reconstructed.
Forbidden pairs and unmatched penalties are different modeling choices
An X entry means that pair is unavailable. A very large numeric cost instead permits it when every alternative is even worse or impossible. Confusing those meanings can produce an apparently valid assignment that violates a real restriction. This page does not manufacture a cost for leaving a larger-side item unmatched; if that choice has a substantive penalty, the model needs explicit dummy items or another formulated optimization problem.
Negative costs can represent benefits under a consistent sign convention and do not cause unboundedness because a finite number of one-to-one pairs is selected. Equal totals can produce several optimal assignments, so a different pair list is not automatically wrong when its feasibility and total match. The Maximum bipartite matching calculator from an edge list instead maximizes the number of permitted pairs without comparing their costs. The two objectives can select different matchings even on the same underlying relation.
A few questions, answered
What happens when there are more tasks than workers?
Every worker is assigned once when workers form the smaller side. Some task columns remain unused, and their labels are listed explicitly.
Can two workers share the same task?
Not in this one-to-one model. Use a capacitated flow or a differently formulated program when one task can accept several assignments.