Definition · The minimum-cost flow problemGiven a directed network with costs c, capacities u and supplies b, the minimum-cost flow problem is min cᵀx subject to Nx = b and 0 ≤ x ≤ u, where N is the node-arc incidence matrix: one row per node, one column per arc, +1 at the tail, −1 at the head.
It is a linear programme with equality rows, so it is solved by the two-phase simplex method exactly as written. No new algorithm is introduced here and none is needed.
the network N (rows s a b t, columns in arc order)
s>a 3:2 s>a s>b a>b a>t b>t
s>b 3:3 s 1 1 0 0 0
a>b 2:1 a -1 0 1 1 0
a>t 3:5 b 0 -1 -1 0 1
b>t 3:2 t 0 0 0 -1 -1
supplies s: 4, t: -4 the four rows sum to the zero row
the programme min 2x1 + 3x2 + x3 + 5x4 + 2x5
N x = b, 0 ≤ x ≤ (3, 3, 2, 3, 3)
4 node rows + 5 capacity rows = 9 rows, 5 columns
the optimum x = (3, 1, 2, 1, 3) cost 22
Every one of those five numbers is a whole number. Nothing in the programme asked for that: there is no integrality constraint anywhere, the simplex method was free to stop at a corner with halves in it, and on a general linear programme it very often does. It came out whole because of what N is, and that is proved later on this course rather than left as a happy observation.
The same programme, four more times
What follows is not a family of related problems. It is one programme, one matrix and one objective, and the only thing that changes between the four is what was typed into the boxes. The lab's mode for this lesson has a single control for the data set and prints the same tableau each time.
Example · TransportationTwo sources and three sinks, arcs from every source to every sink, no capacity on any of them, supplies 20, 30 and demands 10, 25, 15. The programme has five rows — one per node and nothing else, because no arc is bounded — and six columns.
The optimum ships 10 and 10 from the first source and 25 and 5 from the second, for a total of 245. The tableau method usually taught for this is in the next two lessons; the point here is that it does not need one.
Example · AssignmentThree workers, three jobs, an arc from every worker to every job at capacity 1, every supply +1 and every demand −1. Fifteen rows and nine columns.
The optimum is 9, at the assignment that gives the second job to the first worker, the first to the second and the third to the third. Every variable came out 0 or 1: the programme is a transportation problem whose margins happen to be ones, and no binary variable was declared anywhere.
Example · Shortest pathOne unit at the source, one unit demanded at the sink, every capacity 1, and the arc costs read as lengths. Moving a single unit as cheaply as possible is moving it along the cheapest route.
On the lab's data the optimum is 6, carried on s>b, b>a and a>t. Bellman-Ford's labels on the same network are 0, 3, 2, 6, and the label at the sink is the same 6 — the relaxation and the simplex method reaching one number by different routes.
Example · Maximum flowPrice every arc at zero, add one arc from the sink back to the source with no upper bound and a cost of −1, and supply nothing anywhere. The only way to earn anything is to run flow round the loop, so minimising the cost maximises the flow.
The optimum is −5, and 5 is the maximum flow — and also the capacity of the smallest cut in the same network, which is the theorem two lessons from the end of this course. The return arc is deliberately unbounded: bounding it would cap the answer at whatever bound you chose.
What this buys, and what it costs
What it buys is that everything already proved about linear programmes now applies to all four. A dual exists and its variables have units; complementary slackness holds; a shadow price on a node row is worth something per unit of supply. The rest of this course is mostly reading those duals, and each one turns out to be an object with a name of its own.
What it costs is speed, and honesty about that matters. A specialised method that knows the basis is a spanning tree will beat a general tableau on a large network, which is why such methods exist. On the size of instance this course works with, the general programme is both fast enough and the right reference: when a hand method and the programme disagree, the programme is not the one that is wrong.