The transportation problem is a special LP that finds the cheapest way to send goods from several sources to several destinations. Its structure allows simple and fast methods.

Definition and Linear Form

There are m sources (factories) with supplies a1, …, am, and n destinations (warehouses) with demands b1, …, bn. Sending one unit from source i to destination j costs c(ij). Let x(ij) be the amount sent. The problem is: minimise Z = Σ Σ c(ij)x(ij) subject to Σ over j of x(ij) = a(i) for each source, Σ over i of x(ij) = b(j) for each destination, and x(ij) ≥ 0. It is balanced if total supply equals total demand. If not, a dummy source or destination with zero costs is added to balance it. A basic feasible solution has m + n − 1 occupied cells. If it has fewer, it is degenerate, and a tiny amount ε is placed in a suitable cell.

Definition: Transportation problem. A linear programming problem of shipping a commodity from several sources with given supplies to several destinations with given demands so that the total transport cost is a minimum.

Initial Feasible Solution

North-west corner method (NWC): start at the top-left cell, allocate as much as possible, the minimum of the supply and demand, then move right if the column is filled or down if the row is exhausted, and repeat. It is simple but ignores costs. Least cost method (LCM): allocate as much as possible to the cell with the lowest cost, cross out the filled row or column, and repeat. Vogel's approximation method (VAM): for each row and column, find the penalty, the difference between its two lowest costs. Choose the row or column with the largest penalty and allocate as much as possible to its lowest-cost cell. Recompute penalties and repeat. VAM usually gives a solution very close to the optimum.

MODI Method for the Optimum

The modified distribution (MODI), or u-v, method tests and improves a basic feasible solution. 1. For each occupied cell, set u(i) + v(j) = c(ij), and put one u = 0 to solve for the rest. 2. For each empty cell, compute the opportunity cost d(ij) = c(ij) − (u(i) + v(j)). 3. If all d(ij) ≥ 0, the solution is optimal. 4. Otherwise choose the cell with the most negative d(ij), form a closed loop through occupied cells with alternate + and − signs, shift the smallest amount in the − cells around the loop, and return to step 1.

Table 4.5: Initial solution methods

Method Rule Quality
North-west corner Start top-left, ignore cost Poor
Least cost Cheapest cell first Better
Vogel's approximation Largest penalty first Near optimal

Example 4.5: NWC, least cost and VAM

Problem: Sources A, B with supply 30, 50. Destinations P, Q, R with demand 20, 40, 20. Costs: A→P 4, A→Q 6, A→R 8; B→P 5, B→Q 3, B→R 7. Find the cost by NWC, least cost and VAM.

Solution:

  1. NWC: A→P 20, A→Q 10, B→Q 30, B→R 20. Cost = 80 + 60 + 90 + 140 = 370.
  2. Least cost: B→Q 40 (cost 3), A→P 20 (cost 4), then A→R 10 and B→R 10. Cost = 120 + 80 + 80 + 70 = 350.
  3. VAM: penalties give the same plan as least cost here, cost 350.
  4. MODI on the 350 plan: all opportunity costs are ≥ 0, so it is optimal.

Result: NWC gives 370, least cost and VAM give 350, and 350 is optimal.

def nwc(s, d):
    s, d, i, j, x = s[:], d[:], 0, 0, {}
    while i < len(s) and j < len(d):
        q = min(s[i], d[j]); x[(i, j)] = q
        s[i] -= q; d[j] -= q
        if s[i] == 0: i += 1
        else: j += 1
    return x
C = [[4, 6, 8], [5, 3, 7]]
x = nwc([30, 50], [20, 40, 20])
print(x, sum(C[i][j] * q for (i, j), q in x.items()))

Output

{(0, 0): 20, (0, 1): 10, (1, 1): 30, (1, 2): 20} 370

Common mistakes

  • Applying the methods to an unbalanced problem without adding a dummy row or column.
  • Forgetting that a basic solution needs m + n − 1 occupied cells.
  • In MODI, forming a loop that turns at an empty cell other than the entering cell.

Key takeaways

  • A transportation problem must be balanced before solving.
  • NWC, least cost and VAM give initial feasible solutions, VAM usually the best.
  • A basic solution has m + n − 1 allocations.
  • MODI: u(i) + v(j) = c(ij) for occupied cells; optimal when all d(ij) ≥ 0.

Practice questions

  1. When is a transportation problem balanced?
  2. What is the penalty in VAM?
  3. When is a solution optimal by MODI?

Answers to the practice questions

  1. When total supply equals total demand.
  2. The difference between the two lowest costs in a row or column.
  3. When every empty cell has an opportunity cost c(ij) − (u(i) + v(j)) of zero or more.

Sources

  • Official BCA syllabus Mathematics Foundations to Computer Science II, course code 25BCA402DS01, Unit IV