How the transportation problem is solved
What is the transportation problem?
A company ships a product from m sources (factories, warehouses) to n destinations (shops, customers). Each source has a supply, each destination a demand, and every route has a cost per unit. The transportation problem asks how many units to send along each route so that every demand is met, no supply is exceeded and the total cost is as small as possible.
It is a linear program with a special structure: the constraints form a bipartite network of sources and destinations, so it can also be seen as a minimum-cost flow problem. That structure is what makes the fast table methods below possible.
Finding an initial solution
North-West Corner: start at the top-left cell, ship as much as possible, then move right or down. It ignores the costs, so it is quick but usually far from optimal.
Least Cost: always ship as much as possible through the cheapest cell still open. Vogel’s Approximation Method (VAM): for each open row and column compute a penalty, the difference between its two smallest costs, and serve first the line with the largest penalty, at its cheapest cell. VAM looks ahead at what is lost by not using the cheapest route, and it usually starts very close to the optimum.
Testing and improving: the MODI method
A basic solution has m + n − 1 basic cells. The MODI (modified distribution, or u-v) method gives every row a number u_i and every column a number v_j with u_i + v_j = c_ij on the basic cells, starting from u₁ = 0. For an empty cell, d_ij = c_ij − u_i − v_j is how much the total cost changes per unit sent through it.
If no d_ij is negative, the plan is optimal. Otherwise the most negative cell enters: its stepping-stone loop alternates + and − through basic cells, the smallest amount on a − cell (θ) is moved around the loop, and that cell leaves the basis. The stepping-stone method finds the same loops but prices every empty cell by walking its loop; MODI gets all the prices at once.
Unbalanced problems, maximization, forbidden routes and degeneracy
If total supply and total demand differ, a dummy destination (or source) with cost 0 absorbs the difference. A profit problem is turned into a cost problem by subtracting every profit from the largest one. A route that cannot be used gets the cost M, a number larger than any other, so it is avoided whenever possible.
When an allocation uses up a supply and a demand at the same time, the solution has fewer than m + n − 1 positive cells: it is degenerate. A basic cell with 0 (often written ε) is kept so that MODI still works, and a loop may then move θ = 0.
Related problems
The assignment problem is the special case where every supply and demand is 1; the Hungarian method solves it faster. Both are minimum-cost flow problems, and both can be written as linear programs for the simplex method.
Frequently asked questions
Which initial method should I use?
Vogel’s Approximation Method usually gives the best start, often optimal or within a few MODI iterations. The North-West Corner rule is the easiest to compute by hand but ignores costs. The calculator lets you pick any of the three and always finishes with MODI, so the final answer is the same optimum.
How do you solve an unbalanced transportation problem?
Add a dummy destination when supply exceeds demand, or a dummy source when demand exceeds supply, with a cost of 0 on its routes. Units sent to the dummy destination stay at their source; units from the dummy source are demand that is not met. The calculator adds the dummy automatically.
What is a degenerate solution?
A basic solution with fewer than m + n − 1 positive allocations. It happens when a supply and a demand run out at the same moment. The calculator keeps a basic cell with 0 in the table so that the u and v values can still be computed.
Is the MODI method the same as the stepping-stone method?
They reach the same optimum with the same loops. The stepping-stone method finds the cost change of each empty cell by tracing its loop; MODI computes all of them at once from the u and v values, which is faster for larger tables.
How large can the problem be?
Up to 8 sources and 8 destinations, which covers textbook and exam problems while keeping every table readable.