Presentation is loading. Please wait.

Presentation is loading. Please wait.

2.2 Shortest Paths Def: directed graph or digraph

Similar presentations


Presentation on theme: "2.2 Shortest Paths Def: directed graph or digraph "— Presentation transcript:

1 2.2 Shortest Paths Def: directed graph or digraph 𝐺: 𝑉=𝑉(𝐺) of nodes, 𝐸=𝐸(𝐺) of arcs, functions associating to each 𝑒∈𝐸, a tail 𝑡(𝑒)∈𝑉 and a head ℎ(𝑒)∈𝑉. A digraph is called simple if it has no loops or parallel (same directions) arcs. write 𝑒=𝑣𝑤 for 𝑣=𝑡(𝑒), 𝑤=ℎ(𝑒) forward arc, reverse arc in a path 𝑃 A path in which every arc is forward is a directed path or dipath A dicircuit is a dipath that is also a circuit Shortest path problem Input: A digraph 𝐺, a node 𝑟∈𝑉, and a real cost vector (𝑐𝑒 : 𝑒∈𝐸) Objective: To find, for each 𝑣∈𝑉, a (simple) dipath from 𝑟 to 𝑣 of least cost (if one exists). Assume that there exist dipaths from 𝑟 to every node 𝑣∈𝑉 and 𝐺 is simple. (We may add arcs from 𝑟 to 𝑣∈𝑉 with large costs to ensure the existence of dipaths) Combinatorial Optimization 2014

2 Overview of results Directed graphs: longest path problem difficult
If 𝐺 is acyclic, easy (e.g., PERT network) Shortest path problem: If 𝐺 does not contain negative-cost dicircuit, easy. If 𝐺 contains a negative-cost dicircuit, there exist algorithms which can detect it but they cannot find a directed simple (𝑟,𝑣) path. (all combinatorial algorithm tries to find min cost dipath, not necessarily a simple dipath) Finding shortest simple (𝑟,𝑣) path is difficult (when negative-cost dicircuit exists) Acyclic graph, nonnegative arc costs: easy Combinatorial Optimization 2014

3 Undirected graphs: longest path problem difficult
If 𝐺 is acyclic, easy Shortest path problem: If 𝐺 has nonnegative edge costs: easy replace each edge by two directed arcs with opposite direction and apply the algorithm for directed case. modify the algorithm for directed case. If negative edge cost allowed: Note that doubling an edge with directed arcs having negative cost and using algorithm for directed case does not work. If 𝐺 contains a negative-cost circuit, difficult to find a shortest simple path. If 𝐺 does not contain a negative-cost circuit, can be solved as a 𝑇−join problem (later) Combinatorial Optimization 2014

4 𝑦𝑣+𝑐𝑣𝑤 ≥𝑦𝑤 for all 𝑣𝑤∈𝐸 (2.12)
Ideas: Let 𝑦𝑣 denote the length of a shortest dipath from 𝑟 to 𝑣 for each 𝑣∈𝑉. Then it must satisfy 𝑦𝑣+𝑐𝑣𝑤 ≥𝑦𝑤 for all 𝑣𝑤∈𝐸 (2.12) (Otherwise, 𝑦𝑣+ 𝑐 𝑣𝑤 <𝑦𝑤 and the path from 𝑟 to 𝑣+𝑣𝑤 gives a shorter path.) We call 𝑦=(𝑦𝑣:𝑣∈𝑉) a feasible potential if it satisfies (2.12) and 𝑦𝑟=0 (Note that we can subtract 𝑦𝑟 from each 𝑦𝑣 and (2.12) still satisfied) Proposition 2.9: Let 𝑦 be a feasible potential and let 𝑃 be a dipath from 𝑟 to 𝑣. Then 𝑐(𝑃)≥𝑦𝑣. Pf) Suppose 𝑃 is 𝑣0, 𝑒1, 𝑣1, …, 𝑒𝑘 , 𝑣𝑘 where 𝑣0=𝑟 and 𝑣𝑘=𝑣 Then 𝑐 𝑃 = 𝑖=1 𝑘 𝑐 𝑒 𝑖 ≥ 𝑖=1 𝑘 𝑦 𝑣 𝑖 − 𝑦 𝑣 𝑖−1 = 𝑦 𝑣 𝑘 − 𝑦 𝑣 0 = 𝑦 𝑣 . Combinatorial Optimization 2014

5 Moreover, the shortest paths do not use many arcs in 𝐺.
Proposition 2.9 shows that a feasible potential gives a lower bound for the shortest path costs. Suppose we have a feasible potential. Then, if we can find paths to each 𝑣∈𝑉 which satisfies (2.12) at equality (𝑦𝑣+𝑐𝑣𝑤=𝑦𝑤) for the edges on each path to 𝑣∈𝑉, they give paths having 𝑦𝑣 as path lengths. So we have proofs that they are actually the shortest paths to 𝑣∈𝑉. Moreover, the shortest paths do not use many arcs in 𝐺. We can assume that all the shortest paths use only one arc having head 𝑣 for each node 𝑣≠𝑟. (Subpaths of a shortest path are shortest paths) Hence, the subgraph of 𝐺 which consists of arcs in the shortest dipaths forms a spanning tree (only 𝑛−1 arcs and connected) (arborescence). This subgraph can be identified by storing the information of the immediate predecessor of node 𝑣≠𝑟, 𝑣∈𝑉 (𝑝(𝑣)). Combinatorial Optimization 2014

