1 / 16

Chapter 4 Shortest Paths: Label-Setting Algorithms

Chapter 4 Shortest Paths: Label-Setting Algorithms. 4.1 Introduction. Directed network G = (N, A) with an arc length (cost) c ij associated with each arc (i, j) A. C = max{ c ij : (i, j)A} Given source node s, find shortest path from s to every other node iN{s}.

juliacooper
Télécharger la présentation

Chapter 4 Shortest Paths: Label-Setting Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4Shortest Paths: Label-Setting Algorithms

  2. 4.1 Introduction • Directed network G = (N, A) with an arc length (cost) cij associated with each arc (i, j)A. C = max{ cij: (i, j)A} Given source node s, find shortest path from s to every other node iN\{s}. (finding s-t shortest path gives shortest paths to every other iN\{s}as byproducts.) • May interpret as sending one unit of flow from s to each of the nodes iN\{s} in an uncapacitated network. • Minimize (i, j)A cijxij subject to {j: (i, j)A} xij - {j: (j, i)A} xji = n-1, for i = s = -1, for all iN\{s} xij  0 for all (i, j)A

  3. Assumption 4.1: Arc lengths are integers • Some algorithms use this assumption in complexity analysis • Assumption 4.2: G contains a directed path from s to every other node. • May add arc (s, i) with large cost for every node i not connected to s by a directed path. • Assumption 4.3: G does not contain a negative cycle. (negative arc length may be allowed, but no negative cycle) • LP formulation unbounded if there exists a negative cycle in G. • Combinatorial algorithms try to find shortest length directed walks, hence unbounded if there exists a negative cycle in G. • Assumption 4.4: The network is directed. • If arc lengths nonnegative, use two arcs with opposite direction • If negative length arc exists, above transformation creates negative cycle. (need other transformation to handle this (matching).

  4. Various Types of Shortest Path Problems: • Finding shortest path from one node to all other nodes when arc lengths are nonnegative • Finding shortest path from one node to all other nodes with arbitrary arc lengths. • Finding shortest paths from every node to every other node (all pairs shortest path problem) • Various generalizations (e.g., k-shortest path problem) • Analog solution of the shortest path problem. • See the 3 observations in text. • Label-Setting and Label-Correcting Algorithms

  5. 4.2 Applications • Application 4.3 Knapsack problem maximize i=1p uixi subject to i=1p wixi  W xi  {0, 1} for all i. • Can be modeled as a longest path problem on an acyclic network. • Compare the dynamic programming algorithm and the algorithm on the network. Ex in text)

  6. Longest path problem → shortest path problem: take negative of arc lengths • If negative cycle exists, cannot be solved easily. But, the graph is acyclic. • Recall that for dynamic programming, d(i, j) is maximum utility (longest path length in the transformed graph) using items 1 through i and weight restriction j. • Exists algorithm for shortest path problem in acyclic networks: O(m) Does it imply that knapsack problem can be solved in polynomial time? No Transformed network has O(pW) arcs, hence running time is still O(pW), which is pseudopolynomial time.

  7. Application 4.4 Tramp Steamer Problem (minimum cost-to-time ratio cycle problem) A voyage of tramp steamer from port i to port j earns pij units of profit and requires ij units of time. Find tour W that achieves the largest possible mean daily profit (W) = ( (i, j)W pij) / ((i, j)W ij) • We assume ij  0 for (i, j)A, and (i, j)W ij > 0 for every directed cycle W. • For given 0, consider if there exists W such that ( (i, j)W pij) / ((i, j)W ij) > 0 , → (i, j)W (0ij - pij) < 0 Identify a negative cycle in G with arc cost (0ij - pij). Then, use binary search.

  8. Application 4.5 System of Difference Constraints: Consider LP with constraints: having one +1 and one -1 in each constraint m difference constraints in n variables x = {x(1), x(2), … , x(n)}: x(jk) – x(ik)  b(k) for each k = 1, … , m. Want to determine whether it has a feasible solution, and if so, identify a feasible solution. • Use constraint graph: Use arc (ik, jk) of length b(k) for the constraint x(jk) – x(ik)  b(k)

  9. Ex) x(3) – x(4)  5 x(4) – x(1)  -10 x(1) – x(3)  8 x(2) – x(1)  -11 x(3) – x(2)  2. 0 5 5 4 3 4 3 0 8 8 2 2 -10 -10 s 0 1 2 1 2 -11 -11 0

  10. Constraints are identical to the optimality conditions for the shortest path problem in G (later in Chapter 5). Conditions satisfied if and only if there does not exist a negative cycle. • Interpret x(i) as the shortest distance from an additional node s to i. Connect node s to node i with arc cost 0 so that the existence of a path from s to i is guaranteed for all i. • Note that for negative cycle 1-2-3 in G, we can add the lhs and rhs of the corresponding constraints respectively and get 0 < -1, which is inconsistent. • Value of a shortest path from s to i gives a feasible solution x(i) for all i. If negative cycle exists, label correcting algorithm can detect it, and it indicates inconsistent set of constraints.

  11. Application 4.6 Telephone Operator Scheduling Telephone company need to schedule operators around the clock. Let b(i), i = 0, 1, 2, … , 23 denote the minimum number of operators needed for the i-th hour of the day. (b(0): number needed for 0-1 a.m.) Each operator works 8 consecutive hours and a shift can begin at any hour. Want cyclic schedule that repeats daily.(using minimum number of operators ) • minimize i=023 yi subject to yi-7 + yi-6 + … + yi  b(i) for all i = 8 to 23, y17+i + … + y23 + y0 + … + yi  b(i) for all i = 0 to 7, yi  0 for all i =0 to 23. • Note that the rows have 1’s consecutively (in wraparound fashion)

  12. Let x(i) = k=0i yk, i = 0, … , 23 and x(23) = p yi-7 + yi-6 + … + yi  b(i) for all i = 8 to 23, y17+i + … + y23 + y0 + … + yi  b(i) for all i = 0 to 7, yi  0 for all i =0 to 23. Rewrite the constraints as x(i) – x(i-8)  b(i) for all i = 8 to 23, x(23) – x(16+i) + x(i) = p – x(16+i) + x(i)  b(i) for all i = 0 to 7, x(i) – x(i-1)  0 • System of difference constraints. Use binary search.

  13. 4.3 Tree of Shortest Paths • Shortest paths from s to all other nodes constitutes a directed out-tree (Shortest path tree) • Property 4.1 Let s = i1 – i2 - … - ih = k be a shortest path from s to k. Then subpath s = i1 – i2 - … - iq is a shortest s-iq path for q = 2, 3,…, h-1 P1 P3 s p k P2 • P1-P3 is shortest s-k path. If P2 is shorter s-p path, P2-P3 is s-k walk with shorter length. Can obtain s-k path after eliminating cycles (if no negative cycle)

  14. Let d() denote the shortest path distances. P is a shortest s-k path.  d(j) = d(i) + cij for every arc (i, j)P. Converse? Suppose d(j) = d(i) + cij for every arc in an s-k path P. Let s = i1 – i2 - … - ih = k be the node sequence in P. Then d(k) = d(ih) = (d(ih) – d(ih-1)) + (d(ih-1) – d(ih-2)) + … + (d(i2) – d(i1)) = ci(h-1),i(h) + ci(h-2),i(h-1) + … + ci2,i1 = (i, j)P cij Hence P is a shortest s-k path. • Property 4.2 Let the vector d represent the shortest path distances. Then s-t path P is a shortest path.  d(j) = d(i) + cij for every arc (i, j)P. • Use breadth-first search to identify shortest path tree satisfying d(j) = d(i) + cij.

  15. 4.4 Shortest Path Problems in Acyclic Networks • For acyclic network  topological ordering with i < j for (i, j)A. Then for node k, all incoming arcs must come from nodes 1, 2, … , k-1. By property 4.1, d(k) = minimumi<k {d(i) + cik}. • Algorithm Initially, d(s) = 0, d(i) = M for large M scan nodes in topological order for all arcs (i, j) in adjacency list A(i), if d(j) > d(i) + cij, set d(j) = d(i) + cij. at termination, d(i)’s are shortest distances (use pointers to identify the paths)

  16. Proof of correctness) Use induction. Suppose scanned nodes 1, 2, … , k and the distance labels are optimal. For node k+1, suppose s = i1 – i2 – ih – (k+1) is shortest path to k+1. By property 4.1, the path i1 – i2 – ih is a shortest s - ih path. By topological ordering, (ih, k+1)A implies ih {1, 2, … , k}. By inductive hypothesis, the label of ih is equal to the length of i1 – i2 – ih . Hence, when examining node ih, algorithm scans arc (ih, k+1) and set the label of node k+1 as the length of the path i1 – i2 – ih – (k+1). So, when the algorithm examines node k+1, its distance label is optimal. • Thm 4.3. The reaching algorithm solves the shortest path problem on acyclic networks in O(m) time. • If the network contains cycles, we need more elaborate schemes.

More Related