Chapter 6 Dynamic Programming

Slides:



Advertisements
Similar presentations
1 Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Advertisements

13 –Routing Protocols Network Layer4-1. Network Layer4-2 Chapter 4 Network Layer Computer Networking: A Top Down Approach Featuring the Internet, 3 rd.
Routing - I Important concepts: link state based routing, distance vector based routing.
DYNAMIC PROGRAMMING. 2 Algorithmic Paradigms Greedy. Build up a solution incrementally, myopically optimizing some local criterion. Divide-and-conquer.
CIS 235: Networks Fall, 2007 Western State College Computer Networks Fall, 2007 Prof Peterson.
Network Layer Design Isues Store-and-Forward Packet Switching Services Provided to the Transport Layer The service should be independent of the router.
Data Communication and Networks Lecture 7 Networks: Part 2 Routing Algorithms October 27, 2005.
4-1 Network layer r transport segment from sending to receiving host r on sending side encapsulates segments into datagrams r on rcving side, delivers.
Network Layer4-1 Chapter 4 Network Layer Computer Networking: A Top Down Approach Featuring the Internet, 2 nd edition. Jim Kurose, Keith Ross Addison-Wesley,
Lecture 7 Overview. Two Key Network-Layer Functions forwarding: move packets from router’s input to appropriate router output routing: determine route.
EE 122: Intra-domain routing Ion Stoica September 30, 2002 (* this presentation is based on the on-line slides of J. Kurose & K. Rose)
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 22.
Network Layer r Introduction r Datagram networks r IP: Internet Protocol m Datagram format m IPv4 addressing m ICMP r What’s inside a router r Routing.
Introduction 1 Lecture 21 Network Layer (Routing Activity) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer Science &
Network Layer4-1 Chapter 4 Network Layer Part 3: Routing Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March.
13 – Routing Algorithms Network Layer.
10/4/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 17 Dynamic.
Network Layer4-1 Distance Vector Algorithm Bellman-Ford Equation (dynamic programming) Define d x (y) := cost of least-cost path from x to y Then d x (y)
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2012 Lecture 17.
Distance Vector Routing
Introduction 1 Lecture 19 Network Layer (Routing Algorithms) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer Science.
Internet Routing r Routing algorithms m Link state m Distance Vector m Hierarchical routing r Routing protocols m RIP m OSPF m BGP.
Transport Layer 3-1 Chapter 4 Network Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley Chapter4_3.
CS38 Introduction to Algorithms Lecture 10 May 1, 2014.
Network Layer (2). Review Physical layer: move bits between physically connected stations Data link layer: move frames between physically connected stations.
4: Network Layer4-1 Chapter 4: Network Layer Last time: r Chapter Goals m Understand network layer principles and Internet implementation r Started routing.
@Yuan Xue A special acknowledge goes to J.F Kurose and K.W. Ross Some of the slides used in this lecture are adapted from their.
CSE 421 Computer Networks. Chapter 4 Network Layer Thanks to you All material copyright J.F Kurose and K.W. Ross, All Rights Reserved Computer.
Application Layer 2-1 Chapter 4 Network Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012 A.
IP tutorial - #2 Routing KAIST Dept. of CS NC Lab.
Network Layer4-1 Chapter 4: Network Layer 4. 1 Introduction 4.2 Virtual circuit and datagram networks 4.3 What’s inside a router 4.4 IP: Internet Protocol.
Network Layer.
The network layer: routing
Network Layer: The Control Plane.
CS 5565 Network Architecture and Protocols
Centralized vs Distributed Routing
Chapter 7 Dynamic Routing
Routing Jennifer Rexford.
Chapter 4 Network Layer A note on the use of these ppt slides:
CMPT 880: Internet Architectures and Protocols
Network Layer Introduction Datagram networks IP: Internet Protocol
Intra-Domain Routing Jacob Strauss September 14, 2006.
Routing: Distance Vector Algorithm
Chapter 4: outline 4.1 introduction
استانداردهاي سري IEEE 802.X
Distance Vector Routing: overview
NAT traversal problem client want to connect to server with address
Road Map I. Introduction II. IP Protocols III. Transport Layer
Lecture 10 Computer Networking: A Top Down Approach 6th edition Jim Kurose, Keith Ross Addison-Wesley March 2012 CS3516: These slides are generated from.
EEC-484/584 Computer Networks
CSCD 330 Network Programming
Chapter 6 Dynamic Programming
Chapter 4-4 routing and IP routing
Routers Routing algorithms
Chapter 6 Dynamic Programming
Advanced Computer Networks
CS4470 Computer Networking Protocols
Network Control Jennifer Rexford
CS 455/555 Intro to Networks and Communications
Evaluation of the Course (Modified)
Chapter 4: Network Layer
Chapter 4: Network Layer
Network Layer (contd.) Routing
EE 122: Intra-domain routing: Distance Vector
CSCD 330 Network Programming
Network Layer: Link-state and Distance-Vector Routing Protocols
Network Layer.
Chapter 4: Network Layer
CSCD 330 Network Programming
Chapter 4 Network Layer A note on the use of these ppt slides:
Presentation transcript:

Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.