6 Algorithm strategy (1) Maintain and update a spanning tree (arborescence) which actually gives paths to each node (may not be shortest). The value 𝑦𝑣 represents the path length of some path to 𝑣 (It may not be the path length to 𝑣 in the current tree). (2) Try to find feasible potential 𝑦 by selecting arc 𝑣𝑤 which violates (2.12) (𝑦𝑣+𝑐𝑣𝑤≥𝑦𝑤), then update (decrease) the potential of 𝑦𝑤 to 𝑦𝑣+𝑐𝑣𝑤. If potential 𝑦𝑤 is updated, update the predecessor of node 𝑤 as 𝑝(𝑤)=𝑣, if necessary. (3) If we have found a feasible potential 𝑦 and spanning tree (𝑉, 𝑇), it is optimal shortest spanning tree and 𝑦𝑣 is shortest path length. Combinatorial Optimization 2014

7 Ford’s Algorithm We call an arc 𝑣𝑤 violating (2.12) incorrect.
To correct 𝑣𝑤 means to set 𝑦𝑤=𝑦𝑣+ 𝑐 𝑣𝑤 and to set 𝑝(𝑤)=𝑣 Initializing the algorithm: Set 𝑦𝑟=0, 𝑝(𝑟)=0, 𝑦𝑣=, 𝑝(𝑣)=−1 for 𝑣∈𝑉∖{𝑟} Ford’s algorithm: Initialize 𝑦, 𝑝; While 𝑦 is not a feasible potential Find an incorrect arc 𝑣𝑤 and correct it. Combinatorial Optimization 2014

8 (Example) a 2 3 r d 1 1 b Start vw= ra vw= rb vw= ad vw= ba y p y p r
a r b b r d a a a Combinatorial Optimization 2014

9 Remarks For arc 𝑣𝑤, if 𝑝(𝑣)=−1, we disregard arc 𝑣𝑤 (arc does not grow tree) Good implementation prevent this situation When correcting arc 𝑣𝑤, two cases occur 𝑣𝑤∉𝑇: update 𝑦𝑤 (=𝑦𝑣+ 𝑐 𝑣𝑤 ), update the unique predecessor of 𝑤 in 𝑇. 𝑣𝑤∈𝑇: no change in 𝑇, update 𝑦𝑤 𝑦 𝑣 = 𝑦 𝑝(𝑣) + 𝑐 𝑝 𝑣 𝑣 holds in the tree at termination, but it may not be true before termination. (consider 𝑣=𝑑 after 4th iteration) 𝑦 𝑣 ≥ 𝑦 𝑝 𝑣 + 𝑐 𝑝 𝑣 𝑣 holds throughout for the arcs in the arborescences. (It held with equality when 𝑦𝑣 and 𝑝(𝑣) were assigned their current values and after that 𝑦 𝑝(𝑣) can only decrease. If 𝑦 𝑣 decreases, 𝑇 changes. )  𝑦 𝑣 gives upper bound on the path length to 𝑣 in the current arborescence. Also note that if 𝑦 𝑣 > 𝑦 𝑝 𝑣 + 𝑐 𝑝 𝑣 𝑣 , arc 𝑝 𝑣 𝑣 in the arborescence is incorrect. Combinatorial Optimization 2014

10 (Abnormal case) a 1 2 r b 1 -3 d Start vw= ra vw= ab vw= bd vw= da y p
a r d b a a d b Combinatorial Optimization 2014

11 Application involving negative-cost dicircuit:
currency exchange rate 𝑟𝑣𝑤 If we can find a sequence of currency transactions 𝑣0,𝑣1,𝑣2,…,𝑣𝑘=𝑣0 such that 𝑖=1 𝑘 𝑟 𝑣 𝑖−1 𝑣 𝑖 >1, we can make money. Form a digraph 𝐺 whose nodes are currencies, with an arc 𝑣𝑤 of cost 𝑐𝑣𝑤=− log 𝑟 𝑣𝑤 for each pair 𝑣,𝑤. Then a sequence of transactions is money making iff associated dipath has cost − 𝑖=1 𝑘 log 𝑟 𝑣 𝑖−1 𝑣 𝑖 =− log 𝑖=1 𝑘 𝑟 𝑣 𝑖−1 𝑣 𝑖 <0. Existence of money-making sequence can be checked by checking the existence of a negative-cost dicircuit in 𝐺. Combinatorial Optimization 2014

