1 Chapter 9 Dynamic Programming General Problem-Solving strategy Was born in the 1950s (Bellman) Based on successive decomposition Leads to functional.

Slides:



Advertisements
Similar presentations
Bellman-Ford algorithm
Advertisements

Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
CS138A Single Source Shortest Paths Peter Schröder.
1 Theory I Algorithm Design and Analysis (10 - Shortest paths in graphs) T. Lauer.
Design and Analysis of Algorithms Single-source shortest paths, all-pairs shortest paths Haidong Xue Summer 2012, at GSU.
Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm.
5-1 Chapter 5 Tree Searching Strategies. 5-2 Satisfiability problem Tree representation of 8 assignments. If there are n variables x 1, x 2, …,x n, then.
Data Structures Using C++
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
Management Science 461 Lecture 2b – Shortest Paths September 16, 2008.
Chapter 3 The Greedy Method 3.
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
Graphs.
Chapter 9: Greedy Algorithms The Design and Analysis of Algorithms.
Graphs. Graph definitions There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs Birmingham Rugby London Cambridge.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Design and Analysis of Algorithms - Chapter 81 Dynamic Programming Dynamic Programming is a general algorithm design technique Dynamic Programming is a.
Spring 2010CS 2251 Graphs Chapter 10. Spring 2010CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs.
MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 15, Friday, October 3.
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Network Flow Models Chapter 7.
1 1 Slide © 2000 South-Western College Publishing/ITP Slides Prepared by JOHN LOUCKS.
Introduction to Management Science
NetworkModel-1 Network Optimization Models. NetworkModel-2 Network Terminology A network consists of a set of nodes and arcs. The arcs may have some flow.
The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each decision is locally optimal. These.
Chapter 4: Finding the Shortest Path Lesson 1: Dijkstra’s Algorithm
Using Dijkstra’s Algorithm to Find a Shortest Path from a to z 1.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms Shortest-Path.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Operations Research Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD4207 University of Palestine.
1 Network Optimization Chapter 3 Shortest Path Problems.
Graph Theory Topics to be covered:
CSCE350 Algorithms and Data Structure Lecture 17 Jianjun Hu Department of Computer Science and Engineering University of South Carolina
1 1 © 2003 Thomson  /South-Western Slide Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
10. Lecture WS 2006/07Bioinformatics III1 V10: Network Flows V10 follows closely chapter 12.1 in on „Flows and Cuts in Networks and Chapter 12.2 on “Solving.
6/10/01Network Problems: DJK1 Network Problems Chapters 9 and 10.
COSC 2007 Data Structures II Chapter 14 Graphs I.
1 Network Models Transportation Problem (TP) Distributing any commodity from any group of supply centers, called sources, to any group of receiving.
Chapter 3 Algorithms Complexity Analysis Search and Flow Decomposition Algorithms.
Problem Reduction So far we have considered search strategies for OR graph. In OR graph, several arcs indicate a variety of ways in which the original.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Thursday, May 2 Dynamic Programming – Review – More examples Handouts: Lecture Notes.
Dijkstra animation. Dijksta’s Algorithm (Shortest Path Between 2 Nodes) 2 Phases:initialization;iteration Initialization: 1. Included:(Boolean) 2. Distance:(Weight)
7-1 Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall Network Flow Models Chapter 7.
1 GRAPHS – Definitions A graph G = (V, E) consists of –a set of vertices, V, and –a set of edges, E, where each edge is a pair (v,w) s.t. v,w  V Vertices.
Part3 Algorithms By example … Overview Shortest Path Knapsack.
SHORTEST ROUTE PROBLEM A Networking Model Report for DPA 702 QUANTITATIVE METHODS OF RESEARCH By: ALONA M. SALVA Cebu Technological University.
Chapter Chapter Summary Graphs and Graph Models Graph Terminology and Special Types of Graphs Representing Graphs and Graph Isomorphism Connectivity.
1 1 Slide © 2005 Thomson/South-Western Chapter 9 Network Models n Shortest-Route Problem n Minimal Spanning Tree Problem n Maximal Flow Problem.
Operations Research II Course,, September Part 2: Network Flow Operations Research II Dr. Aref Rashad.
St. Edward’s University
Greedy Technique.
Shortest Path from G to C Using Dijkstra’s Algorithm
More Graph Algorithms.
Party-by-Night Problem
Graphs Chapter 13.
Dynamic Programming General Idea
Dijkstra’s Algorithm for the Shortest Path Problem
Shortest Path.
Unit 4: Dynamic Programming
Dynamic Programming General Idea
ICS 353: Design and Analysis of Algorithms
and 6.855J March 6, 2003 Maximum Flows 2
Graphs.
Graphs.
Trees-2, Graphs Data Structures with C Chpater-6 Course code: 10CS35
The Greedy Approach Young CS 530 Adv. Algo. Greedy.
Graphs.
Graphs.
Presentation transcript:

