Dijkstra’s Algorithm for the Shortest Path Problem

Slides:



Advertisements
Similar presentations
15.082J & 6.855J & ESD.78J October 14, 2010 Maximum Flows 2.
Advertisements

15.082J & 6.855J & ESD.78J Shortest Paths 2: Bucket implementations of Dijkstra’s Algorithm R-Heaps.
Chapter 5 Shortest Paths: Label-Correcting Algorithms
15.082J, 6.855J, and ESD.78J Sept 16, 2010 Lecture 3. Graph Search Breadth First Search Depth First Search Intro to program verification Topological Sort.
Management Science 461 Lecture 2b – Shortest Paths September 16, 2008.
Chapter 7 Maximum Flows: Polynomial Algorithms
MIT and James Orlin © Introduction to Networks Eulerian Tours Hamiltonian Tours The Shortest Path Problem Dijkstra’s Algorithm for Solving the Shortest.
Network Optimization Models: Maximum Flow Problems In this handout: The problem statement Solving by linear programming Augmenting path algorithm.
15.082J and 6.855J and ESD.78J November 4, 2010 The Network Simplex Algorithm.
Computational Methods for Management and Economics Carla Gomes
& 6.855J & ESD.78J Algorithm visualizations Modified Label Correcting Algorithm.
15.082J and 6.855J and ESD.78J November 2, 2010 Network Flow Duality and Applications of Network Flows.
15.082J, 6.855J, and ESD.78J September 21, 2010 Eulerian Walks Flow Decomposition and Transformations.
Chapter 4 Shortest Path Label-Setting Algorithms Introduction & Assumptions Applications Dijkstra’s Algorithm.
Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x.
Lecture 10 The Label Correcting Algorithm.
15.082J & 6.855J & ESD.78J September 23, 2010 Dijkstra’s Algorithm for the Shortest Path Problem.
Maximum Flow Problem (Thanks to Jim Orlin & MIT OCW)
& 6.855J & ESD.78J Algorithm Visualization The Ford-Fulkerson Augmenting Path Algorithm for the Maximum Flow Problem.
and 6.855J The Goldberg-Tarjan Preflow Push Algorithm for the Maximum Flow Problem.
15.082J & 6.855J & ESD.78J October 7, 2010 Introduction to Maximum Flows.
15.082J and 6.855J March 4, 2003 Introduction to Maximum Flows.
15.082J and 6.855J and ESD.78J The Successive Shortest Path Algorithm and the Capacity Scaling Algorithm for the Minimum Cost Flow Problem.
and 6.855J March 6, 2003 Maximum Flows 2. 2 Network Reliability u Communication Network u What is the maximum number of arc disjoint paths from.
15.082J & 6.855J & ESD.78J September 30, 2010 The Label Correcting Algorithm.
Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘length’ c ij (cost, time, distance, …). Determine a path of shortest.
EMIS 8374 Shortest Path Trees Updated 11 February 2008 Slide 1.
15.082J and 6.855J and ESD.78J Network Simplex Animations.
Tuesday, March 19 The Network Simplex Method for Solving the Minimum Cost Flow Problem Handouts: Lecture Notes Warning: there is a lot to the network.
Cycle Canceling Algorithm
Network Optimization J.B. Orlin
Shortest Paths CONTENTS Introduction to Shortest Paths (Section 4.1)
Network Simplex Animations
EMIS 8374 Dijkstra’s Algorithm Updated 18 February 2008
Disjoint Path Routing Algorithms
Dijkstra’s Algorithm with two levels of buckets
Party-by-Night Problem
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
15.082J & 6.855J & ESD.78J Visualizations
15.082J & 6.855J & ESD.78J Visualizations
Dijkstra’s Algorithm for the Shortest Path Problem
Breadth first search animation
Lecture 4 Graph Search.
Introduction to Minimum Cost Flows
EMIS 8374 Shortest Path Problems: Introduction Updated 9 February 2008
Shortest-Path Property 4.1
Primal-Dual Algorithm
Successive Shortest Path Algorithm
Shortest Path Problems
and 6.855J March 6, 2003 Maximum Flows 2
15.082J & 6.855J & ESD.78J Radix Heap Animation
Network Optimization Depth First Search
Introduction to Algorithms
Min Global Cut Animation
Network Optimization Flow Decomposition.
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
Network Optimization Topological Ordering
and 6.855J Dijkstra’s Algorithm
Visualizations Dijkstra’s Algorithm
Network Simplex Animations
Eulerian Cycles in directed graphs
15.082J & 6.855J & ESD.78J Visualizations
Implementation of Dijkstra’s Algorithm
and 6.855J Depth First Search
Introduction to Minimum Cost Flows
The Successive Shortest Path Algorithm
Max Flows 3 Preflow-Push Algorithms
Class 11 Max Flows Obtain a network, and use the same network to illustrate the shortest path problem for communication networks, the max flow.
15.082J & 6.855J & ESD.78J Visualizations
Presentation transcript:

Dijkstra’s Algorithm for the Shortest Path Problem 15.082J & 6.855J & ESD.78J September 23, 2010 Dijkstra’s Algorithm for the Shortest Path Problem