12 Shortest (𝑟,𝑠) Path and LP
Consider an IP formulation to find a shortest (𝑟,𝑠) path (not the paths from 𝑟 to every other nodes). Define 𝑏𝑣= if 𝑣=𝑠 =−1 if 𝑣=𝑟 = otherwise IP formulation is minimize (𝑐𝑒𝑥𝑒: 𝑒𝐸) subject to (𝑥𝑤𝑣: 𝑤∈𝑉,𝑤𝑣∈𝐸)−(𝑥𝑣𝑤: 𝑤∈𝑉,𝑣𝑤∈𝐸)=𝑏𝑣, for all 𝑣∈𝑉 (i.e. inflow – outflow = net flow at node 𝑣, flow conservation) 𝑥 𝑣𝑤 ≥0, and integer for all 𝑣𝑤∈𝐸 Combinatorial Optimization 2014

13 Consider the LP relaxation and its dual: (P) minimize (𝑐𝑒𝑥𝑒: 𝑒∈𝐸)
subject to (𝑥𝑤𝑣: 𝑤∈𝑉,𝑤𝑣∈𝐸)−(𝑥𝑣𝑤: 𝑤∈𝑉,𝑣𝑤∈𝐸)=𝑏𝑣, for all 𝑣∈𝑉 𝑥 𝑣𝑤 ≥0, for all 𝑣𝑤∈𝐸 (D) maximize 𝑦𝑠−𝑦𝑟 𝑦𝑤− 𝑦 𝑣 ≤𝑐𝑣𝑤 for all 𝑣𝑤∈𝐸 (P) is a special case of the min cost network flow problem (may have upper bound on the arcs 𝑥 𝑣𝑤 ≤ 𝑢 𝑣𝑤 ). May use bounded variable simplex method. The coefficient matrix of constraints in (P) has special structure; each column has exactly one 1 and one –1 (except nonnegativity constraints). Such matrix is totally unimodular (details in Chap. 6). For totally unimodular matrix, if the right-hand sides are integer valued, any basic feasible solution to LP is integral. Hence, there exists an integer optimal solution (simple (𝑟,𝑠) path) if an optimal solution exists (not unbounded) and, from strong duality of LP, optimal values of (P) and (D) are equal. Combinatorial Optimization 2014

14 From the constraints of (D), we can see that 𝑦 is a feasible potential iff it is a feasible dual solution (with 𝑦𝑟=0). For any feasible dual solution (feasible potential), 𝑦𝑠−𝑦𝑟,  𝑠∈𝑉∖{𝑟} gives a lower bound on the optimal shortest path length from 𝑟 to 𝑠,  𝑠∈𝑉∖{𝑟}, as was shown. Using CS conditions, we can see that the dual constraints hold at equality for the edges on the optimal (𝑟,𝑠) path (for fixed 𝑠) in an optimal solution. Combinatorial Optimization 2014

15 Abnormal case (existence of negative cost dicircuit)
If the network has a negative-cost dicircuit, the LP is unbounded, hence dual is infeasible. 1 1 1(M) 2(M) s r -5(M) Let flow of M   on the dicircuit We may increase the flow over the negative-cost dicircuit indefinitely, hence the LP is unbounded. Although we may impose the restriction that 𝑥𝑒≤1 on each arc, then the optimal solution is not a simple path. Combinatorial Optimization 2014

16 Validity of Ford’s Algorithm
Prop 2.10: If (𝐺,𝑐) has no negative-cost dicircuit, then at any stage of the Ford’s algorithm we have : (i) If 𝑦 𝑣 ≠∞, then it is the cost of a simple dipath from 𝑟 to 𝑣. (ii) If 𝑝 𝑣 ≠−1, then 𝑝 defines a simple dipath from 𝑟 to 𝑣 of cost at most 𝑦 𝑣 . pf) (i) Let 𝑦 𝑣 𝑗 be the value of 𝑦𝑣 after 𝑗 iterations. If 𝑦 𝑣 𝑗 ≠∞, it is a cost of some dipath from 𝑟 to 𝑣 (The dipath may not be the same as the dipath to 𝑣 in the current arborescence). To prove that it is simple, suppose that it includes a closed dipath and derive contradiction. Then there exists 𝑣0,𝑣1,…,𝑣𝑘=𝑣0 and 𝑞0<𝑞1<…<𝑞𝑘 such that 𝑦 𝑣 𝑖−1 𝑞 𝑖−1 + 𝑐 𝑣 𝑖−1 𝑣 𝑖 = 𝑦 𝑣 𝑖 𝑞 𝑖 , 1≤𝑖≤𝑘 The cost of the resulting dipath is 𝑐 𝑣 𝑖−1 𝑣 𝑖 = 𝑦 𝑣 𝑖 𝑞 𝑖 − 𝑦 𝑣 𝑖−1 𝑞 𝑖−1 = 𝑦 𝑣 𝑘 𝑞 𝑘 − 𝑦 𝑣 0 𝑞 0 . But 𝑦 𝑣 𝑘 was lowered at iteration 𝑞 𝑘 , hence the dipath has negative cost, contradiction. Combinatorial Optimization 2014

