Flow in Network Graph, oriented graph, network • A graph G =(V, E) is specified by a non empty set of nodes V and a set of edges E such that each edge a is identified by a pair of nodes (u, v). 1 a c b 3 d 2 V = {1, 2, 3} E = {a, b, c, d} a = b = (1, 2) ; c = (1, 3) ; d =(2, 3) • A graph g is a sub graph of a graph G if all the nodes and all the edges of g are nodes and edges of G. 1 a 1 c b c 3 3 d 2 G g • A sub graph of a graph G including all the nodes of G is a partial graph of G. 1 a 1 c b c 3 d 3 d 2 2 G g • A chain in a graph G is a sequence of distinct edges a1, a2, …, ap such that there exist (p+1) nodes u1, u2, …, up+1 where ai= (ui, ui+1). 1 a c b 3 d 2 The sequence a, c is a chain. • A cycle in a graph G is a chain such that u1 = up+1 1 a c b 3 d 2 The sequence c, b, d is a cycle. • A graph G is connected if for all pair of nodes, there exists a chain linking them. 1 a c b 3 d 2 This graph is connected. • A tree is a connected graph with no cycle Property : A tree with n nodes includes exactly (n – 1) edges • A partial tree ( spanning tree) of a connected graph G is a partial graph of G being a tree 1 a 1 c b c 3 d d 2 2 G partial tree 3 • A fondamental cycle with respect to a partial tree is a cycle including an edge of the graph not included in the partial tree and edges of the tree. 1 a 1 c b c 3 d d 2 2 G partial tree 3 • A fondamental cycle with respect to a spanning tree is a cycle including an edge of the graph not included in the partial tree and edges of the tree. 1 a 1 c b 3 c a d d 3 2 2 G fondamental cycle • An oriented graph G = (V, E) is specified by a non empty set of nodes V and a set of arcs E such that each arc a is identified by an ordered pair of nodes (u, v). 2 a c 1 e b d 3 4 f V = {1, 2, 3, 4} E = {a, b, c, d, e, f} a = (1, 2), b = (2, 4), c = (2, 3), d =(3, 2), e = (1, 3), f = (3, 4) • A non oriented graph obtained from an oriented graph G by eliminating the direction of the arc is denoted the corresponding graph. • The notions of chain, cycle, connectedness, tree, spanning tree, and fondamental cycle for an oriented graph refer to the corresponding graph. • A path in an oriented graph is a sequence of distinct arcs a1, a2, …, ap being a chain where all the arcs are oriented in the same direction. • A directed graph is simple if the nodes identifying each arc are distinct, and if there is no pairs of arcs specified by the same pair of nodes. • A network is a connected oriented graph in which a flow can move over the arcs. Each arc (i, j) est characterized as follows a capacity dij corresponding to an upper bound on the flow in the arc a lower bound lij on the flow in the arc Moreover, 0≤ lij ≤ dij [0, 2] [0, 6] 2 1 [2, 9] [3, 4] 4 [0, 4] [1, 6] 3 At each arc (i, j) is associated a pair [lij , dij]. Minimum cost flow model • Consider a network where the following attributs are associated with each arc (i, j) : dij the capacity of the arc lij the lower bound on the flow in the arc cij flow unitary cost in the arc xij the variable including the value of the flow in the arc • Furthermore, associate the following two sets of nodes with each node i: Bi j V : ( j , i ) E Pi j V : (i, j ) E Exemple B1= Φ , B2= {1, 3}, B3= {1, 2}, B4= {2, 3} P1= {2, 3}, P2= {3, 4}, P3= {2, 4}, P4= Φ 1 [0, 2] [0, 6] 2 [2, 9] [3, 4] 4 [0, 4] [1, 6] 3 • The minimum cost flow problem is to determine how to send a fixed quantity of flow v from a source sV to a destination t V along the arcs of the network satisfying the lower bound and the capacity constraints of the arcs in order to minimize the total cost. • Constraints of the problem: 1. lower bound and the capacity constraints of the arcs: lij xij dij (i, j ) E 2. flow conservation constraints (specific to network flow problems): For each node i V the total flow going in the node must be equal to the total flow going out of the node • For each node, the total flow going in the node must be equal to the total flow going out of the node. For the source s v x js xsj jBs or 2 v 1 4 3 jPs x jPs sj x js v jBs • For each node, the total flow going in the node must be equal to the total flow going out of the node. For the destination t x jBt 2 1 4 3 jt xtj v jPt v or x x jPt tj jBt jt v • For each node, the total flow going in the node must be equal to the total flow going out of the node. For an intermediate node i x 2 1 jBi 4 3 ji xij jPi or x x jPi ij jBi ji 0 Model for the minimum cost flow problem • The minimum cost flow problem is to determine how to send a fixed quantity of flow v from a source sVto a destination t V along the arcs of the network satisfying the lower bound and the capacity constraints of the arcs in order to minimize the total cost. (MCF) (MCF) (MCF) min cij xij s.t. (flow conservation) ( i , j )E (flow x v xconservation) (flow conservation) xsj x js v jPs jBs xij x ji 0 i s, t jPi jBi xtj x jt v jPt jBt (capacity lij xij d ij c x ij ij ( i , j )E cij xij ( i , j )E s.t. s.t. jPs min min (i , j ) E sj jBs js v si i s xij x ji 0 i s, t si i s, t Bi x ji 0 jPixij j jPi jB xtj i x jt vv si i t jPt jBt (capacity) (capacity) lijlij xij ddijij (i(,ij,)j) EE (FCM) cij xij min (i , j )E Sujet à (conservation de flot) v si i s xij x ji 0 si i s, t jPi jBi v si i t colonne (i, j) x ij (capacité) 0 0 • The matrix associated with the flow conservation constraints are 1 denoted ligne i 0 the nodes-arcs incidence matrix: j Pi row i ↔ node i 0 column (i, j) ↔ arc (i, j) 1 ligne j i Bj 0 0 lij xij dij (i, j ) E • Exemple of an incidence matrix (MCF) min cij xij ( i , j )E s.t. (flow conservation) v si i s xij x ji 0 si i s, t jPi jBi v si i t (capacity) lij xij d ij 2 (i , j ) E 1 4 3 x12 x13 x 23 x 24 x32 x34 1 2 3 4 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0 0 1 0 1 • The nodes-arcs incidence matrix has the unimodularity property indicating that the simplex algorithm generates an integer solution for problem (MCF) when lij, dij et v are integer. (MCF) min cij xij ( i , j )E s.t. (flow conservation) v si i s xij x ji 0 si i s, t jPi jBi v si i t (capacity) lij xij d ij (i , j ) E (MCF) min cij xij ( i , j )E s.t. (flow conservation) Properties of the incidence matrix v A si i s xij x ji 0 si i s, t jPi jBi v si i t • Now we show that the columns of any basis correspond to (capacity) arcs in a lij xij d ij spanning tree and vice versa. (i , j ) E • Theorem: The incidence matrix A of a connected simple oriented graph having m nodes and n arcs has a rank equal to (m–1). Proof: First we show that rank A m 1 . Each column of A includes only one component equal to 1, another one equal to -1, and all the other elements are equal to 0. Hence if we sum up the rows of A, then we obtain a row vector having all its elements equal to 0. Consequently the rows of A are linearly dependent. Thus rank A m 1 . • Exemple of incidence matrix 2 1 4 3 x12 x13 x 23 x 24 x32 x34 1 2 3 4 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0 0 1 0 1 _____________________ 0 0 0 0 0 0 Now we show that rank A m 1 . Suppose that there exist a set K of k rows of A ai1 , , aik that are linearly dependent. There exists scalars 1, , k that are not all equal to 0 such that 1ai k ai 0, ,0. Since each column of the matrix A includes exactly one element equal to 1 and another one equal to -1, if j 0, then for all element different 1 k from 0 in row ai j , we must find in the set K , the row of A including the corresponding complementary element different from 0. • Exemple of incidence matrix 2 1 4 3 x12 x13 x 23 x 24 x32 x34 1 2 3 4 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0 0 1 0 1 Now we show that rank A m 1 . Suppose that there exist a set K of k rows of A ai1 , , aik that are linearly dependent. There exists scalars 1, , k that are not all equal to 0 such that 1ai k ai 0, ,0. Since each column of the matrix A includes exactly one element equal to 1 and another one equal to -1, if j 0, then for all element different 1 k from 0 in row ai j , we must find in the set K , the row of A including the corresponding complementary element different from 0. If we reapply the reasonning for all elements j 0, we find that K includes all the rows of A since the oriented graph is simple and connected. Hence k m, and consequently all subsets of rows of the matrix A where m 1 , are linearly independent. Then rank A m 1 . It follows that rank A m 1 . • Theorem: Consider an incidence matrix A associated with a simple connected directed graph G including m nodes and n arcs. A square (m – 1)x (m – 1) sub matrix of A is non singular if and only if the arcs associated to its columns are those specifying a spanning tree of G. Theorem: Consider an incidence matrix A associated with a simple connected directed graph G including m nodes and n arcs. A square (m 1) x (m 1) sub matrix of A is non singular if and only if the arcs associated to its columns are those specifying a spanning tree of G. Proof: Let T be a spanning tree of G illustrated in red. 2 1 4 3 x12 x13 x 23 x 24 x32 x34 1 2 3 4 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0 0 1 0 1 Proof: Let T be a spanning tree of G illustrated in red. Denote by A(T) the mx(m˗1) sub matrix A being the incidence matrix of T. 2 1 4 3 x12 x13 x 23 x 24 x32 x34 1 2 3 4 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0 0 1 0 1 Proof: Let T be a spanning tree of G illustrated in red. Denote by A(T) the mx(m–1) sub matrix A being the incidence matrix of T. Since T is a simple connected graph, it follows from the preceding theorem that rank(A(T)) = (m–1). 2 1 4 3 x12 x13 x 23 x 24 x32 x34 1 2 3 4 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0 0 1 0 1 Proof: Let T be a spanning tree of G illustrated in red. Denote by A(T) the mx(m–1) sub matrix A being the incidence matrix of T. Since T is a simple connected graph, it follows from the preceding theorem that rank(A(T)) = (m–1). Then all (m – 1)x (m – 1) sub matrices obtained by eliminating a row of A(T) is non singular. 2 But these sub matrices 1 4 x12 x13 x 23 x 24 x32 x34 are also sub matrices of A. 1 1 1 0 0 0 0 3 2 3 4 1 0 1 1 1 0 0 1 1 0 1 1 0 0 0 1 0 1 Theorem: Consider an incidence matrix A associated with a simple connected directed graph G including m nodes and n arcs. A square (m 1) x (m 1) sub matrix of A is non singular if and only if the arcs associated to its columns are those specifying a spanning tree of G Let B be a (m – 1)x (m – 1) square non singular sub matrix of A. 2 1 4 3 x12 x13 x 23 x 24 x32 x34 1 2 3 4 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0 0 1 0 1 Let B be a (m – 1)x (m – 1) square non singular sub matrix of A. 2 1 4 3 x12 x13 x 23 x 24 x32 x34 1 2 3 4 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0 0 1 0 1 Let B be a (m – 1)x (m – 1) square non singular sub matrix of A. B is obtained by eliminating a row from an incident matrix of a spanning tree g of G. 2 1 4 3 x12 x13 x 23 x 24 x32 x34 1 2 3 4 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0 0 1 0 1 Let B be a (m – 1)x (m – 1) square non singular sub matrix of A. B is obtained by eliminating a row from an incident matrix of a spanning tree g of G. This sub graph g is simple, connected, including (m – 1) arcs. 2 Then g is a spanning tree 1 4 x12 x13 x 23 x 24 x32 x34 of G. 3 1 2 3 4 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0 0 1 0 1 • Theorem: The incidence matrix A of a connected simple oriented graph having m nodes and n arcs has a rank equal to (m–1). • Theorem: Consider an incidence matrix A associated with a simple connected directed graph G including m nodes and n arcs. A square (m – 1)x (m – 1) sub matrix of A is non singular if and only if the arcs associated to its columns are those specifying a spanning tree of G. Any base from the incidence matrix is such that its columns correspond to variables associated with the arcs of a spanning tree, and vice versa. The basic variables of a basic solution of a (MCF) problem correspond to the arcs of a spanning tree and vice-versa. The simplex method for the minimum cost flow problem • We use the variant of the simplex method when the variables are bounded to solve the minimum cost flow problem (MCF): (MCF) min ( i , j )E cij xij s.t. (flow conservation) v si i s x x 0 si i s, t ij ji jPi jBi v si i t (capacity) 0 xij d ij (i , j ) E where Bi j V : ( j, i) E et Pi j V : (i, j) E • To analyse one iteration of the simplex method, suppose that we have a basic feasible solution x of the problem. Then the non basic variables xij are such that xij = 0 ou dij. The basic variables xij correspond to the arcs of a spanning tree T of the network. v4 • Entering criterion determine the relative costs of the variables xij : T [1 ,..., i ,..., j ,..., m ] x ij cij cij aij T that can be written as c ij cij i j Moreover, for the basic variables associated to the arcs (i, j ) E (T ) of the spanning tree T : c ij cij i j 0 (i, j) E(T ) aij 0 0 1 0 0 1 0 0 ligne i ligne j c ij cij i j 0 (i, j ) E(T ) In a tree (# arcs) = (# nodes) –1. The preceding system includes (m – 1) équations (associated to the arcs (i, j ) E (T ) ) et m unknown πi (associated to the nodes i of T). But since any sub matrix (m – 1)x (m – 1) of the incidence matrix T is non singular, we can fix the value of one multiplier and to evaluate the others using the system. The system of equations being triangular, it is easy to show that the multipliers are evaluated sequentially one by one. c ij cij i j 0 (i, j) E(T ) In our exemple (1) 0 c s1 c s1 s 1 4 s 1 (2) 0 c s 2 c s 2 s 2 1 s 2 (3) 0 c 23 c 23 2 3 3 2 3 (4) 0 c1t c1t 1 t 1 1 t Let πt = 0 πs=5 π1=1 πt=0 (4) 0 1 1 t 0 1 1 1 1 (1) 0 4 s 1 0 4 s 1 s 5 (2) 0 14 s 2 0 1 5 2 2 4 (3) 0 3 4 2 3 0 3 4 3 3 1 π2=4 π3=1 Once the values of the multipliers are known, determine the relative costs c ij cij T aij of the non basic variables associated to the arcs that are not belonging to the spanning tree T. In our exemple πs=5 π1=1 πt=0 c 21 c 21 2 1 2 4 1 1 c 3t c3t 3 t 2 1 0 1 π2=4 π3=1 Once the values of the multipliers are known, determine the relative costs c ij cij i j of the non basic variables associated to the arcs that are not belonging to the spanning tree T. Recall the optimality criterion If cij 0 (i, j ) E (T ) où xij 0 cij 0 (i, j ) E (T ) où xij d ij , and then the current solution is optimal. Otherwise select one of the variables (admissibles) xij where the optimality criterion is not satisfied. If the admissible variable xij = 0, then its value increases, and if the value xij d ij , then its value decreases. Once the values of the multipliers are known, determine the relative costs c ij cij T aij of the non basic variables associated to the arcs that are not belonging to the spanning tree T. In our exemple πs=5 π1=1 πt=0 c 21 c 21 2 1 2 4 1 1 c 3t c3t 3 t 2 1 0 1 x21 is admissible to increase x3t is admissible to decrease π2=4 π3=1 Recall: Step 1: Selecting the entering variable The criterion to select the entering variable must be modified to account for the non basic variables xj being equal to their upper bounds uj since these variables can be reduced. Hence, for an index j JB if x j 0 et c j 0 , it is interesting to increase xj if x j u j et c j 0 , it is interesting to decrease xj c min c , c Determine c s1 min jJB Let c s s1 s2 j : x j 0 and c s2 max c j : x j u j max c jJB s1 , c s2 If c s 0, then the solution is optimal, and the algoithm stops. If c s 0 and c s c s1 , then the non basic variable xs increases, and go to Step 2.1. If c s 0 et c s c s1 , then the non basic variable xs decreases, and go to Step 2.2. Once the values of the multipliers are known, determine the relative costs c ij cij T aij of the non basic variables associated to the arcs that are not belonging to the spanning tree T. In our exemple πs=5 π1=1 πt=0 c 21 c 21 2 1 2 4 1 1 c 3t c3t 3 t 2 1 0 1 x21 is admissible to increase x3t is admissible to decrease π2=4 Entering variable π3=1 Recall: A fondamental cycle with respect to a spanning tree is a cycle including an edge of the graph not included in the partial three and edges of the three. • Leaving criterion Evaluate the impact of modifying the value of the entering variable on the values of the basic variables. It is easy to verify that only the values of the flow on the arcs of the fondamental cycle associated to the arc associated to the entering variable are modifed. In our exemple: x3t is the entering variable In cases i) or ii) where the modification Determine the largest value of the modification of the entering variable before of the entering variable is limited, i) the value of a basic variable xij from the base being replace by reduce to 0 ii) the value of a basic variable xij reach its capacity dij iii) the entering variable move between from one of its bound to the other then the entering variable xij exits the entering variable. The new basis T where the arc i, j T is remplaced by the entering arc. In case iii), we adjust the values of the flow on the arcs of the fondamental cycle, and we move to the next iteration with the same basis. To complete the iteration, the value of the entering variable is reduces by . The largest value of 2 since the flow in arc 1, t reach its capacity d1t 2. The variable x1t is replaced by the variable x3t in the basis. 0+θ 0+θ 4-θ 4-θ 4-θ To complete the iteration, the value of the entering variable is reduces by . The largest value of 2 since the flow in arc 1, t reach its capacity d1t 2. The variable x1t is replaced by the variable x3t in the basis. The new solution and the spanning tree associated are as follows Second iteration : Entering criterion Determine the multipliers by solving the system: (1) 0 c s1 c s1 s 1 4 s 1 (2) 0 c s 2 c s 2 s 2 1 s 2 (3) 0 c 23 c 23 2 3 3 2 3 (4) 0 c 3t c3t 3 t 2 3 t (1) 0 c s1 c s1 s 1 4 s 1 (2) 0 c s 2 c s 2 s 2 1 s 2 (3) 0 c 23 c 23 2 3 3 2 3 (4) 0 c 3t c3t 3 t 2 3 t Let πt = 0 (4) 0 2 3 t 0 2 3 3 2 (3) 0 34 2 3 0 3 2 2 2 5 (2) 0 14 s 2 0 1 s 5 s 6 (1) 0 4 s 1 0 4 6 1 1 2 Determine the relavive costs of the non basic variables c ij cij i j 0 πs= 6 4 π1= 2 πt= 0 2 1 c21 c21 2 1 2 5 2 1 c1t c1t 1 t 1 2 0 1 π2= 5 3 π3= 2 c 21 c 21 2 1 2 5 2 1 c1t c1t 1 t 1 2 0 1 Since x1t 2 d1t and c1t 1, then x1t is not admissible. The variable x21 0 and c21 1, then x21 becomes the entering 4 variable that is increasing. 2 1 3 c 21 c 21 2 1 2 5 2 1 c1t c1t 1 t 1 2 0 1 Since x1t 2 d1t and c1t 1, then x1t is not admissible. The variable x21 0 and c21 1, then x21 becomes the entering variable that is increasing. The fondamental cycle associated with x21 in the spanning tree is • Leaving criterion Evaluate the impact of increasing the value of the entering variable on the values of the basic variables. Then θ = 2 since for this value, xs1 = 2 – 2 = 0 x21 = 0 + 2 = 2 = d21. We can use the same basis at the next iteration since x21 2 d 21. We prefer to use xs1 as the leaving variable. 2-θ 0+θ 2+θ • Leaving criterion Evaluate the impact of increasing the value of the entering variable on the values of the basic variables. Then θ = 2 since for this value, xs1 = 2 – 2 = 0 x21 = 0 + 2 = 2 = d21. We can use the same basis at the next iteration since x21 2 d 21. We prefer to use xs1 as the leaving variable. The new solution and the associated spanning three are the following • Third iteration : Entering criterion Determine the multipliers Determine the relative costs of the non basic variables c s1 c s1 s 1 4 6 3 1 c1t c1t 1 t 1 3 0 2 πs=6 π1=3 1 πt=0 2 π2=5 2 3 π3=2 c s1 c s1 s 1 4 6 3 1 c1t c1t 1 t 1 3 0 2 The solution is optimal x s1 0 and c s1 1 0 x1t 2 d1t and c1t 2 0 • The simplex version for the minimum cost flow problem is simplified because of the incidence matrix structure. • There is a lot of degeneracy in flow problem. This may induce degenerate iteration (where the values of the variables dont change) sinply to modify the basis. There exists procedures to guide in chosing the basic solutions in order to reduce the number of degenerate iterations. Multiple sources and multiple destinations p sources si V , i 1, , p q destinations t j V , j 1, where vsi denotes the flow quantity coming from si ,q where vt j denotes the flow quantity arriving at t j s1 s2 sp t1 Rest of network t2 tq p sources si V , i 1, , p q destinations t j V , j 1, where vsi denotes the flow quantity coming from si ,q where vt j denotes the flow quantity arriving at t j Generate the network G1= (V1, E1 ) V 1 V s, t s1 s s2 sp t1 Rest of network t2 tq t p sources si V , i 1, , p q destinations t j V , j 1, where vsi denotes the flow quantity coming from si ,q where vt j denotes the flow quantity arriving at t j Generate the network G1= (V1, E1 ) V 1 V s, t E1 E (s, si ) : i 1,, p (t j , t ) : j 1, , q s1 s s2 sp t1 Reste du réseau t2 tq t p sources si V , i 1, , p q destinations t j V , j 1, where vsi denotes the flow quantity coming from si ,q where vt j denotes the flow quantity arriving at t j Generate the network G1= (V1, E1 ) V 1 V s, t E1 E (s, si ) : i 1,, p (t j , t ) : j 1, , q [d ij , cij ] [v s1 ,0] [vs2, ,0] s s1 s2 [vs p ,0] t1 Rest of network t2 [vt1 ,0] [ v t 2 ,0 ] [vtq ,0] sp tq t p sources si V , i 1, , p q destinations t j V , j 1, where vsi denotes the flow quantity coming from si ,q where vt j denotes the flow quantity arriving at t j Generate the network G1= (V1, E1 ) p q i 1 j 1 Total flow v vsi vt j [v s1 ,0] v v [vs2, ,0] s s1 s2 [vs p ,0] t1 Rest of network t2 [vt1 ,0] [ v t 2 ,0 ] [vtq ,0] sp tq t References M.S. Bazaraa, J.J. Jarvis, H.D. Sherali, “ Linear Programming and Network Flows”, 3rd edition, Wiley-Interscience (2005), Chapter9 F.S. Hillier, G.J. Lieberman, “Introduction to Operations Research”, Mc Graw Hill (2005), Section 9.7 D. G. Luenberger, “ Linear and Nonlinear Programming ”, 2nd edition, Addison-Wesley (1984), Chapter 5