6.8 Shortest Paths

Shortest Paths Shortest path problem. Given a directed graph G = (V, E), with edge weights cvw, find shortest path from node s to node t. Ex. Nodes represent agents in a financial setting and cvw is cost of transaction in which we buy from agent v and sell immediately to w. allow negative weights 2 10 3 9 s 18 6 -16 6 6 30 4 19 11 5 15 -8 6 20 16 t 7 44

Shortest Paths: Failed Attempts Dijkstra. Can fail if negative edge costs. Re-weighting. Adding a constant to every edge weight can fail. u 2 3 s v 1 -6 t 5 6 2 2 s t 3 3 -3

Shortest Paths: Negative Cost Cycles Observation. If some path from s to t contains a negative cost cycle, there does not exist a shortest s-t path; If a graph contains no negative cycle, there exists a shortest path that is simple (i.e., does not repeat nodes), and hence has at most n-1 edges. -6 -4 7 s t W c(W) < 0

Shortest Paths: Dynamic Programming Def. OPT(i, v) = length of shortest v-t path P using at most i edges. Case 1: P uses at most i-1 edges. OPT(i, v) = OPT(i-1, v) Case 2: P uses at most i edges. if (v, w) is first edge, then OPT uses (v, w), and then selects best w-t path using at most i-1 edges Remark. By previous observation, if no negative cycles, then OPT(n-1, v) = length of shortest v-t path.

Shortest Paths: Implementation Analysis. (mn) time, (n2) space. Finding the shortest paths. Maintain a "successor" for each table entry. Shortest-Path(G, s, t) { Array M[0…n-1, 1…n] foreach node v  V M[0, v]   M[0, t]  0 for i = 1 to n-1 foreach edge (v, w)  E M[i, v]  min { M[i-1, v], M[i-1, w] + cvw } return M[n-1,s] } Alternative to maintaining predecessor indices: compute optimal distances, then consider only zero reduced cost edges. n: # of nodes; m: # of edges