17 The cost of dipath is ≤ 𝑦 𝑣 𝑖 − 𝑦 𝑣 𝑖−1 = 𝑦 𝑣 − 𝑦 𝑟 = 𝑦 𝑣 . 
(ii) Similar to (i). If 𝑝 does not define a simple dipath, there exists 𝑣0,𝑣1,…,𝑣𝑘=𝑣0 and 𝑝( 𝑣 𝑖 )= 𝑣 𝑖−1 for 1≤𝑖≤𝑘. For an arc 𝑝(𝑣)𝑣 in the selected subgraph (arborescence), we always have 𝑐 𝑝 𝑣 𝑣 ≤ 𝑦 𝑣 − 𝑦 𝑝(𝑣) ( note that 𝑦𝑣, 𝑣∈𝑉 never increase ) Hence total cost of the closed dipath is ≤0. In the most recent predecessor assignment in the closed dipath, the potential of the head node strictly decreases. Suppose 𝑝(𝑣) is such node and new node potential is 𝑦 𝑝 𝑣 ′ 𝑦 𝑝 𝑣 ′ < 𝑦 𝑝(𝑣) . Then 𝑐 𝑝 𝑣 𝑣 ≤ 𝑦 𝑝 𝑣 ′ − 𝑦 𝑝 𝑣 <0. So a negative-cost closed dipath exists, contradiction. Next, consider a dipath 𝑣0,𝑒1,𝑣1,…,𝑒𝑘, 𝑣 𝑘 where 𝑣0=𝑟, 𝑣 𝑘 =𝑣 and 𝑝( 𝑣 𝑖 )= 𝑣 𝑖−1 for 1≤𝑖≤𝑘. The cost of dipath is ≤ 𝑦 𝑣 𝑖 − 𝑦 𝑣 𝑖−1 = 𝑦 𝑣 − 𝑦 𝑟 = 𝑦 𝑣 .  Combinatorial Optimization 2014

18 Thm 2.11: If (𝐺,𝑐) has no negative-cost dicircuit, then Ford’s algorithm terminates after a finite number of iterations. At termination, for each 𝑣∈𝑉, 𝑝 defines a least-cost dipath from 𝑟 to 𝑣 of cost 𝑦𝑣. pf) only finitely many simple dipaths in 𝐺, hence possible values for 𝑦𝑣 finite by Prop 2.10. One of 𝑦𝑣 decreases strictly in each iteration and never increases, hence finitely terminates. At termination, 𝑝 (pointers) defines a simple dipath from 𝑟 to 𝑣 of cost at most 𝑦𝑣, but 𝑦𝑣 is lower bound on shortest path to 𝑣 if 𝑦 is feasible potential.  Combinatorial Optimization 2014

19 pf) If 𝐺 has a feasible potential, then no negative-cost dicircuit
Thm 2.12: (𝐺,𝑐) has a feasible potential iff it has no negative-cost dicircuit. pf) If 𝐺 has a feasible potential, then no negative-cost dicircuit ( since 𝑦𝑣+ 𝑐 𝑣𝑤 ≥ 𝑦 𝑤 for all 𝑣𝑤∈𝐸 ) Suppose 𝐺 has no negative-cost dicircuit. Add a node 𝑟 to 𝐺 and connect 𝑟 to 𝑣 for 𝑣∈𝑉 with cost 0. (𝐺’,𝑐’) has no negative-cost dicircuit since no dicircuit goes through 𝑟. Now apply Ford’s algorithm to 𝐺’. 𝐺’ has a dipath from 𝑟 to all other nodes, hence produces feasible potential and it is also feasible potential for (𝐺,𝑐)  Note that the theorem holds without the assumption of the existence of dipaths to all 𝑣. Combinatorial Optimization 2014

20 Running time of Ford’s Algorithm:
Assuming arc-costs are integers, each step decreases some 𝑦𝑣 by at least one. Let 𝐶=2max 𝑐 𝑒 :𝑒∈𝐸 Prop 2.13: If 𝑐 is integer-valued, and 𝐺 has no negative-cost dicircuit, then Ford’s algorithm terminates after at most 𝐶𝑛2 arc-correction steps. (not polynomial time algorithm, not satisfactory. But improved running time is possible.) Combinatorial Optimization 2014