Single source shortest path problem 1 2 3 4 5 6 ∞ Find the shortest path from a source node to each other node. Assume: (1) all arc lengths are non-negative (2) the network is directed (3) there is a path from the source node to all other nodes

A Key Step in Shortest Path Algorithms In this lecture, and in subsequent lectures, we let d( ) denote a vector of temporary distance labels. d(i) is the length of some path from the origin node 1 to node i. Procedure Update(i) for each (i,j) ∈ A(i) do if d(j) > d(i) + cij then d(j) : = d(i) + cij and pred(j) : = i; Update(i) used in Dijkstra’s algorithm and in the label correcting algorithm

Update(7) d(7) = 6 at some point in the algorithm, because of the path 1-8-2-7 9 5 3 2 1 11 8 8 1 8 2 7 3 4 6 7 no change Suppose 7 is incident to nodes 9, 5, 3, with temporary distance labels as shown. We now perform Update(7).

On Updates Note: distance labels cannot increase in an update step. They can decrease. 1 8 2 7 3 4 6 9 5 11 no change We do not need to perform Update(7) again, unless d(7) decreases. Updating sooner could not lead to further decreases in distance labels. In general, if we perform Update(j), we do not do so again unless d(j) has decreased.

Dijkstra’s Algorithm Let d*(j) denote the shortest path distance from node 1 to node j. Dijkstra’s algorithm will determine d*(j) for each j, in order of increasing distance from the origin node 1. S denotes the set of permanently labeled nodes. That is, d(j) = d*(j) for j ∈ S. T = N\S denotes the set of temporarily labeled nodes.

Dijkstra’s Algorithm S : = {1} ; T = N – {1}; d(1) : = 0 and pred(1) : = 0; d(j) = ∞ for j = 2 to n; update(1); while S ≠ N do (node selection, also called FINDMIN) let i ∈ T be a node for which d(i) = min {d(j) : j ∈ T}; S : = S + {i}; T: = T – {i}; Update(i) Dijkstra’s Algorithm Animated

Application 19.19. Dynamic Lot Sizing K periods of demand for a product. The demand is dj in period j. Assume that dj > 0 for j = 1 to K. Cost of producing pj units in period j: aj + bjpj hj : unit cost of carrying inventory from period j Question: what is the minimum cost way of meeting demand? Tradeoff: more production per period leads to reduced production costs but higher inventory costs.

Application 19.19. Dynamic Lot Sizing (1) 2 3 4 K-1 K D -d1 -d2 -d3 -d4 -dK-1 -dK Flow on arc (0, j): amount produced in period j Flow on arc (j, j+1): amount carried in inventory from period j Lemma: There is production in period j or there is inventory carried over from period j-1, but not both.

Lemma: There is production in period j or there is inventory carried over from period j-1, but not both. Suppose now that there is inventory from period j-1 and production in period j. Let period i be the last period in which there was production prior to period j, e.g., j = 7 and i = 4. Claim: There is inventory stored in periods i, i+1, …, j-1 4 5 6 7 K-1 K D -d4 -d5 -d6 -d7 -dK-1 -dK

4 5 6 7 K-1 K D -d4 -d5 -d6 -d7 -dK-1 -dK Thus there is a cycle C with positive flow. C = 0-4-5-6-7-0. Let x07 be the flow in (0,7). The cost of sending D units of flow around C is linear (ignoring the fixed charge for production). Let Q = b4 + h4 + h5 + h6 – b7. If Q < 0, then the solution can be improved by sending a unit of flow around C. If Q > 0, then the solution can be improved by decreasing flow in C by a little. If Q = 0, then the solution can be improved by increasing flow around C by x07 units (and thus eliminating the fixed cost a7). This contradiction establishes the lemma.

Let cij be the (total) cost of this flow. Corollary. Production in period i satisfies demands exactly in periods i, i+1, …, j-1 for some j. Consider 2 consecutive production periods i and j. Then production in period i must meet demands in i+1 to j-1. D i i+1 i+2 j-1 j -di -di+1 -di+2 -dj-1 -dj Let cij be the (total) cost of this flow. cij = ai + bi(di + di+1 + … + dj-1) + hi(di+1 + di+2 + … + dj-1) + hi+1(di+2 + di+3 + … + dj-1) + … hj-2(dj-1)

Interpretation: produce in periods 1, 6, 8 and 11. Let cij be the cost of producing in period i to meet demands in periods i, i+1, …, j-1 (including cost of inventory). Create a graph on nodes 1 to K+1, where the cost of (i,j) is cij. 1 2 3 4 K K+1 Each path from 1 to K+1 gives a production and inventory schedule. The cost of the path is the cost of the schedule. 1 6 8 11 K+1 Interpretation: produce in periods 1, 6, 8 and 11. Conclusion: The minimum cost path from node 1 to node K+1 gives the minimum cost lot-sizing solution.

15.082J / 6.855J / ESD.78J Network Optimization MITOpenCourseWare http://ocw.mit.edu 15.082J / 6.855J / ESD.78J Network Optimization Fall 2010 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.