Applications of ORGitHub
Lecture 2 · Logistics & Supply Chain

The Transportation Problem

Shipping goods from supply points to demand points at minimum cost, and what the dual prices tell you.

A company makes a product at several plants and sells it in several markets. Each plant has a limited capacity, each market has a demand that must be met, and shipping one unit from a given plant to a given market has a known cost. How much should each plant send to each market?

This is the transportation problem. It is one of the oldest models in OR and still one of the most useful: it is the building block inside distribution planning, it is the simplest example of a network-flow problem, and its dual has a clean economic interpretation.

The decision

We have mm supply points (plants, warehouses, ports) indexed by ii and nn demand points (markets, stores, customers) indexed by jj.

  • Supply point ii can ship at most sis_i units.
  • Demand point jj requires djd_j units.
  • Shipping one unit along route (i,j)(i, j) costs cijc_{ij}.

The decision is the shipment plan: how many units travel along each route. Costs are assumed to be linear in quantity — no fixed charges per route, no volume discounts. (Relaxing that assumption turns the LP into a MIP; see the extensions.)

Formulation

Let xij≥0x_{ij} \ge 0 be the quantity shipped from ii to jj.

min⁡x∑i=1m∑j=1ncij xijs.t.∑j=1nxij≤si,i=1,…,m(capacity)∑i=1mxij≥dj,j=1,…,n(demand)xij≥0.\begin{aligned} \min_{x} \quad & \sum_{i=1}^{m} \sum_{j=1}^{n} c_{ij}\, x_{ij} \\ \text{s.t.} \quad & \sum_{j=1}^{n} x_{ij} \le s_i, && i = 1, \dots, m \quad \text{(capacity)} \\ & \sum_{i=1}^{m} x_{ij} \ge d_j, && j = 1, \dots, n \quad \text{(demand)} \\ & x_{ij} \ge 0 . \end{aligned}

The model is feasible exactly when total supply covers total demand, ∑isi≥∑jdj\sum_i s_i \ge \sum_j d_j.

(Balanced transportation problem)

A transportation problem is balanced if ∑isi=∑jdj\sum_i s_i = \sum_j d_j. In that case every constraint holds with equality at any feasible point. Any problem can be balanced by adding a dummy demand point that absorbs the surplus supply at zero cost; units sent to it represent unused capacity.

Structure

The constraint matrix has a very particular form: every variable xijx_{ij} appears in exactly two constraints — the capacity row of ii and the demand row of jj — each with coefficient 11. Equivalently, the problem is a flow problem on a bipartite graph with supply nodes on one side, demand nodes on the other, and an arc for every route.

(Integrality)

The constraint matrix of the transportation problem is totally unimodular: every square submatrix has determinant 00, +1+1 or −1-1. Consequently, if all sis_i and djd_j are integers, every basic feasible solution — and in particular the solution returned by the simplex method — is integer.

This matters in practice. If the units are trucks, containers or people, we need whole numbers, and integer programming is in general much harder than LP. For the transportation problem we get integrality for free.

Solution methods

Any LP solver handles transportation problems of realistic size in well under a second. Historically, though, the structure motivated a specialized version of the simplex method that is still taught because it makes the dual visible.

Finding a starting solution. In a balanced problem a basic feasible solution has at most m+n−1m + n - 1 positive entries (one constraint is redundant, since supplies and demands sum to the same total). Simple rules produce one:

  • North-west corner rule: fill the table starting at the top-left cell, shipping as much as possible, and move right or down as rows and columns are exhausted. Ignores costs; easy to check.
  • Least-cost rule: repeatedly fill the cheapest remaining cell.
  • Vogel's approximation: for each row and column compute the gap between its two cheapest cells, and fill the cheapest cell in the row or column with the largest gap. Often close to optimal.

Testing optimality (MODI / u–v method). Assign a potential uiu_i to each supply row and vjv_j to each demand column such that

ui+vj=cijfor every basic (used) cell (i,j).u_i + v_j = c_{ij} \quad \text{for every basic (used) cell } (i, j).

There are m+nm + n unknowns and m+n−1m + n - 1 equations, so fix one value (say u1=0u_1 = 0) and solve the rest. Then compute the reduced cost of each unused cell:

cˉij=cij−ui−vj.\bar c_{ij} = c_{ij} - u_i - v_j .