21 Feasible Potentials and Linear Programming
Different logic using Ford’s Algorithm: Feasible potentials provide lower bounds for dipath costs. In fact, at termination of Ford’s algorithm, we have a feasible potential and dipaths for which equality holds. So, we have Thm 2.14: Let 𝐺 be a digraph, 𝑟,𝑠∈𝑉 and 𝑐∈ 𝑅 𝐸 . If there exists a least cost dipath from 𝑟 to 𝑣 for every 𝑣∈𝑉, then min{𝑐(𝑃): 𝑃 a dipath from 𝑟 to 𝑠} = max{ 𝑦 𝑠 : 𝑦 a feasible potential } The max problem is an LP: (D) maximize 𝑦𝑠−𝑦𝑟 (2.13) subject to 𝑦𝑤− 𝑦 𝑣 ≤𝑐𝑣𝑤 for all 𝑣𝑤∈𝐸 Its dual is, (P) minimize (𝑐𝑒𝑥𝑒: 𝑒∈𝐸) (2.14) (𝑥𝑤𝑣: 𝑤∈𝑉,𝑤𝑣∈𝐸)−(𝑥𝑣𝑤: 𝑤∈𝑉,𝑣𝑤∈𝐸)=𝑏𝑣, for all 𝑣∈𝑉 𝑥 𝑣𝑤 ≥0, for all 𝑣𝑤∈𝐸 Combinatorial Optimization 2014

