The minimum cost flow problem Note for instructors: this lecture was developed to follow the two lectures that are labeled Chapter 8 MIT and James Orlin © 2003
Network Models Networks 1: Introduction to Networks Paths, Cycles, Trees The shortest path problem Dijkstra’s Algorithm LP Formulation of Shortest Path Problem node arc incidence matrix Networks 2: CPM and extensions Arcs as precedence relation CPM algorithm LP Formulation of CPM Transpose of Node-Arc Matrix Networks 3: flows on arcs Large number of diverse applications MIT and James Orlin © 2003
Outline of Lecture Shortest Path Problem The shortest path problem is a special case of something known as the minimum cost flow problem We’ll introduce it soon, but first a couple of special cases. A transportation problem. Assignment Problem MIT and James Orlin © 2003
Directed and Undirected Networks 2 3 4 1 a b c d e An Undirected Graph 2 3 4 1 a b c d e A Directed Graph · Networks are used to transport commodities physical goods (products, liquids) communication electricity, etc. · The field of Network Optimization concerns optimization problems on networks MIT and James Orlin © 2003
The shortest path problem 1 2 3 4 5 6 The shortest path problem x12 x13 x23 x25 x24 x35 x46 x54 x56 1 = 1 -1 = 1 -1 = 1 -1 = 1 -1 = -1 = The constraint matrix is the node arc incidence matrix MIT and James Orlin © 2003
Applications of Network Optimization Physical analog of nodes Physical analog of arcs Flow Communication systems phone exchanges, computers, transmission facilities, satellites Cables, fiber optic links, microwave relay links Voice messages, Data, Video transmissions Hydraulic systems Pumping stations Reservoirs, Lakes Pipelines Water, Gas, Oil, Hydraulic fluids Integrated computer circuits Gates, registers, processors Wires Electrical current Mechanical systems Joints Rods, Beams, Springs Heat, Energy Transportation systems Intersections, Airports, Rail yards Highways, Airline routes Railbeds Passengers, freight, vehicles, operators MIT and James Orlin © 2003
A Transportation Problem 3 warehouses: nodes 1, 2, 3 3 retailers: nodes 4, 5, 6 1 2 3 W 4 5 6 R Supplies of goods at the warehouses (6, 7 and 2) : Upper bound on flow 6 7 2 4 8 3 1 1 Demand for goods at the warehouses (4, 8 and 3) Lower bound on flow 1 2 Costs on shipping from each warehouse to each retailer 1 1 Objective: send at most the supply, send at least the demand, and minimize cost. 1 What is the linear program for this transportation problem? MIT and James Orlin © 2003
The constraints for the transportation problem 1 2 3 4 5 6 W R 7 8 x26 x34 x35 x36 x25 x14 x15 x16 x24 = 6 1 1 = 7 1 = 2 1 = 4 1 = 8 1 = 3 This graph is “bipartite.” That is, the nodes are partitioned into two parts and arcs have one endpoint in each part. MIT and James Orlin © 2003
The constraint matrix is a node-arc incidence matrix in disguise 1 2 3 4 5 6 W R 7 8 x26 x34 x35 x36 x25 x14 x15 x16 x24 = 6 1 1 = 7 1 = 2 1 = 4 -1 = -4 1 = 8 -1 = -8 1 = 3 -1 = -3 Multiply the constraints for nodes 4, 5, 6 by -1 The matrix becomes a node-arc incidence matrix MIT and James Orlin © 2003
Features of this transportation problem The constraint matrix is (or can be made to be) the node arc incidence matrix of the network If supplies/demands are integral, then the flows are also integral. If the total supply is equal to the total demand, then all supply and demand constraints hold with equality Very efficient special purpose solution techniques exist Applications to shipment of goods Transportation Problem MIT and James Orlin © 2003
On the integrality Property The fact that solutions to the transportation problem are integral is an amazing property. In general, solutions to IP are fractional. Consider x + y = 1, x – y = 0. Unique solution (.5, .5) But solutions to this transportation problem are integral. In general, if there is at most one 1 and at most one –1 in any column of the constraint matrix, then every basic feasible solution is integer (so long as RHS is integral.) For many applications, we want to restrict variables to be integer valued. Transportation Problem MIT and James Orlin © 2003
A special case: supplies and demands are all 1. Note the special structure of the integral solutions. There will be three arcs with 1 unit of flow. 1 2 3 4 5 6 W R W R 1 4 3 5 1 2 6 1 A solution may be viewed as an “Assignment” MIT and James Orlin © 2003
A special case: supplies and demands are all 1. Every feasible integral solution has three arcs with a flow of 1. And the LP produces integral solutions. 1 2 3 4 5 6 W R W R 1 4 2 1 5 6 1 3 Each node on the left is “assigned” to a node on the right MIT and James Orlin © 2003
The Assignment Problem 3 persons: nodes 1, 2, 3 3 tasks: nodes 4, 5, 6 1 2 3 P 4 5 6 T Each person must be assigned to a task 1 2 1 1 Each task has a person assigned Utility of assigning a person to a task Objective: meet constraints while maximizing total utility Assignment Problem Formulate this as an Integer Program. (Require all variables to be integer). MIT and James Orlin © 2003
Assignment Problem Suppose that n persons (labeled 1 to n) are assigned to n tasks (also labeled 1 to n) Let xij = 1 if person i is assigned to task j Let xij = 0 if person i is not assigned to task j Let uij be the utility of assigning person i to task j Formulate the assignment problem MIT and James Orlin © 2003
The Assignment Problem In general the LP formulation is given as Minimize Each supply is 1 Each demand is 1 MIT and James Orlin © 2003
The Transportation Problem In general the LP formulation is given as Minimize All arcs are from a node in S to a node in D, and uncapacitated. S: Supply nodes D: Demand nodes MIT and James Orlin © 2003
Comments on the Assignment Problem The Air Force has used this for assigning thousands of people to jobs. This is a classical problem. Research on the assignment problem predates research on LPs. Very efficient special purpose solution techniques exist. 10 years ago, Yusin Lee and J. Orlin solved a problem with 2 million nodes and 40 million arcs in ½ hour. MIT and James Orlin © 2003
Some More on the Assignment Problem 1 7 2 8 3 9 4 10 5 11 6 12 There are 6! different assignments. There are n! different assignments in an n x n assignment problem. There are n! different assignments in an n x n assignment problem. Diverse applications. MIT and James Orlin © 2003
An Application of the Assignment Problem Suppose that there are moving targets in space. You can identify each target as a pixel on a radar screen. Given two successive pictures, identify how the targets have moved. This may be the most efficient way of tracking items. MIT and James Orlin © 2003
The minimum cost flow problem Assignment problem, transportation problem, and the shortest path problem. All are efficiently solvable All have constraint matrices that are the node-arc incidence matrix (or are equivalent) All have integer value solutions when solved by simplex We next consider the minimum cost flow problem includes assignment, transportation, and shortest path as special cases Has a constraint matrix that is the node arc incidence matrix Has integer valued solutions when solved by simplex MIT and James Orlin © 2003
The Minimum Cost Flow Problem Network G = (N, A) A network with costs, capacities, supplies, demands Node set N = {1, 2, 3, 4} 3 4 -5 -2 Arc set A = {(1,2), (1,3), (2,3), (2,4), (3,4)} 1 2 3 4 -$3, $8, $7, $3, $2, 6 5 2 4 7 Capacities uij on arc (i,j) e.g., u12 = 6 Cost cij on arc (i,j) e.g., c12 = $3 Supply/demand bi for node i. e.g. b1 = 4 (supply) b3 = -5 (demand) Send flow in each arc Satisfy “supply/demand” constraints” Satisfy flow bound constraints Minimize cost MIT and James Orlin © 2003
The Minimum Cost Flow Problem 1 2 3 4 -$3, $8, $7, $3, $2, -5 -2 A network with costs, capacities, supplies, demands 6 5 7 Let xij be the flow on arc (i,j). Min z = the cost of sending flow s.t. Flow out of i - Flow into i = bi for each i 0 xij uij for all arcs (i,j) in A MIT and James Orlin © 2003
Supply/Demand constraints -1 1 = 3 2 3 4 -$3, $8, $7, $3, $2, -5 -2 6 5 7 The LP Formulation x12 x13 x23 x24 x34 -z -3 8 7 3 2 = 1 1 = 4 Supply/Demand constraints -1 1 = 3 -1 1 = -5 -1 = -2 0 x12 6, 0 x13 5, 0 x23 2, 0 x24 4, 0 x34 7, Lower and upper bounds on variables The constraint matrix is the node arc incidence matrix MIT and James Orlin © 2003
On Network Flow Problems If the constraint matrix is a node-arc incidence matrix, then the LP is a network flow problem.** The solution values are all integer valued. ** Upper bound constraints on variables may be treated similarly to lower bound constraints, and are not viewed as part of the constraint matrix. MIT and James Orlin © 2003
The Minimum Cost Flow Problem Let xij be the flow on arc (i,j). Minimize the cost of sending flow s.t. Flow out of i - Flow into i = bi 0 xij uij Minimize s.t. 0 xij uij for all (i,j) MIT and James Orlin © 2003
Some Information on the Min Cost Flow Problem Reference text: Network Flows: Theory, Algorithms, and Applications by Ahuja, Magnanti, and Orlin This is one of the few problems for which there is a provably efficient implementation of the simplex algorithm (Orlin [1997]) Basic feasible solutions of a minimum cost flow problem are integer valued (assuming that the data is integer valued) Very efficient solution techniques in practice 15.082J/6.885J: Network Optimization MIT and James Orlin © 2003
Baseball Elimination Problem Bos Chi Atl. Denver 82 79 77 76 Games Won Games Left 9 4 8 5 Bos Chi Atl. Den. -- 1 7 3 Has Chicago already been eliminated from winning in this hypothetical season finale? Has Atlanta? http://riot.ieor.berkeley.edu/~basket/ MIT and James Orlin © 2003
Modeling as an optimization problem xAB = number of wins by Atlanta over Boston 7- xAB = number of wins by Boston over Atlanta xAD = number of wins by Atlanta over Denver 1- xAD = number of wins by Denver over Atlanta xBC = … xBD = … xCD = … Bos Chi Atl. Den. -- 1 7 3 7 1 MIT and James Orlin © 2003
Bos Chi Atl. Denver 82 79 77 76 Games Won Games Left 9 4 8 5 Determining whether Chicago can win the championship, assuming Chicago wins all of its games, and thus has 83 wins. 8 6 7 AB AD BD . RHS Bos 7-xAB+ +xBD 1 Chi -- Atl. xAB +xAD 6 Den. 1-xAD + 1 - xBD 7 MIT and James Orlin © 2003 and also upper and lower bound constraints.
The constraint matrix is a node-arc incidence matrix AB AD BD Bos Atl. Den. 7-xAB+ +xBD xAB +xAD 1-xAD + 1 - xBD . RHS 1 6 7 xAB xAD xBD . RHS Bos -1 +1 -6 Atl. 1 6 Den. -1 5 The baseball elimination problem is a minimum cost flow problem in disguise. MIT and James Orlin © 2003
Another Application of the Minimum Cost Flow Problem Warehouses 5 4 Plants 2 3 1 Customers 6 7 200 300 100 Supplies 400 180 Demands Ship from suppliers to customers, possibly through warehouses, at minimum cost to meet demands.
Matrix Fill In 16 11 20 6 Row sums ? 1 2 5 3 ? 19 13 17 7 Column sums Is it possible to fill in the missing data with non-negative integers and have the row sums and column sums as specified? If so, how large or small can be the element in position 2,3? How is this a transportation problem? MIT and James Orlin © 2003
Transportation Problem Matrix Fill In entry in (i,j) is “flow” Rows Columns Minimize entry (2,3) ? 1 2 5 3 5 1 ? 1 16 9 13 9 12 1 1 2 3 4 5 1 2 3 4 5 12 7 9 4 2 ? ? ? 1 16 13 1 1 ? ? ? 11 13 9 ? ? 2 5 1 20 12 1 1 3 ? ? 6 1 13 9 19 12 7 13 12 17 7 4 Determine the row and column sums for unknown entries. Formulate a transportation problem Transportation Problem MIT and James Orlin © 2003
Conclusions. Advantages of the transportation problem and the minimum cost flow problem Integer solutions Very fast solution methods Extremely common in modeling MIT and James Orlin © 2003
Multicommodity Flows: a brief glimpse at an important problem Send 6 units of commodity 1 from node 1 to node 4. $5, 4 $2, 4 $6, 4 $0, 8 5 1 2 3 4 5 6 5 Send 3 units of commodity 2 from node 3 to node 6. Two minimum cost flows on a shared network 3 3 The costs and capacities are given. What is the minimum cost multicommodity flow? MIT and James Orlin © 2003
Multicommodity Flows $5, 4 6 1 4 6 $0, 8 $0, 8 $2, 4 2 5 $0, 8 $0, 8 Send 5 units of commodity 1 from node 1 to node 4. Send 3 units of commodity 2 from node 3 to node 6. 4 $5, 4 6 1 4 6 2 $0, 8 $0, 8 $2, 4 2 5 2 $0, 8 $0, 8 $6, 4 3 6 3 3 1 The shared arc capacities make the problem much more complex. Optimum flows may be fractional. MIT and James Orlin © 2003
Multicommodity flow Problems can be large Consider a communication network with 1000 nodes, and 10,000 arcs. Suppose each node wants to send a different message to each other node. 1,000,000 messages. 1,000,000 commodities 10 billion variables. (10,000 variables per commodity) MIT and James Orlin © 2003
Multicommodity Flow Problems are important in practice Manufacturing Networks Road and Rail Transportation Networks Air Transportation Networks Communication Networks MIT and James Orlin © 2003
Final comments on multicommodity flows We mention them because they are important extensions of the minimum cost flow problem Much harder to solve in practice Lots of applications Lots of Research at MIT Cynthia Barnhart Jim Orlin MIT and James Orlin © 2003
Summary Minimum Cost Flows shortest paths transportation problem assignment problem plus more important subproblem of many optimization problems, including multicommodity flows MIT and James Orlin © 2003