Bellman-Ford: Efficient Implementation Push-Based-Shortest-Path(G, s, t) { foreach node v  V { M[v]   successor[v]   } M[t] = 0 for i = 1 to n-1 { foreach node w  V { if (M[w] has been updated in previous iteration) { foreach node v such that (v, w)  E { if (M[v] > M[w] + cvw) { M[v]  M[w] + cvw successor[v]  w If no M[w] value changed in iteration i, stop.

6.9 Distance Vector Protocol The following several pages are modified from slides provided by Textbook: Computer Networking: A Top Down Approach Featuring the Internet, J. Kurose & K. Ross, Addison Wesley, 6th ed., 2013

Distance Vector Protocol Communication network. Node  router. Edge  direct communication link. Cost of edge  delay on link. Dijkstra's algorithm. Requires global information of network. Bellman-Ford. Uses only local knowledge of neighboring nodes. Synchronization. We don't expect routers to run in lockstep. The order in which each foreach loop executes in not important. Moreover, algorithm still converges even if updates are asynchronous. naturally nonnegative, but Bellman-Ford used anyway!

Distance Vector Algorithm (1) Bellman-Ford Equation (dynamic programming) Define dx(y) := cost of least-cost path from x to y Then dx(y) = minv {c(x,v) + dv(y) } where min is taken over all neighbors of x dx(y) = minv {c(x,v) + dv(y) } Network Layer

du(z) = min { c(u,v) + dv(z), c(u,x) + dx(z), c(u,w) + dw(z) } Bellman-Ford example How about du(z)? Suppose we know that dv(z) = 5, dx(z) = 3, dw(z) = 3 u y x w v z 2 1 3 5 B-F equation says: du(z) = min { c(u,v) + dv(z), c(u,x) + dx(z), c(u,w) + dw(z) } = min {2 + 5, 1 + 3, 5 + 3} = 4 Network Layer

Distance Vector Algorithm (3) Dx(y) = estimate of least cost from x to y Distance vector: Dx = [Dx(y): y є N ] Node x knows cost to each neighbor v: c(x,v) Node x maintains Dx = [Dx(y): y є N ] Node x also maintains its neighbors’ distance vectors For each neighbor v, x maintains Dv = [Dv(y): y є N ] Network Layer

Distance vector algorithm (4) Basic idea: Each node periodically sends its own distance vector estimate to neighbors When a node x receives new DV estimate from neighbor, it updates its own DV using B-F equation: Dx(y) ← minv{c(x,v) + Dv(y)} for each node y ∊ N Under minor, natural conditions, the estimate Dx(y) converge the actual least cost dx(y) Network Layer

Distance Vector Algorithm (5) Iterative, asynchronous: each local iteration caused by: local link cost change DV update message from neighbor Distributed: each node notifies neighbors only when its DV changes neighbors then notify their neighbors if necessary Each node: wait for (change in local link, cost of msg from neighbor) recompute estimates if DV to any dest has changed, notify neighbors Network Layer

z y x Dx(z) = min{c(x,y) + Dy(z), c(x,z) + Dz(z)} = min{2+1 , 7+0} = 3 Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} = min{2+0 , 7+1} = 2 node x table x y z x y z 0 2 7 ∞ from cost to cost to x y z x 2 3 from y 2 0 1 z 7 1 0 node y table cost to x z 1 2 7 y x y z x ∞ 2 0 1 ∞ ∞ y from z ∞ ∞ ∞ node z table cost to x y z x ∞ ∞ ∞ from y ∞ ∞ ∞ z 7 1 time Network Layer

z y x Dx(z) = min{c(x,y) + Dy(z), c(x,z) + Dz(z)} = min{2+1 , 7+0} = 3 Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} = min{2+0 , 7+1} = 2 node x table x y z x y z 0 2 7 ∞ from cost to cost to cost to x y z x y z x 0 2 3 x 0 2 3 from y 2 0 1 from y 2 0 1 z 7 1 0 z 3 1 0 node y table cost to cost to cost to x z 1 2 7 y x y z x y z x y z x ∞ ∞ x 0 2 7 ∞ 2 0 1 x 0 2 3 y from y from 2 0 1 from y 2 0 1 z z ∞ ∞ ∞ 7 1 0 z 3 1 0 node z table cost to cost to cost to x y z x y z x y z x 0 2 7 x 0 2 3 x ∞ ∞ ∞ from y from y 2 0 1 from y 2 0 1 ∞ ∞ ∞ z z z 3 1 0 3 1 0 7 1 time Network Layer