22 Any dipath 𝑃 from 𝑟 to 𝑠 provides a feasible solution to (2
Any dipath 𝑃 from 𝑟 to 𝑠 provides a feasible solution to (2.14): Define ( 𝑥 𝑒 𝑃 :𝑒∈𝐸) as the number of times that arc 𝑒 is used in 𝑃. If 𝑃 is simple, 𝑥 𝑃 is {0,1}-valued, and is the characteristic vector of 𝑃. Therefore, Theorem 2.14 implies that, when shortest paths exist, (2.14) has an optimal solution that is the characteristic vector of a simple dipath (strong duality). Hence the vertices of the polyhedron of the feasible solutions to (2.14) are characteristic vectors of simple dipaths (Chapter 6). ( If (2.14) has an integer optimal solution for all choices of 𝑐 for which finite optimal solutions exist, it implies that the polyhedron is integral (every extreme point is integer vector). Combinatorial Optimization 2014

23 Relationship between the Ford’s Alg and the simplex method for (2,14)
The constraint matrix in (2.14) has special structure; each column has exactly one 1 and one –1 (except nonnegativity constraints). Adding the rows of the matrix 𝐴, we get 0 vector, which implies the rows are linearly dependent (rank of 𝐴 is ≤𝑛−1). Prop 2.15: Let 𝐺 be a connected digraph and 𝐴={𝑎𝑒: 𝑒∈𝐸} be its incidence matrix ( 𝑎𝑒 is the column vector for arc 𝑒 in the constraint matrix) . A set {𝑎𝑒: 𝑒∈𝑇} is a column basis of 𝐴 iff 𝑇 is the arc-set of a spanning tree of 𝐺 (not considering the directions of the arcs). ( 𝐺 has 𝑛 nodes, 𝑚 arcs. 𝐴 is 𝑛×𝑚 matrix. Spanning tree has 𝑛−1 arcs.) Combinatorial Optimization 2014

24 b.f.s. and dual vector satisfies 𝑥𝑒=0 for all 𝑒∉𝑇
So the rank of 𝐴 is 𝑛−1. To solve the problem by the simplex method, we need nonsingular basis 𝐵. Two approaches: Drop one of the constraints and solve the full row rank problem Add an artificial variable (say 𝑥 𝑎 ) to any one constraint (objective coefficient is 0). It makes 𝐴 full row rank (the artificial variable always remains in the basis and has value 0 in any b.f.s). b.f.s. and dual vector satisfies 𝑥𝑒= for all 𝑒∉𝑇 𝑦𝑤–𝑦𝑣=𝑐𝑣𝑤 for all 𝑣𝑤∈𝑇 ( From 𝑦 ′ 𝐵= 𝑐 𝐵 ′ for current basis 𝐵) This 𝑦 vector gives the path length to each node 𝑣 in the current tree 𝑇 (If 𝑇 is arborescence). Note that if we add artificial variable to the constraint for node 𝑟 (root), then we have 𝑦𝑟=0 in any bfs (from 𝑦 ′ 𝐵= 𝑐 𝐵 ′ ) Also we can check that 𝑥 𝑎 =0 in any b.f.s. (from 𝐵 𝑥 𝐵 =𝑏) Combinatorial Optimization 2014

25 (1) Change of arborescence
A b.f.s. for (2.14) does not necessarily correspond to an arborescence (each node has one predecessor except node 𝑟) . It may be just a spanning tree. However, the simplex iteration can be modified so that we always have arborescence once we started the algorithm with an arborescence. Each step of the simplex method may correspond to multiple Ford’s step; (1) Change of arborescence (2) update the node potentials so that it gives the actual path length in the arborescence. Combinatorial Optimization 2014

26 Suppose we solve (𝑟,𝑠) shortest path problem by LP (with simplex method) and have a feasible arborescence (bfs); entering nonbasic arc selection: choose 𝑒∉𝑇 with 𝑐𝑒–(𝑦𝑤–𝑦𝑣)<0, i.e. 𝑐𝑒+ 𝑦 𝑣 <𝑦𝑤. ( from 𝑐𝑗−𝑦’ 𝐴 𝑗 <0 since we solve min problem ) leaving basic variable: select the entering arc to 𝑤 in the current arborescence as leaving basic variable. Update flow (𝑥−value) so that we have value 1 for each arc on the (𝑟,𝑠) path. Note that we may solve the shortest (𝑟,𝑠) path problem by LP. But, in an optimal basis (arborescence), we have shortest (𝑟,𝑣) path, for all 𝑣∈𝑉. ( If you use the above modified simplex method) ( We have feasible potential 𝑦 and the (𝑟,𝑣) paths in the arborescence for all 𝑣∈𝑉 gives actual path with length 𝑦𝑣 for all 𝑣∈𝑉.) The identification of the basis of the LP as a spanning tree (not necessarily arborescence) is used in the primal minimum cost flow algorithm for the minimum cost network flow problem. (Chapter 4) Combinatorial Optimization 2014

27 Remarks Denote (P) as min {𝑐 ′ 𝑥:𝐴𝑥=𝑏,𝑥≥0} after adding artificial variable 𝑥 𝑎 and 𝑄={𝑥∈ 𝑅 𝑚 :𝐴𝑥=𝑏,𝑥≥0}. Problem (P) is unbounded iff ∃ extreme ray 𝑑 in 𝑄 (recession cone of 𝑄) such that 𝑐 ′ 𝑑<0. Recall the HW problem in IE531 LP: Let 𝑃={𝑥∈ 𝑅 𝑛 :𝐴𝑥=𝑏,𝑥≥0}, where 𝐴 is an 𝑚×𝑛 matrix of rank 𝑚. Show that 𝑦 defines an extreme ray of 𝑃 (i.e., extreme ray of the recession cone of 𝑃) if and only if 𝑦 is a positive multiple of the vector 𝑥 𝐵 , 𝑥 𝑁 , where 𝐴= 𝐵:𝑁 and 𝐵 is 𝑚×𝑚 invertible, and 𝑥 𝐵 =− 𝐵 −1 𝐴 𝑗 ≥0, 𝑥 𝑁 is a unit vector with the 1 in the position corresponding to column 𝐴 𝑗 of 𝑁. Let 𝐶 be a dicircuit in 𝐺. Then the vector 𝑥 with 𝑥 𝑒 =1, 𝑒∈𝐶, 𝑥 𝑒 =0, otherwise is an extreme ray of 𝑄 (Use the HW result with 𝐵 𝑥 𝐵 =− 𝐴 𝑗 . The columns of 𝐵 consists of tree arcs and the artificial column.) Therefore, (P) is unbounded if and only if there exists a negative cost dicircuit. Combinatorial Optimization 2014

28 Refinements of Ford’s Algorithm
Number of steps depends on the sequence we consider the arcs. Let 𝑆={𝑓1,𝑓2,…,𝑓𝑙} be the sequence of arcs considered (arcs may be repeated). Let 𝑃 denote the dipath 𝑣0,𝑒1,𝑣1,…,𝑒𝑘, 𝑣 𝑘 where 𝑣0=𝑟, 𝑣 𝑘 =𝑣. After the first time Ford’s algorithm considers 𝑒1, we will have 𝑦 𝑣 1 ≤ 𝑦 𝑟 + 𝑐 𝑒 1 ≤ 𝑐 𝑒 1 . After the first subsequent time Ford’s algorithm considers 𝑒2, we will have 𝑦 𝑣 2 ≤ 𝑦 𝑣 1 + 𝑐 𝑒 2 ≤ 𝑐 𝑒 1 + 𝑐 𝑒 2 . Continuing, once the arcs in the path are considered in the order they appear in the path, we have 𝑦 𝑣 ≤𝑐(𝑃). We say that 𝑃 is imbedded in 𝑆 if its arcs occur (in the right order, but not necessarily consecutively) as a subsequence of 𝑆. Combinatorial Optimization 2014

29 Prop 2.16: If Ford’s algorithm uses the sequence 𝑆, then for every 𝑣∈𝑉 and for every path 𝑃 from 𝑟 to 𝑣 embedded in 𝑆, we have 𝑦 𝑣 ≤𝑐(𝑃). If 𝑆 contains the sequences for all optimal paths to 𝑣∈𝑉, we have 𝑦 𝑣 ≤𝑐(𝑃) for optimal path 𝑃 to 𝑣 and for all 𝑣∈𝑉. Also the pointer 𝑝 defines a simple dipath to 𝑣 with cost at most 𝑦𝑣, 𝑣∈𝑉. Hence the algorithm stops. Combinatorial Optimization 2014

30 The Ford-Bellman Algorithm
Use the sequence 𝑆 such that each edge is considered once in a pass. Let 𝑆𝑖 be an ordering of 𝐸. Then every simple dipath in 𝐺 is embedded in the sequences 𝑆1,𝑆2,…, 𝑆 𝑛−1 . → 𝑂(𝑚𝑛) If 𝑦 is not a feasible potential after 𝑛−1 passes, there exists a negative-cost dicircuit. Ford-Bellman Algorithm Initialize 𝑦,𝑝; Set 𝑖=0; While 𝑖<𝑛 and 𝑦 is not a feasible potential replace 𝑖 by 𝑖+1; For 𝑒∈𝐸 If 𝑒 is incorrect Correct 𝑒. Combinatorial Optimization 2014

31 Store the arcs having tail 𝑣 in a list 𝐿𝑣. Scan 𝑣 means For 𝑣𝑤∈𝐿𝑣
Refinements: Store the arcs having tail 𝑣 in a list 𝐿𝑣. Scan 𝑣 means For 𝑣𝑤∈𝐿𝑣 If 𝑣𝑤 is incorrect Correct 𝑣𝑤; Replace the last 3 statements of the algorithm by For 𝑣∈𝑉 Scan 𝑣; Combinatorial Optimization 2014

32  Keep a list 𝑄 of nodes to be scanned Initially 𝑄={𝑟}
Note that if 𝑦𝑣 has not decreased since the last time 𝑣 was scanned, then 𝑣 need not be scanned  Keep a list 𝑄 of nodes to be scanned Initially 𝑄={𝑟} Add node 𝑣 to 𝑄 when 𝑦𝑣 is decreased and 𝑣∉𝑄. Choose the next node to be scanned from 𝑄 (and delete it from 𝑄) Stop the algorithm when 𝑄 is empty. Keep 𝑄 as both a list (or queue) and a characteristic vector. Combinatorial Optimization 2014

33 Acyclic Digraphs Topological sort of nodes in 𝐺: Ordering of 𝑣1,𝑣2,…,𝑣𝑛 of 𝑉 so that 𝑣 𝑖 𝑣 𝑗 ∈𝐸 implies 𝑖<𝑗. If we can order 𝐸 in the sequence 𝑆 so that 𝑣 𝑖 𝑣 𝑗 precedes 𝑣 𝑘 𝑣 𝑙 if 𝑖<𝑘, then every dipath in 𝐺 is imbedded in 𝑆. Hence Ford’s algorithm solves the problem in one pass ( 𝑂(𝑚) ). 𝐺 has a topological sort if and only if 𝐺 is acyclic. (pf) If 𝐺 has a topological sort, then clearly it has no dicircuit. Conversely, if 𝐺 is acyclic, then there exists a node 𝑣 such that 𝑢𝑣∈𝐸 for no 𝑢∈𝑉. Let the node be 𝑣1 and eliminate it from 𝐺. Then 𝐺\ 𝑣 1 is also acyclic and repeat the procedure. Combinatorial Optimization 2014

34 Nonnegative Costs When we choose the node to be scanned next, select the node 𝑣 for which 𝑦𝑣 is minimum. Then we have Prop 2.19: For each 𝑤∈𝑉, let 𝑦 𝑤 ′ be the value of 𝑦𝑤 when 𝑤 is chosen to be scanned. If 𝑢 is scanned before 𝑣, then 𝑦 𝑢 ′ ≤ 𝑦 𝑣 ′ . pf) Suppose 𝑦 𝑣 ′ < 𝑦 𝑢 ′ and let 𝑣 be the earliest node scanned for which this is true. When 𝑢 was scanned, we had 𝑦 𝑢 ′ = 𝑦 𝑢 ≤ 𝑦 𝑣 . So 𝑦𝑣 was lowered to a value < 𝑦 𝑢 ′ after 𝑢 was scanned and before 𝑣 was scanned. So for some node 𝑤, 𝑦𝑣 was set to 𝑦 𝑤 ′ + 𝑐 𝑤𝑣 . By choice of 𝑣, 𝑦 𝑤 ′ ≥ 𝑦 𝑢 ′ and since 𝑐𝑤𝑣≥0, we have 𝑦 𝑣 ′ ≥ 𝑦 𝑢 ′ . Contradiction.  Combinatorial Optimization 2014

35 After all nodes are scanned, we have 𝑦 𝑣 + 𝑐 𝑣𝑤 ≥ 𝑦 𝑤 for all 𝑣𝑤∈𝐸.
Suppose not. Then 𝑦𝑣 was lowered after 𝑣 was scanned, say while node 𝑞 was scanned. Then 𝑦𝑣 was set to 𝑦 𝑣 = 𝑦 𝑞 ′ + 𝑐 𝑞𝑣 ≥ 𝑦 𝑣 ′ since 𝑞 was scanned later than 𝑣 and 𝑐𝑞𝑣≥0. Contradiction. Dijkstra’s Algorithm Initialize 𝑦, 𝑝; Set 𝑆=𝑉; While 𝑆≠∅ Choose 𝑣∈𝑆 with 𝑦𝑣 minimum; Delete 𝑣 from 𝑆; Scan 𝑣. Combinatorial Optimization 2014

36 We have 𝑦𝑣+ 𝑐 𝑣𝑤 ≥𝑦𝑤 for 𝑤∉𝑆 since 𝑦𝑣≥𝑦𝑤.
So only need to test if 𝑦𝑣+ 𝑐 𝑣𝑤 <𝑦𝑤 for 𝑤∈𝑆. Running time: 𝑂(𝑚) + time to find 𝑣 {𝑛−1+𝑛−2+ … +1 = 𝑂(𝑛2)} Hence total time is 𝑂(𝑛2) Notation: 𝑆(𝑛,𝑚): time needed to solve a nonnegative cost shortest path problem on a digraph with 𝑛 nodes and 𝑚 arcs If we happen to know the feasible potential 𝑦, then may transform 𝑐 𝑣𝑤 ′ = 𝑐 𝑣𝑤 + 𝑦 𝑣 − 𝑦 𝑤 ≥0 so that we can use Di’s algorithm. Any (𝑟,𝑠) dipath satisfies 𝑐 ′ 𝑃 =𝑐 𝑃 + 𝑦 𝑟 − 𝑦 𝑠 , hence shortest path does not change. Combinatorial Optimization 2014

37 Above transformation on arc costs can be used to improve running time for all pairs shortest path problem. May solve shortest path problem starting from each of the 𝑛 nodes: 𝑂( 𝑛 2 𝑚) Find a feasible potential in 𝑂(𝑛𝑚) with Ford-Bellman, then transform to nonnegative costs, and then use Dijkstra (𝑛−1) times: 𝑂(𝑛𝑆 𝑛,𝑚 ) Direct method: Floyd-Warshall method is 𝑂( 𝑛 3 ) Combinatorial Optimization 2014

38 Unit Costs and Breadth-First Search
Prop 2.21: If each 𝑐 𝑒 =1, then in Dijkstra’s algorithm, the final value of 𝑦𝑣 is the first finite value assigned to it. Moreover, if 𝑣 is assigned its first finite 𝑦𝑣 before 𝑤 is, then 𝑦𝑣≤𝑦𝑤. pf) True for 𝑣=𝑟. If 𝑣≠𝑟, the first finite value 𝑦𝑣 is 𝑦 𝑤 ′ +1 for some 𝑤, where 𝑦 𝑤 ′ is the final value of 𝑦𝑤. Moreover, any node 𝑗 scanned later than 𝑤 has 𝑦 𝑗 ′ ≥ 𝑦 𝑤 ′ by Prop 2.19, so 𝑦𝑣 will not be further decreased. Similarly, any node 𝑤 assigned its first finite 𝑦𝑤 after 𝑣 will have 𝑦 𝑤 = 𝑦 𝑗 ′ +1≥ 𝑦 𝑞 ′ +1= 𝑦 𝑣 for some 𝑞,𝑗.  Hence, when picking 𝑣∈𝑆, we choose the first element in queue 𝑄 of unscanned nodes having 𝑦𝑣 finite. => breadth-first search. 𝑣 can be found in constant time, hence running time is 𝑂(𝑚) Need when we consider an algorithm for maximum flow problem. Combinatorial Optimization 2014