If every cˉij≥0\bar c_{ij} \ge 0, the current plan is optimal. Otherwise, bring a cell with negative reduced cost into the solution by shifting flow around the unique cycle it forms with the basic cells, and repeat.

The uiu_i and vjv_j are precisely the LP dual variables, and the optimality test is LP complementary slackness written out for this problem.

Worked example

(Three plants, four markets)

Supplies, demands and unit costs are:

D1D_1D2D_2D3D_3D4D_4Supply
S1S_186109120
S2S_291213780
S3S_3149165100
Demand70906080300

Total supply equals total demand, so the problem is balanced. The optimal shipment plan is

D1D_1D2D_2D3D_3D4D_4
S1S_1·7050·
S2S_270·10·
S3S_3·20·80

with total cost

70⋅6+50⋅10+70⋅9+10⋅13+20⋅9+80⋅5=2260.70 \cdot 6 + 50 \cdot 10 + 70 \cdot 9 + 10 \cdot 13 + 20 \cdot 9 + 80 \cdot 5 = 2260 .

Verifying optimality. The six used cells give the equations ui+vj=ciju_i + v_j = c_{ij}. Setting u1=0u_1 = 0:

  • from (1,2)(1,2) and (1,3)(1,3): v2=6v_2 = 6, v3=10v_3 = 10;
  • from (2,3)(2,3): u2=3u_2 = 3; then (2,1)(2,1) gives v1=6v_1 = 6;
  • from (3,2)(3,2): u3=3u_3 = 3; then (3,4)(3,4) gives v4=2v_4 = 2.

The reduced costs cˉij=cij−ui−vj\bar c_{ij} = c_{ij} - u_i - v_j of the unused cells are

D1D_1D2D_2D3D_3D4D_4
S1S_12··7
S2S_2·3·2
S3S_35·3·

All are strictly positive, so the plan is optimal — and, because none is zero, it is the unique optimum.

Notice that the optimum is not greedy. Market D1D_1 is cheapest to serve from S1S_1 (cost 8), yet it is served entirely from S2S_2 (cost 9). Plant S1S_1 is more valuable sending its limited capacity to D2D_2 and D3D_3, where its cost advantage over the alternatives is larger.

Reading the dual

In the balanced problem the potentials are only determined up to a constant (adding kk to every uiu_i and subtracting it from every vjv_j changes nothing), so their differences carry the meaning.

  • Reduced costs price the routes not used. Route S1→D4S_1 \to D_4 has cˉ14=7\bar c_{14} = 7: its unit cost would have to fall from 9 to 2 before it would be worth using. Route S1→D1S_1 \to D_1, at cˉ11=2\bar c_{11} = 2, is the nearest to entering the plan — useful to know if rates are renegotiated.
  • Supply potentials price capacity. Here u2−u1=u3−u1=3u_2 - u_1 = u_3 - u_1 = 3: an extra unit of capacity at S1S_1 (with one unit less at S2S_2 or S3S_3) would lower total cost by 3. If the company could expand one plant, the dual says to expand S1S_1.
  • Demand potentials price markets. Serving one extra unit at DjD_j, using an extra unit of supply at SiS_i, costs ui+vju_i + v_j. One more unit at D3D_3 made at S1S_1 costs 0+10=100 + 10 = 10 at the margin.

Shadow prices are valid only for small changes. Large changes in supply or demand alter which routes are used, and with them the potentials. LP sensitivity analysis reports the range over which each price holds.

Extensions

The transportation model is deliberately minimal. Real distribution planning typically adds:

  • Transshipment. Goods may pass through intermediate warehouses or cross-docks. The model becomes a minimum-cost network flow problem on a general graph, with flow conservation at each intermediate node. It keeps total unimodularity, so integrality still comes for free.
  • Multiple products. Several commodities share arc or plant capacity. The coupling constraints break the network structure, and integrality is no longer automatic.
  • Fixed charges. Opening a route or a lane costs money regardless of volume. This needs binary variables, and leads directly to the facility location models.
  • The assignment problem. The special case m=nm = n with all si=dj=1s_i = d_j = 1: assign nn workers to nn jobs at minimum total cost. It has its own efficient algorithm (the Hungarian method) and appears inside many scheduling problems.

Further reading: the transportation problem is treated in every introductory OR text; see for example Hillier and Lieberman, Introduction to Operations Research, or Ahuja, Magnanti and Orlin, Network Flows, for the network-flow view.