A maximization assignment problem is solved exactly by converting profits to costs and applying the Hungarian method to the resulting square matrix.
The goal remains unchanged: assign every worker to exactly one task and every task to exactly one worker while maximizing the total profit. Converting the objective does not relax those one-to-one constraints; it only reverses the numerical direction so a minimum-cost Hungarian solver can find the maximum-profit pairing.

Change the objective without changing the assignment
If the matrix contains profits, scores, benefits, or other values for which a larger number is preferable, do not enter those values into a minimum-cost solver unchanged. The solver would interpret the largest number as the worst possible cost.
Conversion formula: Find the largest profit in the matrix, call it Pmax, and replace every profit p(i,j) with a cost calculated as c(i,j) = Pmax - p(i,j).
Every feasible assignment selects exactly n matrix cells when the problem has n workers and n tasks. Its transformed total therefore satisfies:
Total converted cost = n × Pmax - total original profit.
Because n × Pmax is the same for every feasible assignment, minimizing the converted cost is mathematically equivalent to maximizing the original profit. The pairing with the smallest transformed total is the pairing with the largest profit total.
Negating each profit, using c(i,j) = -p(i,j), is another valid conversion because the solver accepts negative finite costs. In that form, the maximum profit equals the negative of the minimum transformed total. The Pmax conversion is often easier to audit because every resulting cost is nonnegative.
This one-to-one structure is the standard assignment model described in the Google OR-Tools assignment documentation. The important point is that the objective and the constraints are separate: changing a profit into a cost changes only how the solver ranks solutions.
Prepare a complete square profit matrix
Before converting the values, arrange the alternatives so each worker is a row and each task is a column. Each interior cell represents the profit from assigning that row’s worker to that column’s task.
- Use the same number of workers and tasks so the matrix is square.
- Give every worker and task a unique name.
- Place one finite numeric profit in every worker-task cell.
- Use values with the same unit and an additive meaning, such as dollars, points, or expected benefit.
- Keep the matrix within the browser tool’s current limit of 20 workers and 20 tasks.
| Model requirement | Required format | Reason it matters |
|---|---|---|
| Objective | Convert each profit to c(i,j) = Pmax - p(i,j) | Makes a maximization problem compatible with a minimum-cost solver |
| Matrix shape | Square, with equal worker and task counts | Supports exactly one assignment per worker and per task |
| Names | Unique worker and task names | Allows every returned pairing to be identified clearly |
| Cell values | One finite number in every cell | Blanks, NaN, and infinite costs are not supported |
| Input size | From 1 × 1 through 20 × 20 | Matches the current browser operating limit |
A forbidden pairing cannot be represented by leaving a cell blank in this solver. Every cell must contain a finite value. Similarly, an unequal number of workers and tasks is outside the verified model; dummy rows or columns should be added only when their costs correctly represent leaving a worker or task unmatched.
Run the converted profit matrix
- Confirm the objective. Decide whether the original numbers are costs or values to maximize. For profits or scores, identify Pmax and apply c(i,j) = Pmax - p(i,j) to every interior cell.
- Open the Assignment Problem Solver. The calculation runs locally in your browser, so the matrix does not need to be sent to a remote service.
- Write the task header. Begin the first row with a comma, leave the top-left field empty, and follow it with the unique task names. For example, the header can be ,Task A,Task B,Task C.
- Add one row for each worker. Begin every row with that worker’s unique name, followed by exactly one converted cost for every task in header order. Keep the number of worker rows equal to the number of task columns.
- Run the Hungarian solver. The solver validates the square matrix and applies the deterministic Hungarian method to find the minimum-cost one-to-one assignment.
- Inspect every pairing and the cost convention. Confirm that each worker has one task, each task appears once, and the displayed total is the sum of the converted costs rather than the original profits.
- Copy and translate the result. Copy the exact minimum-cost assignment as text. For the Pmax conversion, recover the maximum original profit with maximum profit = n × Pmax - minimum converted cost.
Understand what the Hungarian step does
The Hungarian method does not greedily choose the largest value in each row. It maintains row and column potentials and repeatedly augments a minimum reduced-cost matching until every worker and task is included in one complete pairing. This is what allows it to find the globally best assignment under the stated model rather than merely a locally attractive combination.
The implementation returns an exact optimum for a complete, square matrix with finite costs. It runs in cubic time for an n-by-n matrix, so the current 20-by-20 browser bound keeps the interaction immediate. For a manual explanation of reductions, covering, and augmenting steps, use Solve Assignment Problem by Hungarian Method. The method’s original mathematical treatment is presented in Kuhn’s Hungarian-method paper.
Check the conversion with a small example
Consider three workers—Ana, Ben, and Cara—and three tasks—A, B, and C. In the order A, B, C, their original profits are:
- Ana: 8, 5, 4
- Ben: 6, 8, 3
- Cara: 7, 4, 10
The largest profit is Pmax = 10. Applying c(i,j) = 10 - p(i,j) produces these converted costs:
- Ana: 2, 5, 6
- Ben: 4, 2, 7
- Cara: 3, 6, 0
The Hungarian solver returns Ana to Task A, Ben to Task B, and Cara to Task C. Its converted total is 2 + 2 + 0 = 4. The original profit is 8 + 8 + 10 = 26, which agrees with the conversion identity 3 × 10 - 4 = 26.
Read and verify the returned assignment
The result provides one task for every worker, the cost of each pairing, and the minimum total. Review the output rather than assuming that a successful calculation captures every practical concern.
- Check that the worker names and task names in the result match the intended labels.
- Verify that no task is assigned twice and that no worker receives more than one task.
- Add the displayed pairing costs to confirm that they match the reported minimum total.
- Use the conversion formula to confirm that the corresponding profit total has the expected direction.
- Copy the assignment if it passes the review.
When several assignments have the same optimal total, natural row and column order resolves equal-cost choices deterministically. That makes the result reproducible, although it does not mean every tied solution is equally desirable in practice.
Recognize the limits of the cost matrix
The exact result applies only to the complete, square, finite-cost model that was entered. The solver assumes every worker can take every task. It does not automatically enforce skill thresholds, workload capacity, team dependencies, fairness, changing travel times, precedence rules, multiple tasks per worker, worker availability, or uncertainty.
Those effects must be represented correctly in the matrix before solving, or they must be handled by a more constrained model. A mathematical optimum is also not automatically a sound personnel decision. Legal, ethical, contractual, and human considerations may require an independent review before anyone is assigned.
Move to a richer model when rules are missing
For larger schedules, hard skill restrictions, capacity limits, forbidden pairings, availability constraints, or multiple assignments per worker, use a validated mixed-integer, constraint-programming, or min-cost-flow solver that explicitly represents those rules.
For an unbalanced problem, meaningful dummy rows or columns may be possible, but their values must represent the real cost of leaving a party unmatched. For a forbidden pair, this assignment tool has no hard blank-cell feature; a finite penalty is only appropriate if it faithfully represents the model and cannot distort the optimum. Either way, independently validate the final assignment and review it before applying the result operationally.