Network Optimization Chapter 2 Transshipment Problem 1 2.1 The Network Simplex Method G = (V, E) is a digraph. |V|=n, |E|=m. A type of commodity is shipped on the network. For each arc i, j , cij is the cost of sending one unit of commodity from vertex i to vertex j cij 0 . Vector c = cij has m components, and is called the cost vector. There are three kinds of vertices: 2 2.1 The Network Simplex Method (1) Source If the supply at source i is i ( >0 ), then let bi =- i . (2) Sink If the demand at sink j is j ( >0 ), then let bj = j . (3) Intermediate vertex Neither a source, nor a sink. If k is an intermediate vertex, then let bk = 0. 3 2.1 The Network Simplex Method S denotes supply and D denotes demand 4 2.1 The Network Simplex Method Balanced transshipment problem Total supply = total demand: i j, i.e. n b i 1 i 0 5 2.1 The Network Simplex Method inflow at vertex i ~ the total commodity sent to i; outflow at vertex i ~ the total commodity sent out from i; netflow at vertex i ~ inflow at i - outflow at i; m flow vector x ~ x xij R , where xij is the amount of commodity from i to j xij 0 ; feasible flow x ~ a flow x that makes the netflow at each vertex i equal bi . 6 2.1 The Network Simplex Method A Feasible Flow 7 2.1 The Network Simplex Method Single commodity uncapacitated transshipment problem Find a feasible flow x 0 such that its cost is as low as possible. Let A be the incidence matrix of the network. The supply-demand can be expressed by Ax=b 8 2.1 The Network Simplex Method For example, if at vertex i: then e1 e2 e3 x1 b1 x 2 i 1 1 1 0 ... 0 x3 bi bn A x b x1 x 2 x3 bi netflow at i 9 2.1 The Network Simplex Method The transshipment problem is now formulated as min cx s.t. Ax=b x0 c ~ row vector, x & b ~ column vector c, x R m , b Rn uncapacitated ~ all xij have no upper bound 10 2.1 The Network Simplex Method Example 2.1 Consider the network shown below with 7 vertices and 10 arcs in which any flow vector x is of the form xT = [x13 x21 x32 x51 x52 x61 x64 x67 x74 x75]. The cost vector is given by c = [1 1 1 1 5 11 20 5 5 6] and the supply-demand vector by bT = [0 2 3 5 -2 -3 -5]. 11 2.1 The Network Simplex Method 12 2.1 The Network Simplex Method e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 1 1 1 1 1 1 1 1 1 A 1 1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 6 7 13 2.1 The Network Simplex Method 1 1 1 1 1 1 1 1 1 A 1 1 1 1 1 1 1 1 1 1 1 Note that the rows of A are linearly dependent because the sum of all rows of A is a zero vector. So, rank (A) < n. On the other hand, we will see later that A contains an n 1 n 1 nonsingular submatrix. Therefore, rank (A) = n-1. We may delete one equation from Ax = b without changing the solution set. 14 Do you still remember? What is a basic? What is a basic solution? What is a basic feasible solution? What is the main idea of Simplex method? From a vertex (feasible basic sol) to another vertex, obj. value keep decreasing. 15 2.1 The Network Simplex Method Feasible tree solution (FTS) A feasible flow x is called an FTS if there is a spanning tree T such that xij 0 if i, j T . As each spanning tree has n-1 edges, an FTS x has at most n-1 nonzero components xij. 16 2.1 The Network Simplex Method If an FTS x has n-1 nonzero components, then the associated spanning tree is unique. It must be the tree consisting of the n-1 edges eij that correspond to the n-1 nonzero xij. We call such an FTS a nondegenerate FTS. An FTS x is called a degenerate FTS if the number of nonzero components is less than n-1. A degenerate FTS may associate with more than one spanning tree. 17 2.1 The Network Simplex Method Example 1 1 1 1 A 1 1 1 1 b = (-3, 3, 0, 0)T It is easy to see that x = ( 3, 0, 0, 0 )T is a feasible solution of the equation Ax = b. 18 2.1 The Network Simplex Method In fact x is a degenerate FTS, and the associated spanning trees are not unique. They can be one of the following trees: Conversely, every spanning tree T is associated with at most one feasible tree solution. 19 The above few pages told you FS can be classified into FTS/not FTS. FTS can be further classified into DE/non-DE. Given non-DE FTS, we can defined a unique ST. Given DE FTS, there will be many ST. The following few pages tell: Given a ST, we can solve for a unique solution. The solution may be a FS or not FS. 20 2.1 The Network Simplex Method By relabeling vertices and arcs, we may let the part of A corresponding to the arcs in T contain a nonsingular n 1 n 1 matrix B. For example, if we consider the following spanning tree T (formed by solid lines) in Example 2.1: 21 2.1 The Network Simplex Method It is not clear if in A, the columns corresponding to the arcs in T contain an n 1 n 1 nonsingular B. 1 1 1 1 1 1 1 1 1 A 1 1 1 1 1 1 1 1 1 1 1 22 2.1 The Network Simplex Method Relabel vertices and arcs as follows: 23 2.1 The Network Simplex Method How to relabel? First pick up an arbitrary vertex and label it as the first one. In general suppose i vertices and i-1 arcs in the tree are already relabeled ( 1 i n 1 ). Then from all unlabeled vertices, choose one (say w) which is adjacent to a relabeled vertex (say u), and label w as the i+1th vertex, and also label the arc between w and u in the tree (either (u,w), or (w,u)) as the ith arc. Repeat the procedure until we have labeled all n vertices and n-1 arcs in the tree. 24 2.1 The Network Simplex Method a7, a8, a9, a10 are the four arcs not in T, now the incidence matrix 1 1 1 1 1 1 A 1 1 1 1 1 1 . . . . . . . . . . . . . . . . . . v1 . v 2 . v3 . v4 . v5 . v6 . v 7 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 25 2.1 The Network Simplex Method Let x = (x1, … , x10)T , where xi corresponds to arc ai. Rows 2-7 and columns 1-6 form a matrix B, which is upper triangular, and the diagonal elements are 1 or -1. So, B is a nonsingular n 1 n 1 matrix. 1 1 1 1 1 1 A 1 1 1 1 1 1 . . . . . . . . . . . . . . . . . . v1 . v 2 . v3 . v4 . v5 . v6 . v 7 26 2.1 The Network Simplex Method The feasible tree solution corresponding to T must have x7 = x8 = x9 = x10 = 0. For xB= ( x1, x2, x3, x4, x5, x6 )T, it can be decided by b2 b3 BxB b 7 def b bi ~ the supply or demand, or zero corresponding to vi. 27 2.1 The Network Simplex Method Therefore, xB is uniquely determined: (1) If x B 0 , then x x ,0,0,0,0 is an FTS, i.e., T is associated with a unique FTS. (2) If some components of xB are negative, then x x ,0,0,0,0 is not a feasible solution, i.e., T is not associated with any FTS. x B B 1 b T T T B T B 28 2.1 The Network Simplex Method Summary of the relationship between FTS and ST 29 2.1 The Network Simplex Method From the above analysis, we know that a Tree Solution is actually a Basic Solution of the system Ax = b, and the base B can be determined by an associated spanning tree. An FTS is a feasible basic solution (FBS). In simplex method we move from one FBS to another FBS. Now in network simplex method, we move from one FTS to another FTS, and geometrically, from one spanning tree to another spanning tree. 30 2.1 The Network Simplex Method The dual solution defined by a spanning tree We know that the dual problem of min cx s.t. Ax=b x0 is max yb s.t. yA c where y is a row vector: y1 , y 2 ,..., y n1 , y n . Also, the complementarity slackness condition holds. 31 2.1 The Network Simplex Method Now for a nondegenerate FTS x, the associated spanning tree T is unique, and for any arc i, j in T, xij 0 . Let the column in A which corresponds to arc i, j be Aij , then by the complementarity slackness condition, xij 0 yAij cij i.e. 1 i y1 ,, yn cij 1 j yi y j cij , (i, j) T (*) 32 2.1 The Network Simplex Method yi y j cij i, j T (*) The above set (*) has n-1 equations for n variables. So, the solutions are not unique. If we fix yn = 0, then y1, … , yn-1 can be uniquely determined. (If we fix yn to another value t, then in the solution, each yi shall increase its value by t.) We call the row vector y y1 , , y n1 ,,0 determined by the equations (*), the dual solution defined by the spanning tree T. 33 2.1 The Network Simplex Method Profitable arcs Suppose x is an FTS that defines a spanning tree T(x) and a dual solution y. An arc (i, j) which is not in T(x) is said to be profitable with respect to the FTS x if y j yi cij . Note that if we change the value of yn in deciding y, as all yi shall change by the same value, the value of every y j yi shall remain unchanged. So, the determination of profitable arcs is independent of the value of yn chosen. 34 2.1 The Network Simplex Method Theorem 2.2 An FTS u with no profitable arcs is an optimal solution. Proof Suppose u is associated with tree T(u) and dual solution y. Define c c yA . We know that c u 0 . In fact (1) If arc i, j T u , then by the definition of y, cij cij yi y j cij yi y j 0 (2) If arc i, j T u , then uij 0. So, for any arc i, j , cij uij 0 cu 0. 35 2.1 The Network Simplex Method Now for any feasible solution v: Av= b, v 0 , (1) cv c yAv cv yb . In particular, when v = u, (2) cu c u yb yb . (1) - (2): cv cu c v . 36 2.1 The Network Simplex Method Since there is no profitable arc, for any arc i, j , y j yi cij cij cij yi y j 0 . But v 0 , and hence c v 0 cv cu u is an optimal solution. 37 2.1 The network simplex method The above theorem provides an optimality criterion. Now we consider what happens if there is a profitable arc e p, q . Of course e is not in T, and c pq 0 . If we can increase the flow on p, q from u pq 0 to v pq t 0 , meanwhile keep vij uij 0 for other arcs i, j not in T, then as cpq v pq 0 , we may have cv cu cv cpq t 0 (will explain in detail later), i.e. we obtain a better solution v. 38 2.1 The Network Simplex Method When arc e is added to the spanning tree T, a unique cycle C(e) will be obtained. 39 2.1 The Network Simplex Method In the cycle, we call each arc with the same direction as e a forward arc (arcs e1 & e2 in the above graph) and each arc with the opposite direction a backward arc (arcs e3 & e4 in the above graph). If the flow along arc e is increased from 0 to t, then the flow along each forward arc ei is from ui to ui+t, and the flow along each backward arc ej is from uj to uj-t. 40 2.1 The Network Simplex Method There must be some backward arcs in the cycle. Why? Because if not, we may increase t infinitely (Can this problem be unbounded?). But when t , the new feasible flow v shall let cv cu cpq t cv , which is impossible as c 0 and v 0 . 41 2.1 The Network Simplex Method Now since cycle C(e) has backward arcs, when t is increased to certain amount, the flow along a backward arc becomes zero, and we cannot further increase t (for otherwise some flow shall become negative, violating the feasibility). 42 2.1 The Network Simplex Method In the above example, the largest value of t to maintain a non-negative flow is t minu3 , u4 . Suppose t = u3. In this case, call e3 the leaving arc. Generally, if an arc f in C(e) is the leaving arc, we obtain a new tree T by deleting f T u and adjoining eT u . The updated flow vector v is associated with T , i.e., v is a new FTS, and the associated spanning tree is T v T . 43 2.1 The Network Simplex Method Theorem 2.3 If u is an FTS with a profitable arc e and if v is the updated flow using this arc e, then v is an FTS and cv cu . Proof We first show that v is still an FTS, because (1) When we change from flow u to v, the net-flow at each vertex remains unaffected, and hence all supply / demand requirements are still satisfied, i.e. Av = b. (2) Obviously, v 0 . 44 2.1 The Network Simplex Method We next show that cv cu . Let c c yA , where y is the dual solution of u. By Theorem 2.2, cv cu c v . Consider two types of arcs: (a) If arc i, j is in the tree T(u) cij 0 cij vij 0 (b) If arc i, j is not in the T(u) and other than the profitable arc p, q . vij 0 cij vij 0 45 2.1 The Network Simplex Method Therefore, cv cij vij cpq v pq 0 cv cu . In particular, if u is a nondegenerate FTS uij 0 , arc i, j T u t = min { u | i, j is a backward arc of ij T(u) } >0 v pq t 0 cv cu v u . If all calculated FTS are non-degenerate, the computation must be terminated after a finite number of iterations (i.e. no cycling). 46 2.1 The Network Simplex Method We now summarize the steps. (1) x Initial Step: find an initial FTS and an associated spanning tree T (1). Let k = 1. Iterative Steps: for k = 1, 2, … Step 1 Calculate dual solution y (k ) on the tree T (k.) (k ) (k ) y y cij , i, j T ( k ) i.e., the Step 2 If j i network has no profitable arc, terminate, x ( k ) is the optimal FTS. Otherwise obtain a profitable arc e p, qT (k ) with yq(k ) y (pk ) c pq . 47 2.1 The Network Simplex Method Step 3 Form the cycle C(e) e T (k ) and determine (k ) x t = min { ij | i, j is a backward arc in C(e) } Suppose the minimum is attained at arc f. Let xijk t , If (i, j) is a forward arc of C(e) k k 1 x ij t , If (i, j) is a backward arc of C(e) xij If (i, j) = (p, q) t, xijk , For other arcs ( k 1) and T T (k ) e f . k k 1 and return to Step 1. 48 2.1 The Network Simplex Method Let us now use Example 2.1 to explain the algorithm. S=5 S=2 D=2 D=5 S=3 D=3 49 Tradition about arc labeling In the above example, there are totally 10 arcs: (1,3), (2,1), (3,2) (5,1), (5,2), (6,1), (6,4) (6,7) (7,4) (7,5). We normally, label them according to the first number and then the second. e1 = (1,3), e2 = (2,1), … 50 2.1 The Network Simplex Method Iteration 1 We have given an initial feasible tree solution with which we start our first iteration. Step 1. The initial FTS is xT = [ 3 0 0 0 2 3 0 0 5 0 ] and its cost is z = cx = 71. The arcs of a spanning tree T (not unique since x is degenerate) with which x can be associated are (1, 3), (2, 1), (5, 2), (6, 1), (6, 7) and (7, 4). 51 2.1 The Network Simplex Method For each arc i, j in T y j yi cij or yi y j cij Start with y 7 0 . So, y = [ 6, 5, 7, 5, 0, -5, 0 ] . y 4 y7 c74 0 5 5 y6 y7 c67 0 5 5 y1 y 6 c61 5 11 6 y3 y1 c13 6 1 7 y2 y1 c21 6 1 5 y5 y2 c52 5 5 0 52 2.1 The Network Simplex Method Step 2. We test whether there is a profitable arc e with respect to x. In the present case we see that e = (5, 1) is the only profitable arc which comes. into T(x) as an entering arc. For each arc i, j not in T, calculate c c ij yi y j ~ entering arc. In the degenerate case, cycling might occur, but we can use the methods learned in 53 Linear Programming to avoid cycling. c51 y5 y1 1 0 6 5 0 c51 ij 2.1 The Network Simplex Method Step 3. The cycle C(e) is in which (5, 2) and (2, 1) are both backward arcs with existing flow 2 and 0, respectively. We revise the flow in this cycle as t units along (5, 1), 2 - t units along (5, 2) and 0 - t units along (2, 1). Therefore t = 0. Since (5, 1) has just entered it does not make sense to take it as a leaving arc. Thus (2, 1) becomes the leaving arc. Since t = 0, the cost remains unchanged. 54 2.1 The Network Simplex Method Iteration 2 Step 1. The current FTS is xT = [ 3 0 0 0 2 3 0 0 5 0 ] with cost z = 71. The arcs of the spanning tree are (1, 3), (5, 1), (5, 2), (6, 1), (6, 7) and (7, 4). From the defining equations, y = [ 6 10 7 5 5 -5 0 ] Step 2. We see that e = (3, 2) is the only profitable arc which enters T(x). 55 2.1 The Network Simplex Method Step 3. The cycle C(e) is We get t = 2 and (5, 2) leaves the tree. 56 2.1 The Network Simplex Method Iteration 3 Step 1. Our FTS is now xT = [ 5 0 2 2 0 3 0 0 5 0 ] and z = 67. The spanning tree has arcs (1, 3), (3, 2), (5, 1), (6, 1), (6, 7) and (7, 4). Also y = [6 8 7 5 5 -5 0 ] Step 2. There are no profitable arcs for the current FTS. At this stage the algorithm halts after reporting that the current FTS is an optimal solution. 57 Again to avoid having many different answer If there are two profitable arc, add the arc having prior (smallest) label. For example, if there are 3 profitable arc (2,3), (3,4) and (4,1), Then please add (2,3). Otherwise, I may mark your answer wrong. 58 2.2 Initialization As we have seen, the network simplex method need to have a feasible tree solution (FTS) to start with. How to obtain the initial FTS and the associated spanning tree? Use artificial arcs. 59 2.2 Initialization The way to obtain an initial spanning tree T 1. choose an arbitrary vertex v in the graph. (Always pick vertex 1 in exam) 2. for each source i, if there is an arc from i to v, then this arc (i, v) is an arc of T; if there is no arc from i to v, construct an artificial arc (i, v) and take it as an arc of T; 60 2.2 Initialization 3. for each sink j, if there is an arc from v to j, then this arc (v, j) is an arc of T; if there is no arc from v to j, construct an artificial arc (v, j) and take it as an arc of T; 4. for each intermediate vertex k, if there is an arc from v to k or from k to v, we take that arc as an arc of T; if there is no such an arc, construct an artificial arc in either direction and take it as an arc of T. This T must be a spanning tree. 61 2.2 Initialization Suppose there are r artificial arcs, we denote the enlarged network by G which has m + r arcs, but still n vertices. Define a new cost vector c R m r by taking 0 cij 1 If (i, j) is an arc of the original network G If (i, j) is an artificial arc 62 2.2 Initialization If the incidence matrix of G is A , we solve the problem: c x Pmin s.t. Ax b x0 Note that the vector x R m r . 63 2.2 Initialization Obviously, xiv bi , for all sources i; xvj b j , for all sinks j; , for other arcs in G form a feasible tree solution (FTS) corresponding to the tree T. Starting with this (initial) FTS, we use the network simplex method to solve problem P . xij 0 64 2.2 Initialization Suppose x* is an optimal FTS with an associated spanning tree T*. There are three possibilities: Case 1 T* contains no artificial arc. In this case T* is a spanning tree of the original network G and the components of x* that correspond to the artificial arcs must be zero. Thus the original transshipment problem is feasible. We delete all artificial arcs, replace cost vector c by c and use T* as the initial tree to solve the original network problem. 65 2.2 Initialization Case 2 T* has at least one artificial arc along which the flow is positive. In this case, the optimal value of problem P is positive which means that the original problem has no feasible solution. 66 2.2 Initialization Case 3 T* has at least one artificial arc, but the flow in every artificial arc is zero. The original problem has a feasible solution x obtained by the restriction of x* to the set of original arcs. After deleting the artificial arcs in T*, the remaining part of T* has less than n-1 arcs, which cannot form a spanning tree. So, it must consist of several disconnected components, which implies that the original problem can be decomposed into several smaller sub-problems which may be solved separately. 67 2.2 Initialization Example 2.3 x x12 , x14 , x23 , x25 , x35 , x45 , x46 , x57 , x67 T b 6,4,8,0,0,11,7 T 68 2.2 Initialization Iteration 1. Introduce arcs a10 =(1,5) and a11 =(5,6). Initial spanning tree T(1): D = 11 S=6 S=8 D=7 S=4 69 2.2 Initialization Let c = [ 0 0 0 0 0 0 0 0 0 | 1 1 ] . Initial FTS x(1) = [ 0 0 0 4 8 0 0 7 0 | 6 11 ]T . y7 0 , 1 , 0 , y6 y5 c56 y5 y7 c57 0 , 0 , y3 y5 c35 y 4 y5 c45 0 , y1 y5 c15 1 . y 2 y5 c25 y (1) 1,0,0,0,0,1,0 . 70 2.2 Initialization For the arc (1, 2) not in T(1), y1 y 2 0 1 0 1 0 . c12 c12 arc a1 1,2 is profitable. . T (1) a1 contains cycle C (1) 71 2.2 Initialization The only backward arc is a10 1,5 which is the leaving arc. t = 6. x(2) = [6 0 0 10 8 0 0 7 0 0 11 ]T 72 2.2 Initialization Iteration 2. y2 y7 don’t change, y1 y 2 c12 0 0 0. So, y(2) = [ 0 0 0 0 0 1 0 ]. For arc a7 4,6 , y 4 y6 0 0 1 1 0. c46 c46 a7 4,6 is a profitable arc. Backward arcs in C ( 2) : (4, 5) and (5, 6) Since min {x45, x56} = min {0, 11} = 0, a6 4,5 is the leaving arc. 73 2.2 Initialization x ( 3) x ( 2) , but T(3) is different from T(2). 74 2.2 Initialization Iteration 3. y7 , y6 , y5 , y3 , y 2 , y1 don’t change, 1 0 1. y 4 y6 c46 So, y(3) = [ 0 0 0 1 0 1 0 ]. For arc a2 1,4 , c14 c14 y1 y 4 0 0 1 1 0 a2 1,4 is a profitable arc. 75 2.2 Initialization Since min {x12, x25, x56} = min {6, 10, 11} = 6, a1 1,2 is the leaving arc. x(4) = [ 0 6 0 4 8 0 6 7 0 0 5 ]T. 76 2.2 Initialization Iteration 4. y2 y7 don’t change, y1 y 4 c14 1 0 1 . So, y(4) = [ 1 0 0 1 0 1 0 ]. For the 5 arcs not in T(4), So, there are no profitable arcs, and x(4) is the optimal solution of problem P . But the flow on the artificial arc (5, 6) is positive, which means the original problem is infeasible. c67 0 y6 y7 1 c15 0 y1 y5 2 c45 0 y 4 y5 1 c23 0 y 2 y3 0 c12 0 y1 y 2 1 77 2.2 Initialization Integer Solutions If all supplies / demands are integer values, i.e. b is an integer vector, then the optimal solution x* of the transshipment problem, obtained by the network simplex method, must be an integer vector. Why? because the incidence matrix A is unimodular. 78 2.2 Initialization Let A be the n 1 m matrix obtained by deleting the first row of A; and b be the n 1 1 vector obtained by deleting the first component of b. Then the equation Ax b is equivalent toA x b (since rank(A) = n-1). Any feasible tree solution x corresponds to a nonsingular n 1 (n 1) submatrix B of A such that x T xBT , x TN , where x N 0 and BxB b . p x x x So, each component i of B has the form i , det B where p is an integer. Since A is unimodular, as a nonsingular square submatrix of A, B must satisfy det B 1 . So, x i must be an integer. 79 2.2 Initialization Unbalanced Transshipment Problem So far we consider balanced transshipment problem, i.e. total supply = total demand. Now if total supply > total demand we let r = total supply - total demand and introduce one dummy sink v with the demand r and an arc from each source vertex s i to v with zero cost. Hence the unbalanced problem becomes a balanced problem in the enlarged network. 80 2.2 Initialization Note that if in the optimal solution, the supply of the source i is bi and the flow from i to the dummy vertex v is xiv 0 , then the source i sends out only bi xiv units of the commodity and remains xiv units at its place. 81 2.4 Transportation Problems Motivating Example: A number of warehouses must ship a single commodity to a number of manufacturing plants. Shipping costs are proportional to distance and the amount shipped. What shipping pattern will minimize total shipment costs? 82 2.4 Transportation Problems 83 2.4 Transportation Problems A transportation problem is a special transshipment problem in which (1) there is no intermediate vertices (i.e. every vertex is either a source, or a sink). (2) every arc is from a source to a sink. The underlying graph of a transportation problem is a bipartite graph. 84 2.4 Transportation Problems G = (S, D, E). S ~ the set of sources, denoted by S i (i = 1, … , m); D ~ the set of sinks, denoted by D j (j = 1, …, n); E ~ the set of arcs i, j from a source S i to a sink D j . Flow matrix: m n matrix x ~ xij is the flow on the arc i, j ; ij 85 2.4 Transportation Problems Cost matrix: m n matrix c ~ cij is the cost to send one unit of the commodity from S i to D j . Note that if actually there is no arc from S i to D j , in order to express the problem easily, we assume that there is an arc i, j , but the cost is very expensive, i.e. let cij M , where M is a very large number. ij 86 2.4 Transportation Problems Now the transportation problem can be expressed mathematically as m n min cij xij s.t. i 1 j 1 n x j 1 ij m x i 1 xij 0 ij bi , for i = 1, … , m (1) b j , for j = 1, … , n (2) for i = 1, … , m; j = 1, … , n (3) 87 2.4 Transportation Problems The constraint equations (1) and (2) can be jointly expressed as: A x = b, where A is an (m+n) x mn matrix, which is in fact the incidence matrix of the associated bipartite graph (hence is a unimodular one according to Corollary 1.3b); b is an m+n vector by combining the right-handside of the equations (1) and (2); and x is an m∙n vector consists of all xij . 88 2.4 Transportation Problems Transportation problem can be solved on a particularly designed tableau, called the transportation tableau. 89 2.4 Transportation Problems Finding an initial FTS ~ the northwest corner method. 90 2.4 Transportation Problems Note that the m+n-1 = 6 filled xij entries, together with other xij 0 , form an initial FTS. The arcs corresponding to the filled xij entries form a spanning tree T. 91 2.4 Transportation Problems Calculating dual solution y associated with the tree T We use the equation yi cij y j for any arc i, j T to determine y. In the above example, let y7 0 . y3 c37 y7 y3 0 8 8 y5 ... y3 c36 y6 y6 8 9 1 y1 ... y2 c26 y6 y2 1 7 6 y4 ... We fill in y1 ~ y3 to the right-most column and y4 ~ y7 to the bottom row. 92 2.4 Transportation Problems Checking if there is a profitable arc For each arc i, j T, calculate dij cij yi y j and check if all such dij 0 . If yes, an optimal solution is obtained. But d16 c16 y1 y6 3 8 1 6 0 1,6 is profitable. 93 2.4 Transportation Problems Deciding the leaving arc Starting from the cell (1, 6) in the tableau, move horizontally or vertically until return to the cell (1, 6) to form a cycle. 1,6 2,6 2,5 1,5 1,6 It is seen that in the cycle 1 6 2 5 1 the arcs are forward and backward alternatively. 94 2.4 Transportation Problems Put a + in the tableau for every forward arc; Put a - in the tableau for every backward arc; Decide t = min { xij | i, j is a backward arc}. 95 2.4 Transportation Problems Moving from a non-optimal tableau to the next tableau Let xijnew xij t xij t xij If (i, j) is a forward arc; If (i, j) is a backward arc; Other arcs 96 2.4 Transportation Problems Introduce the entering (profitable) arc into the new tree; remove the leaving arc from the tree. Note that in the example the two backward arcs (1, 5) and (2, 6) both have x15 x26 t 10. In this case, we can choose either one as a leaving arc (in the example (2,6) is chosen to leave the tree), but not both, because to maintain a spanning tree need to have m+n-1 = 6 arcs. So far we completed one iteration and switch to a new tableau. 97 2.4 Transportation Problems Example 2.7 If an FTS is given by the circled numbers in the tableau below, and suppose the entering cell is (3, 7), how to form a cycle in the tableau? 98 2.4 Transportation Problems Note that when we are at (1, 8) and move horizontally, we have to skip the cell (1, 6) and reach (1, 4). Then we move vertically. If we change the moving direction at (1, 6), no cycle can be formed. 99 2.5 Some Applications to Combinatorics Definition A matching in a graph is a set M of edges of the graph such that no two edges in M have a vertex in common. graph G a matching of G 100 2.5 Some Applications to Combinatorics In a bipartite graph G = (X, Y, E) where X and Y both have n vertices (it is possible that between some pair of vertices x X and y Y , there exists no edges, i.e., G may not be a complete bipartite graph), a matching M is called a perfect matching if there are n edges in M. 101 2.5 Some Applications to Combinatorics This bipartite graph has no perfect matching This graph has a perfect matching M u1 , v3 , u 2 , v2 , u3 , v1 102 2.5 Some Applications to Combinatorics A graph is called a regular graph of degree k if the degree of each vertex is k. 2-regular graph Theorem 2.5 (Konig’s marriage theorem) A regular bipartite graph G(U, V, E) of degree k (where k is a positive integer) with U V n has a perfect matching. 103 2.5 Some Applications to Combinatorics Proof We formulate a transportation problem as follows: Let the vertices in U be sources; the vertices in V be sinks; For each edge {u, v} E , give an arc from u U to v V . Let the supply at each source be 1; the demand at each sink be 1; the unit cost cuv on each arc (u, v) be 1. 104 2.5 Some Applications to Combinatorics This problem is feasible because if we let the flow along each arc be 1 k , it is a feasible flow. Also, the supply-demand vector is an integer vector as the incident matrix of a bipartite graph is unimodular. Therefore, the transportation problem must have an integer optimal solution x*. In fact as all supplies / demands are 1, x* must be a 0-1 vector. * x Let M = { (u, v) | uv 1 , u, v = 1, … , n }. It is easy to see that |M|=n, i.e., M must be a perfect matching. 105 2.5 Some Applications to Combinatorics Example Does the following bipartite graph have a perfect matching? If yes, give a perfect matching. As this is a regular graph of degree 2, it has a perfect matching. Find a perfect matching by yourself. 106 2.5 Some Applications to Combinatorics Definition A covering in a graph is a set W of vertices such that every edge of the graph is incident to at least one of the vertices in W. v6, v1, v3, v4 (or v5) is a covering of the left graph 107 2.5 Some Applications to Combinatorics For any matching M and any covering C of a graph, suppose M k the graph has k edges e u ,v , e u ,v ,… , e u , v , such that all u i and vi are different to cover these k edges, we need to use at least k vertices from u1 ,...,uk , v1 ,...,vk a covering C must have at least k vertices 1 k k 1 1 2 2 2 k C k 108 2.5 Some Applications to Combinatorics Therefore, M C for any matching M and any covering C max{|M | : for all M } min{|C | : for all C} This result can be strengthened to become an equality if bipartite graphs are concerned. (Just like Primal and Dual) 109 2.5 Some Applications to Combinatorics Theorem 2.8 (Konig’s Theorem) In any bipartite graph, the size of a maximum matching equals to the size of a minimum covering. 110 2.5 Some Applications to Combinatorics Konig’s Theorem can be translated equivalently to the context of matrices. We use the term a line to denote either a row, or a column. Suppose P is a property that an element of a matrix may or may not have. We call an element of a matrix a P-element if it has the property. A set of P-elements is said to be P-independent if no two of them lie on the same line. The size of the largest P-independent set is called the P-rank of the matrix. 111 2.5 Some Applications to Combinatorics Example 2.10 Let matrix 1 0 A 0 0 0 1 1 0 0 1 0 0 1 0 0 1 0 0 1 1 An element of A is said to have property P if it is positive, i.e., if its value is 1. Obviously, the P-rank of A is 3 as a largest Pindependent set contains 3 elements, for example, the (1, 1)th, (2, 3)th and (5, 4)th element of A. 112 2.5 Some Applications to Combinatorics Theorem 2.9 (Konig-Egervary Theorem) The P-rank of a matrix A is equal to the minimum number of lines that contain all P-elements of the matrix. 113 2.5 Some Applications to Combinatorics Proof We construct a bipartite graph. Let each row i of A correspond to a left vertex i; each column j of A correspond to a right vertex j. th i , j Introduce edge i, j if and only if the element of A is a P-element. 1 0 A 0 0 0 1 1 0 0 1 0 0 1 0 0 1 0 0 1 1 114 2.5 Some Applications to Combinatorics By Theorem 2.8, Size of a max. matching = Size of a min. covering. Now, a matching is a set of edges, all with different (left and right) endpoints. (correspond to) a set of P-elements in different rows/columns, i.e. a P-independent set. So, Size of a max. matching = Size of the largest Pindependent set = P-rank of A. 115 2.5 Some Applications to Combinatorics A covering is a set of vertices such that every edge of the graph is incident to at least one of these vertices. (correspond to) a set of rows and columns such that each P-element is contained in one of these lines. So, Size of a min. covering = minimum number lines of A that contain all P-elements of the matrix. Thus, the theorem is proved. 116 2.6 Assignment Problem The assignment problem is a special kind of transportation problem in which (1) the supply at each source and the demand at each sink are equal to 1. (2) the number of sources = the number of sinks. 117 2.6 Assignment Problem Let cij be the cost to send one unit of product (or sevice) from source i to sink j. The mathematical formulation of the assignment problem is n min cij xij i , j 1 n x ij 1, s.t. j 1 n x ij 1 , i 1 x 0 , ij i 1,...,n j 1,...,n i, j 1,..., n 118 2.6 Assignment Problem Note that actually we are interested in integer solutions, i.e. xij should be 0 or 1, but this request does not need to be imposed explicitly, because the unimodular property for bipartite graph guarantees an integer optimal solution. 119 2.6 Assignment Problem Example A mill has 4 machines and 4 jobs to Time (hours) be completed. Each machine must be Job 1 Job 2 Job 3 assigned to complete Machine 1 14 5 8 one job. The times Machine 2 2 12 6 required to complete Machine 3 7 8 3 each job on different Machine 4 2 4 6 machines are shown in the table: Decide an assignment scheme to minimize the total time needed to complete the 4 jobs. Job 4 7 5 9 10 120 2.6 Assignment Problem Method 1 use the method for transportation problems. Method 2 the Hungarian method. Theorem 2.17 Suppose C is the cost matrix and C' is the matrix obtained by adding a number t to each element in a row or to each element in a column. Then a solution is optimal with respect to C' if and only if it is optimal with respect to C. 121 2.6 Assignment Problem Proof Suppose the k th row is added by t, i.e. ckj ckj t , j 1,...,n and cij cij , for i k and j 1,...,n Then for any feasible solution [ xij ] , n n n n n n cij xij = cij xij ckj xkj = cij xij ckj t xkj i 1 j 1 i k j 1 n n n j 1 c x t x = = c x t Therefore, under C and C’ , the optimal solutions are the same. i 1 j 1 i k j 1 j 1 ij ij j 1 n n kj i 1 j 1 ij ij 122 2.6 Assignment Problem Based on this theorem, we can change C to C’ such that each row and each column of C’ has at least one zero entry by the following operations: Step 1 Subtract each row by its smallest entry; Subtract each column by its smallest entry. 123 2.6 Assignment Problem 2 examples 4 6 A 1 5 7 4 9 9 8 B7 5 9 5 10 11 1 3 2 4 (1) 3 4 2 2 4 5 (2) 3 4 1 1 (1) A 0 2 3 4 1 (1) 4 4 6 5 3 3 (3) 3 11 4 (3) 1 3 10 8 (3) 6 3 8 6 (3) 4 3 4 6 (3) 6 7 10 11 (7) 3 0 2 1 3 0 0 2 3 2 3 0 0 1 2 3 0 3 2 0 0 6 0 8 1 0 5 5 0 7 5 2 0 5 3 B 3 2 0 1 3 5 2 4 0 3 4 (-1) (-2) (-1) (-1) 4 0 7 0 3 0 6 4 0 0 4 2 0 0 0 2 2 0 2 3 124 2.6 Assignment Problem If in such modified matrix C’ , there are n zero entries and not two of them in the same row or same column, for example y 0 c y y y y 0 y 0 y y y y y y 0 (all y are non-negative numbers) cx * 0 then obviously other x 0 i, j 1,2,3,4 is an optimal solution, because for any 125 feasible solution x, * * * * x13 x21 x32 x44 1 , * ij 2.6 Assignment Problem c'ij , xij 0 c'ij xij 0, * c ' x but ij ij 0. Question: How to check if C’ has zero entries at all different rows and columns? This is in the method of step 2. Step 2 Check whether C’ has n zero entries at different rows and columns. If the answer is yes, then an optimal assignment is obtained by taking the assignment corresponding to the n zero entries and we stop. Otherwise we go to Step 3. 126 2.6 Assignment Problem This step can be fulfilled by the following sub-steps. Step 2a Locate a row or a column in C’ with exactly one 0, and the 0 is selected. If every line (row or column) has more than one zero, a line with the minimum number of 0s is located, and we select anyone of the 0s in this line. This line should not be located again (we can put a check mark beside it) 127 2.6 Assignment Problem Put a circle around the selected 0, and draw a line through (covering) the 0. This line should be a vertical line if the line located is a row, and a horizontal line if the line located is a column. 128 2.6 Assignment Problem Step 2b Repeat the previous step (but do not consider any 0 which has been covered by a line) till every 0 has at least one line through it. Step 2c If the number of lines drawn is n, the n selected (circled) 0s will point out an optimal solution. If the number of lines is less than n, we go to Step 3. 129 n = 5 (lines), we obtain an optimal solution which * * * * * xis12 x23 x45 x54 x31 1 and other xij* 0 i, j 1,...5 2.6 Assignment Problem Examples A 3 4 0 3 4 0 2 1 3 0 0 2 3 2 3 0 0 1 2 3 0 3 2 0 0 3 4 0 3 4 0 2 1 3 0 0 2 3 2 3 0 0 1 2 3 0 3 2 0 0 3 4 0 3 4 0 2 1 3 0 0 2 3 2 3 0 0 1 2 3 0 3 2 0 0 3 4 0 3 4 0 2 1 3 0 0 2 3 2 3 0 0 1 2 3 0 3 2 0 0 3 4 0 3 4 3 4 0 3 4 0 2 1 3 0 0 2 3 2 3 0 0 1 2 3 0 3 2 0 0 0 2 1 3 0 0 2 3 2 3 0 0 1 2 3 0 3 2 0 0 130 2.6 Assignment Problem B 0 5 3 5 2 0 5 3 5 2 4 0 7 0 3 0 6 4 0 0 4 2 0 0 0 2 2 0 2 3 4 0 7 0 3 0 6 4 0 0 4 2 0 0 0 2 2 0 2 3 0 5 3 5 2 4 0 7 0 3 0 6 4 0 0 4 2 0 0 0 2 2 0 2 3 0 5 3 5 2 0 5 3 5 2 4 0 7 0 3 0 6 4 0 0 4 2 0 0 0 2 2 0 2 3 4 0 7 0 3 0 6 4 0 0 4 2 0 0 0 2 2 0 2 3 n = 4 < 5, so, we are unable to obtain an optimal assignment by using the modified matrix B . 131 2.6 Assignment Problem Generally, if the number of lines needed to cover the zeros is k and k<n, we call the 0 element in the matrix as P-element and by Th. 2.9, we know that the P-rank of the matrix is k, i.e., the maximal number of 0 elements in different rows and columns is k. In this case, we need to modify the matrix c further to create more 0s in the right place. Let m be the smallest value of the uncovered elements. We subtract m from all uncovered rows ~ so that more 0s appear in the previously uncovered part. 132 2.6 Assignment Problem Example 0 5 B 3 5 2 m=2 4 0 7 0 0 7 0 0 4 3 0 6 4 (2) 3 1 2 4 2 0 0 4 2 (2) 1 2 2 2 0 0 0 0 2 5 0 0 0 2 2 0 2 3 (2) 0 0 2 0 1 However, now in the covered column, some 0 become –m which are negative. We now add m to the covered columns. (+2) (+2) 0 3 1 5 0 6 2 7 0 3 0 4 2 0 0 2 0 B 2 2 0 2 2 0 0 1 133 2.6 Assignment Problem The above operations can be further simplified. We divide all elements in the matrix obtained at Step 2 into 3 groups. (1) Uncovered elements. (2) Singly covered elements ~ covered by only one line (a row or a column) (3) Doubly covered elements ~ covered by two lines: a row and a column. 134 2.6 Assignment Problem Step 3a Find the value of the smallest uncovered element. Suppose it is m. We (a) subtract m from all uncovered elements; (b) add m to all doubly covered elements. (and keep the singly covered elements unchanged) 135 2.6 Assignment Problem For example, if we apply the operations (a) and (b) to B : 0 5 B 3 5 2 4 0 7 0 0 3 3 0 6 4 0 0 4 2 1 0 0 0 2 5 0 2 0 2 3 6 2 7 0 3 0 4 2 0 0 2 0 2 2 0 2 2 0 0 1 . which is just B 136 2.6 Assignment Problem Note that the 0s to be selected to draw the lines (i.e. the 0s with ) are singly covered, hence they are still 0. But some elements in the uncovered part become 0 ~ new 0, and thus need to use more lines to cover all 0. 137 2.6 Assignment Problem Step 3b Delete all covering lines and go back to Step 2. 0 3 B 1 5 0 6 2 7 0 0 3 0 4 2 3 0 0 2 0 1 2 2 0 2 5 2 0 0 1 0 6 2 7 0 3 0 4 2 0 0 2 0 2 2 0 2 2 0 0 1 138 2.6 Assignment Problem Now the number of lines to cover all 0s = 5 = n. So, we obtain an optimal assignment: * * * * * * x x15 x23 x32 x44 x51 1 and other ij 0 , i.e. source 1 sink 5, source 2 sink 3, source 3 sink 2, source 4 sink 4, source 5 sink 1. 139