1 Chapter 9 Dynamic Programming General Problem-Solving strategy Was born in the 1950s (Bellman) Based on successive decomposition Leads to functional equations More “Art” than “Science” (?) Difficult to teach/learn No general purpose software Usually taught/learned by example

2 programme Shortest Path problem Knapsack problem Tower of Hanoi Puzzle Travelling Salesman Problem (??) Critical Path Problem (Chapter 10) And Dijkstra’s Algorithm (BYO) (details in due course)

3 9.1 Shortest Path Problem Graphs: –Nodes (vertices) –Arcs (edges) Networks –Nodes –Arcs –Additional information (eg. length)

4 The significance of the “drawing” is the precedence relationships it represents, not the visual picture. On the other hand, the picture can tell us a lot about the nature of the relationships... Make sure that you distinguish between the drawing and the relationships!!!!!

6 Terminology Path Predecessor Successor Immediate Predecessor immediate Successor Origin (no predecessor) Destination (no successors) Cycle Acyclic graph

7 Notation S(n) := Set of immediate predecessors of node n P(n) := Set of Immediate successors of node n.  := empty set

8 Lemma If a directed graph with a finite number of nodes N is acyclic, then the nodes can be numbered in such a way that the following condition is satisfied: m < n for all m in P(n), n=1,2,...,N In words, an ordering of nodes exists such that all arcs are directed from a lower numbered node to a higher numbered node.

9 Labeling Procedure Find a node without a predecessor Label this node “1” Delete all arcs incident from “1” Set n=1 Repeat the process for n=n+1 until all nodes are labeled.

10 Example 9.1.2

13 Problem Statement Given a directed graph where each arc is assigned a numerical length, we want to find the shortest path between a specified origin s and a specified destination t, where the length of a path is equal to the sum of the arc lengths on that path. There are “generalised” shortest path problems where the length of a path is not “additive” (Eg. ??????)

14 DP Strategy We embed the problem of interest (shortest path from origin to destination) in a family of other related problems. We establish some relationaships between the optimal solutions to these problems. We solve this relationship (functional equation) From the solution of the functional equation we obtain the solution to the problem of interest.

15 Convention Origin = node 1 destination = node N

16 Let f(j) := length of the shortest path from the origin to node j, j=1,2,...,N Note that we are interested “only” in f(N).

17 Observation #1 f(j) = f(k) + a k,j for some k in P(j) (why?) j k 1 N (NILN)

18 But,.... ? What is the value of k ????????? f(j) = f(k) + a k,j (k := “Best” immediate predecessor) We identify k by “doing the best we can”, ie. we find the value of k for which f(j) = f(k) + a k,j is the smallest possible among all immediate predecessor of node j.

19 result DP functional equation

20 Remark Since a ij = infinity if k is not in P(j), the functional equation can be rewritten as follows:

21 Notation Let (Constructed as we solve the functional equation)

22 Procedure We start by setting f(1)=0 Then, we determine the values of f(2),f(3),f(4), in this order. This is possible because our networks are acyclic. For small problems we can do it on the picture itself.

23 Example P(2)={1}, P(3){1}; P(4)={2,3}; P(5)={2,4}; P(6)={3,4}; P(7)={5,6}

(0)

(0) (0) (3) (2) x x

(0) (3) (2) (0) (3) (2) (6) x x x x x

(0) (3) (2) (6) x x x (0) (3) (2) (6) x x x (10) x

(0) (3) (2) (6) x x x (10) x (0) (3) (2) (6) x x x (10) x (9) x

(0) (3) (2) (6) x x x (10) x (9) x (0) (3) (2) (6) x x x (10) x (9) x (15) x x

(0) (3) (2) (6) x x x (10) x (9) x (15) x x Summary: f(1)=0; f(2)=3; f(3)=2;f(4)=6;f(5)=10;f(6)=9; f(7)=15. Question: How do we recover optimal paths?

31 We go backward along marked arcs (0) (3) (2) (6) x x x (10) x (9) x (15) x x

(0) (3) (2) (6) x x x (10) x (9) x (15) x x (0) (3) (2) (6) x x x (10) x (9) x (15) O O

(0) (3) (2) (6) x x x (10) x (9) x (15) O O (0) (3) (2) (6) x x x (10) O (9) O (15) O O

(0) (3) (2) (6) x x O (10) O (9) O (15) O O (0) (3) (2) (6) x x x (10) O (9) O (15) O O

(0) (3) (2) (6) x x O (10) O (9) O (15) O O (0) (3) (2) (6) x O O (10) O (9) O (15) O O

36 There are two optimal paths: p 1 =(1,3,4,5,7) ; p 2 =(1,3,4,6,7) (0) (3) (2) (6) x O O (10) O (9) O (15) O O

37 Remark It is OK (in the exam, assignment, etc) to do the calculation directly on the picture, but write down the details for one nontrivial node, eg:

38 Comment The are many generalisations