39 Other Interpretation of Ford-Bellman Alg.
Handout: Combinatorial Optimization: Networks and Matroids, E. Lawler Bellman’s equations: 𝑢1=0 𝑢 𝑗 = min 𝑘≠𝑗 𝑢 𝑘 + 𝑎 𝑘𝑗 , 𝑗=2,3,…,𝑛 Initial values 𝑢 1 (1) =0 𝑢 𝑗 (1) = 𝑎 1𝑗 , 𝑗≠1 Iteration 𝑢 𝑗 (𝑚+1) =𝑚𝑖𝑛 𝑢 𝑗 (𝑚) , min 𝑘≠𝑗 𝑢 𝑘 (𝑚) + 𝑎 𝑘𝑗 Interpretation 𝑢 𝑗 (𝑚) = the length of a shortest path from the origin to 𝑗, subject to the condition that the path contains no more than 𝑚 arcs. Combinatorial Optimization 2014

40 M Shortest Paths without Repeated Nodes
Handout: Combinatorial Optimization: Networks and Matroids, E. Lawler Enumerate simple 𝑟,𝑠 -paths in nondecreasing order with respect to the weights. Not efficient, but useful when we want to find a shortest path satisfying, or not satisfying certain conditions additionally imposed. Suppose we have shortest paths 𝑃1,𝑃2,…, 𝑃 𝑚 . Let ℘ be the set of all (𝑟,𝑠) paths. We divide the set ℘–{𝑃1,𝑃2,…, 𝑃 𝑚 } into ℘1,℘2,…,℘𝑘 . Each ℘ 𝑗 includes paths with the condition that (a) they include the arcs in a certain specified path from node 𝑟 to another node 𝑝, and (b) certain arcs from node 𝑝 are excluded. Then we can find a shortest path in ℘𝑗 by finding a shortest path from node 𝑝 to 𝑠 after deleting intermediate nodes in the path from 𝑟 to 𝑝, and deleting the arcs excluded from node 𝑝. Combinatorial Optimization 2014


Download ppt "2.2 Shortest Paths Def: directed graph or digraph "

Similar presentations


Ads by Google