Transportation and Assignment Problems
Transportation and Assignment Problems: Balancing, Basic Solutions and Optimal Allocations
The transportation problem
Goods must move from m sources to n destinations. Source i can supply ai units, destination j requires bj units, and shipping one unit from i to j costs cij. Writing xij for the quantity shipped on route (i,j), the problem is
It is an ordinary linear program, but one with so much structure that general-purpose machinery is wasteful. Every coefficient in the constraint matrix is 0 or 1, and every variable appears in exactly two constraints: one row constraint and one column constraint.
Balance, and how to restore it
The equality constraints can only be satisfied simultaneously if
since both sides count the same total shipment. A problem satisfying this is balanced. Real instances usually are not, and the repair is to add a fictitious row or column.
- Excess supply. Add a dummy destination whose demand is the surplus, with unit cost zero on every route into it. Units “shipped” there are simply units left in the warehouse.
- Excess demand. Add a dummy source whose supply is the shortfall, again at zero cost. Units received from it are demand left unmet.
What matters is that the dummy costs are equal, not that they are zero.
The dummy row or column carries a fixed total flow in every feasible solution, the surplus supply, or the shortfall in demand, so charging the same constant k on all of its routes adds the same fixed amount to every feasible allocation.
That shifts the reported total but not the optimizer: the cheapest allocation is the same one it was at zero cost.
Zero is simply the cleanest convention, because it also leaves the reported objective equal to the real shipping cost. Unequal dummy costs can change the optimal allocation by introducing source-specific idle costs or destination-specific shortage costs.
They do not necessarily change it when other costs dominate. Include such differences only when they represent real costs. Such a penalty belongs in the model deliberately, not smuggled in as a shipping rate.
How many variables are basic
There are m+n equality constraints, but they are not independent: summing all the supply equations and all the demand equations gives the same total, so exactly one constraint is redundant. The rank of the system is therefore m+n−1, and a nondegenerate basic feasible solution has
with the remaining mn−(m+n−1) routes carrying nothing. If fewer than m+n−1 routes are positive the solution is degenerate, which is handled by treating some zero-valued route as basic rather than by concluding that something has gone wrong. Note that m+n−1 is counted after balancing, so a dummy row or column raises the count.
Feasible is not optimal
Starting rules such as the northwest-corner method produce a feasible allocation quickly by filling the top-left cell as fully as possible, crossing out the exhausted row or column, and repeating. The method is easy precisely because it ignores the costs entirely, and that is also why it is only a starting point.
Worked example. Two plants supply two customers:
Unit cost | D1 | D2 | Supply |
|---|---|---|---|
S1 | 8 | 5 | 30 |
S2 | 6 | 7 | 50 |
Demand | 45 | 35 | 80 |
Supply and demand both total 80, so the problem is balanced. The northwest-corner rule gives x11=30, then x21=15 and x22=35, at cost
Is that good? Parameterise by x11=t; feasibility forces x12=30−t, x21=45−t, x22=t+5, and the cost becomes
The coefficient of t is positive, so the cost falls as t decreases, and the optimum is at t=0: ship x12=30, x21=45, x22=5, for a cost of 455. The northwest-corner solution was 26% more expensive. The quantity +4 is the net change from rerouting one unit around the cycle S1D1→S1D2→S2D2→S2D1, and testing such cycles is exactly what the transportation simplex does systematically.
Notice that the optimal solution has only three positive routes, matching m+n−1=3.
The assignment problem
Now specialise: n agents, n tasks, each agent takes exactly one task and each task goes to exactly one agent. That is a transportation problem in which every supply and every demand equals 1:
Three adaptations cover almost every practical variant.
- Maximisation. With a profit matrix pij, minimise the opportunity loss cij=M−pij where M is the largest profit. Subtracting every entry from the same constant leaves the ranking of complete assignments unchanged, because each assignment uses exactly n cells and so loses exactly nM.
- Prohibited pairings. Give the forbidden cell a cost so large that no optimal solution would use it, or delete the variable outright.
- Unequal numbers. With more agents than tasks, add dummy tasks at equal cost for every agent. In the base model equal costs are essential: an agent assigned a dummy task is idle, and idleness must not be cheaper for one agent than another unless that is a real feature of the problem. (Subtracting a constant from a whole agent's row, dummy cell included, changes no ranking, so a transformed matrix may show unequal dummy entries without changing the optimum.)
The Hungarian method exploits a simple invariant: subtracting a constant from an entire row or column changes every complete assignment's total by that same constant, so the optimal assignment is unchanged while the reduced matrix accumulates zeros.
When n independent zeros appear, no two sharing a row or column, they mark an optimal assignment, and the total subtracted is the optimal cost.
Why the answers come out whole
The constraint matrix of a transportation problem is totally unimodular: every square submatrix has determinant 0, +1 or −1. By Cramer's rule, every basic solution of such a system with integer right-hand side is integral. So if all supplies and demands are integers, the linear program's optimal vertex is automatically integer-valued, no branch-and-bound, no rounding.
For the assignment problem this is the striking part: the relaxation allows xij anywhere in [0,1], which would in principle permit splitting an agent across tasks, yet an optimal vertex always assigns whole agents to whole tasks.
A method returning an optimal vertex needs no rounding. A fractional optimum can still arise as a mixture of tied optimal vertices, and rounding it directly may destroy feasibility or optimality.
General shortest-path, maximum-flow and minimum-cost-flow algorithms belong to the Network Models concept, and activity scheduling belongs to Project Planning and Control; what is in scope here is formulating these two allocation problems, balancing them, and obtaining and checking small optimal allocations.
A firm has three plants with capacities 45, 60 and 35 units. It serves four customers whose requirements are 30, 50, 25 and 20 units.
The problem is balanced in the standard way before being solved. How many basic variables does a nondegenerate basic feasible solution of the balanced problem have?
Give your answer in basic variables.
A balanced transportation problem has two sources and three destinations, with unit costs, supplies and demands as shown.
Unit cost | D1 | D2 | D3 | Supply |
|---|---|---|---|---|
S1 | 8 | 6 | 3 | 40 |
S2 | 4 | 5 | 9 | 60 |
Demand | 30 | 45 | 25 | 100 |
Apply the northwest-corner rule to obtain an initial basic feasible solution, and calculate its total cost.
Give your answer in cost units.