Minimizes the cost of shipping a single commodity from m supply points to n demand points, given a per-unit shipping cost cij for every supply-demand pair.
minimize z=i=1∑mj=1∑ncijxij
Subject to:
∑j=1nxij≤ai for every supply point i (supply capacity)
∑i=1mxij≥bj for every demand point j (demand requirement)
xij≥0
Variations
Balanced
Total supply equals total demand: ∑iai=∑jbj. Every constraint becomes an equality.
A feasible solution exists iff the problem is balanced.
A balanced transportation problem with m supply and n demand points has m+n−1 basic variables in any basic feasible solution (BFS).
Unbalanced
Total supply and demand differ. Add a dummy supply point (if demand exceeds supply) or a dummy demand point (if supply exceeds demand) with 0 shipping cost, absorbing the excess, to rebalance it.
Maximization
Convert to an equivalent minimization problem by negating every cost cij (or subtracting each from the largest cost in the matrix), then solve as usual.
Restricted
A route is prohibited (e.g. no road between a supply and demand point). Assign it a very large cost M, which drives xij to 0 in any optimal solution.
Transportation Table
A transportation table lays out a transportation problem as a grid: one row per supply point, one column per demand point.
Conventions:
Cell (i,j) carries the shipping cost cij and the allocation xij.
The rightmost column holds each row’s supply ai.
The bottom row holds each column’s demand bj.
A cell is occupied when xij>0, unoccupied otherwise.
Example, unsolved (only the costs, supply, and demand are known):
D1
D2
D3
Supply
O1
4
6
8
20
O2
3
5
2
70
O3
3
9
6
25
Demand
30
25
20
Total supply is 115, total demand is 75: unbalanced.
Loop
A closed path of occupied cells (plus a chosen unoccupied cell) that alternates horizontal and vertical moves, turning only at occupied cells, and returns to the unoccupied cell. Exactly one such loop exists for a given unoccupied cell in a non-degenerate BFS.
Degenerate BFS
A BFS is non-degenerate when it has exactly m+n−1 positive allocations. Every unoccupied cell then has exactly 1 loop, and the stepping stone method computes every improvement index directly.
A BFS is degenerate when an allocation exhausts a row and a column simultaneously before all supply/demand is used, leaving fewer than m+n−1 positive allocations. Add a 0 allocation to an unoccupied cell (chosen so the solution stays a basic feasible solution) to restore the count. From then on the 0-allocated cell counts as occupied for tracing loops, even though it ships nothing.
Degeneracy can also appear mid-solution: if a stepping stone pivot ties 2 or more − cells at the same minimum allocation, only 1 leaves the basis, but every tied cell drops to 0, again leaving fewer than m+n−1 positive allocations.
An allocation to a dummy row or column represents unmet demand or unused supply rather than an actual shipment, since its cost is 0. It is still an ordinary basic variable: it counts toward m+n−1, and it participates in loops like any other occupied cell.
Solving Transportation Method
To construct an initial BFS, there are 2 methods. Only 1 is needed to proceed to the stepping stone method.
Least Cost Method
Step:
Allocate as much as possible to the cell with the lowest cost in the matrix.
A tie in the lowest cost is broken by choosing the cell allowing the larger allocation.
Cross out the exhausted row or column.
Repeat on the remaining cells until fully allocated.
Vogel’s Approximation Method
Penalty is the difference between the lowest and second-lowest cost in it.
Steps:
For every remaining row and column, compute the penalty.
Select the row or column with the largest penalty.
A tie is broken by choosing the row or column whose lowest-cost cell allows the larger allocation. If still tied, choose the one with the lower cost in that cell. If that also ties, choose the lowest-indexed row or column.
Allocate as much as possible to its lowest-cost cell in the chosen row or column.
Cross out the exhausted row or column and recompute penalties.
Repeat until fully allocated.
Generally gives a BFS closer to optimal than the least cost method.
Stepping Stone Method
Improves an initial BFS to optimality.
For every unoccupied cell, trace its loop.
Alternate + and − signs around the loop, starting with + at the unoccupied cell.
Sum the costs around the loop with their signs. This is the cell’s improvement index.
If every improvement index is ≥0, the solution is optimal. Stop.
Otherwise, the cell with the most negative improvement index enters the basis.
Shift the minimum allocation among − cells in its loop, adding it at + cells and subtracting it at − cells.
The − cell with the minimum allocation leaves the basis (becomes 0/unoccupied).
Repeat until every improvement index is ≥0.
Worked Example
Solving the table from Transportation Table. Total supply is 115, total demand is 75: unbalanced. Add a dummy demand point D4 with demand 40 and cost 0 to balance it.
Lowest cost is 0, tied across the whole dummy column D4. O2D4
allows the largest allocation (min(70,40)=40, against O1‘s 20 and
O3‘s 25). Allocate 40. D4 exhausted.
D1
D2
D3
D4
Supply
O1
4
6
8
0
20
O2
3
5
220
040
10
O3
3
9
6
0
25
Demand
30
25
0
0
Lowest remaining cost is 2 at O2D3. Allocate min(30,20)=20. D3
exhausted.
D1
D2
D3
D4
Supply
O1
4
6
8
0
20
O2
3
5
220
040
10
O3
325
9
6
0
0
Demand
5
25
0
0
Lowest remaining cost is 3, tied between O2D1 and O3D1. O3D1
allows the larger allocation (min(25,30)=25 against min(10,30)=10).
Allocate 25. O3 exhausted.
D1
D2
D3
D4
Supply
O1
4
6
8
0
20
O2
35
5
220
040
5
O3
325
9
6
0
0
Demand
0
25
0
0
Lowest remaining cost is 3 at O2D1. Allocate min(10,5)=5. D1
exhausted.
D1
D2
D3
D4
Supply
O1
4
6
8
0
20
O2
35
55
220
040
0
O3
325
9
6
0
0
Demand
0
20
0
0
Lowest remaining cost is 5 at O2D2. Allocate min(5,25)=5. O2
exhausted.
D1
D2
D3
D4
Supply
O1
4
620
8
0
0
O2
35
55
220
040
0
O3
325
9
6
0
0
Demand
0
0
0
0
z=275
Only O1D2 remains. Allocate the remaining 20. 6 basic variables
equals m+n−1, non-degenerate.
Row penalties are O1=4, O2=2, O3=3. Column penalties are
D1=0, D2=1, D3=4, D4=0. O1 and D3 tie at 4.
O1‘s lowest-cost cell (O1D4, cost 0) allows min(20,40)=20;
D3‘s (O2D3, cost 2) also allows min(70,20)=20, so the lower
cost wins: O1.
D1
D2
D3
D4
Supply
Penalty
O1
4
6
8
020
0
–
O2
3
5
2
0
70
–
O3
3
9
6
0
25
–
Demand
30
25
20
20
Penalty
–
–
–
–
Allocate 20 to O1D4. O1 exhausted.
D1
D2
D3
D4
Supply
Penalty
O1
4
6
8
020
0
–
O2
3
5
2
0
70
2
O3
3
9
6
0
25
3
Demand
30
25
20
20
Penalty
0
4
4
0
Row penalties are O2=2, O3=3. Column penalties are D1=0, D2=4, D3=4, D4=0. D2 and D3 tie at 4. D2‘s lowest-cost cell
(O2D2) allows min(70,25)=25, more than D3‘s min(70,20)=20.
D1
D2
D3
D4
Supply
Penalty
O1
4
6
8
020
0
–
O2
3
525
2
0
45
–
O3
3
9
6
0
25
–
Demand
30
0
20
20
Penalty
–
–
–
–
Allocate 25 to O2D2. D2 exhausted.
D1
D2
D3
D4
Supply
Penalty
O1
4
6
8
020
0
–
O2
3
525
2
0
45
2
O3
3
9
6
0
25
3
Demand
30
0
20
20
Penalty
0
–
4
0
Row penalties are O2=2, O3=3. Column penalties are D1=0, D3=4, D4=0. Largest is D3 (4), whose lowest cost is O2D3 (2).
D1
D2
D3
D4
Supply
Penalty
O1
4
6
8
020
0
–
O2
3
525
220
0
25
–
O3
3
9
6
0
25
–
Demand
30
0
0
20
Penalty
–
–
–
–
Allocate 20 to O2D3. D3 exhausted.
D1
D2
D3
D4
Supply
Penalty
O1
4
6
8
020
0
–
O2
3
525
220
0
25
3
O3
3
9
6
0
25
3
Demand
30
0
0
20
Penalty
0
–
–
0
Row penalties are O2=3, O3=3. Column penalties are D1=0, D4=0. O2 and O3 tie at 3, and both offer min(25,20)=20 at cost 0 in
D4: tied on every rule, so the lowest-indexed row wins, O2.
D1
D2
D3
D4
Supply
Penalty
O1
4
6
8
020
0
–
O2
3
525
220
020
5
–
O3
3
9
6
0
25
–
Demand
30
0
0
0
Penalty
–
–
–
–
Allocate 20 to O2D4. D4 exhausted.
D1
D2
D3
D4
Supply
Penalty
O1
4
6
8
020
0
–
O2
35
525
220
020
0
–
O3
3
9
6
0
25
–
Demand
25
0
0
0
Penalty
–
–
–
–
Only D1 remains, so no penalty is needed. Allocate O2D1=5. O2
exhausted.
Applying the stepping stone method to the least cost method’s BFS above (occupied cells O1D2, O2D1, O2D2, O2D3, O2D4, O3D1). Each step below traces the loop for one unoccupied cell, with + and − marking the alternating signs around it.
Starting from the least cost method’s BFS. Trace the loop of every
unoccupied cell to find its improvement index.
D1
D2
D3
D4
Supply
O1
4 +
620 -
8
0
20
O2
35 -
55 +
220
040
70
O3
325
9
6
0
25
Demand
30
25
20
40
z=275
Loop O1D1(+),O2D1(−),O2D2(+),O1D2(−). Improvement index 4−3+5−6=0.
D1
D2
D3
D4
Supply
O1
4
620 -
8 +
0
20
O2
35
55 +
220 -
040
70
O3
325
9
6
0
25
Demand
30
25
20
40
z=275
Loop O1D3(+),O1D2(−),O2D2(+),O2D3(−). Improvement index 8−6+5−2=5.
D1
D2
D3
D4
Supply
O1
4
620 -
8
0 +
20
O2
35
55 +
220
040 -
70
O3
325
9
6
0
25
Demand
30
25
20
40
z=275
Loop O1D4(+),O1D2(−),O2D2(+),O2D4(−). Improvement index 0−6+5−0=−1: the most negative so far.
D1
D2
D3
D4
Supply
O1
4
620
8
0
20
O2
35 +
55 -
220
040
70
O3
325 -
9 +
6
0
25
Demand
30
25
20
40
z=275
Loop O3D2(+),O3D1(−),O2D1(+),O2D2(−). Improvement index 9−3+3−5=4.
D1
D2
D3
D4
Supply
O1
4
620
8
0
20
O2
35 +
55
220 -
040
70
O3
325 -
9
6 +
0
25
Demand
30
25
20
40
z=275
Loop O3D3(+),O3D1(−),O2D1(+),O2D3(−). Improvement index 6−3+3−2=4.
D1
D2
D3
D4
Supply
O1
4
620
8
0
20
O2
35 +
55
220
040 -
70
O3
325 -
9
6
0 +
25
Demand
30
25
20
40
z=275
Loop O3D4(+),O3D1(−),O2D1(+),O2D4(−). Improvement index 0−3+3−0=0. Every unoccupied cell is checked: O1D4‘s −1 is the most
negative, so it enters the basis.
D1
D2
D3
D4
Supply
O1
4
620 -
8
0 +
20
O2
35
55 +
220
040 -
70
O3
325
9
6
0
25
Demand
30
25
20
40
z=275
The minimum allocation among the loop’s − cells is 20, at O1D2. Shift
20 around the loop: add 20 at the + cells, subtract 20 at the − cells.
D1
D2
D3
D4
Supply
O1
4
6
8
020
20
O2
35
525
220
020
70
O3
325
9
6
0
25
Demand
30
25
20
40
z=255
O1D2 leaves the basis (0/unoccupied), O1D4 enters at 20. New cost z=275−20=255.
D1
D2
D3
D4
Supply
O1
4
6
8
020
20
O2
35
525
220
020
70
O3
325
9
6
0
25
Demand
30
25
20
40
z=255
Recomputing: O1D1=1, O1D2=1, O1D3=6, O3D2=4,
O3D3=4, O3D4=0. Every improvement index is ≥0:
optimal at z=255. O3D4=0 gives an alternate optimal
solution.
This matches Vogel’s approximation method’s result exactly, both in allocations and cost: VAM reached the optimum directly, while the least cost method needed 1 stepping stone iteration to get there.