Transportation and Assignment Problems: Balancing, Basic Solutions and Optimal Allocations

The transportation problem

Goods must move from mm sources to nn destinations. Source ii can supply aia_i units, destination jj requires bjb_j units, and shipping one unit from ii to jj costs cijc_{ij}. Writing xijx_{ij} for the quantity shipped on route (i,j)(i,j), the problem is


min⁡∑i=1m∑j=1ncijxijsubject to∑jxij=ai,  ∑ixij=bj,  xij≥0.\min \sum_{i=1}^{m}\sum_{j=1}^{n} c_{ij}x_{ij} \quad \text{subject to} \quad \sum_{j} x_{ij} = a_i,\ \ \sum_{i} x_{ij} = b_j,\ \ x_{ij} \ge 0 .


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


∑i=1mai=∑j=1nbj,\sum_{i=1}^{m} a_i = \sum_{j=1}^{n} b_j ,


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 kk 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+nm + 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−1m + n - 1, and a nondegenerate basic feasible solution has


m+n−1 basic variables,m + n - 1 \ \text{basic variables,}


with the remaining mn−(m+n−1)mn - (m+n-1) routes carrying nothing. If fewer than m+n−1m+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−1m+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=30x_{11}=30, then x21=15x_{21}=15 and x22=35x_{22}=35, at cost


30(8)+15(6)+35(7)=240+90+245=575.30(8) + 15(6) + 35(7) = 240 + 90 + 245 = 575 .


Is that good? Parameterise by x11=tx_{11}=t; feasibility forces x12=30−tx_{12}=30-t, x21=45−tx_{21}=45-t, x22=t+5x_{22}=t+5, and the cost becomes


8t+5(30−t)+6(45−t)+7(t+5)=4t+455.8t + 5(30-t) + 6(45-t) + 7(t+5) = 4t + 455 .


The coefficient of tt is positive, so the cost falls as tt decreases, and the optimum is at t=0t=0: ship x12=30x_{12}=30, x21=45x_{21}=45, x22=5x_{22}=5, for a cost of 455. The northwest-corner solution was 26% more expensive. The quantity +4+4 is the net change from rerouting one unit around the cycle S1D1→S1D2→S2D2→S2D1S_1D_1 \to S_1D_2 \to S_2D_2 \to S_2D_1, 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=3m+n-1 = 3.

The assignment problem

Now specialise: nn agents, nn 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:


min⁡∑i∑jcijxij,∑jxij=1,  ∑ixij=1,  xij≥0.\min \sum_i \sum_j c_{ij}x_{ij}, \qquad \sum_j x_{ij} = 1,\ \ \sum_i x_{ij} = 1,\ \ x_{ij}\ge 0 .


Three adaptations cover almost every practical variant.


  • Maximisation. With a profit matrix pijp_{ij}, minimise the opportunity loss cij=M−pijc_{ij} = M - p_{ij} where MM is the largest profit. Subtracting every entry from the same constant leaves the ranking of complete assignments unchanged, because each assignment uses exactly nn cells and so loses exactly nMnM.
  • 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 nn 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+1 or −1-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 xijx_{ij} anywhere in [0,1][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.

The assignment problem is standardly described as a special case of the transportation problem.

Which feature of the assignment problem makes this true?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

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.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

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.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors