0% found this document useful (0 votes)
88 views3 pages

A Second Example

This document provides a second example of dynamic programming. It describes finding the shortest path from node A to node J in a road network. The problem is broken down into stages based on the nodes. Shortest paths and costs are calculated moving backwards through each stage, using the principle of optimality from dynamic programming. Calculations are shown to find the shortest path and costs from each node to the destination J by iterating through each stage one by one.

Uploaded by

newbigbat
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views3 pages

A Second Example

This document provides a second example of dynamic programming. It describes finding the shortest path from node A to node J in a road network. The problem is broken down into stages based on the nodes. Shortest paths and costs are calculated moving backwards through each stage, using the principle of optimality from dynamic programming. Calculations are shown to find the shortest path and costs from each node to the destination J by iterating through each stage one by one.

Uploaded by

newbigbat
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

A second example http://mat.gsia.cmu.edu/classes/dynamic/node3.

html

next previous contents


Next: Common Characteristics Up: A Tutorial on Dynamic Previous: First Example

A second example
Dynamic programming may look somewhat familiar. Both our shortest path algorithm and our method for CPM project scheduling have a lot in
common with it.

Let's look at a particular type of shortest path problem. Suppose we wish to get from A to J in the road network of Figure 2.

Figure 2: Road Network

The numbers on the arcs represent distances. Due to the special structure of this problem, we can break it up into stages. Stage 1 contains node A,
stage 2 contains nodes B, C, and D, stage 3 contains node E, F, and G, stage 4 contains H and I, and stage 5 contains J. The states in each stage
correspond just to the node names. So stage 3 contains states E, F, and G.

If we let S denote a node in stage j and let be the shortest distance from node S to the destination J, we can write

1 of 3 4/10/2011 3:20 PM
A second example http://mat.gsia.cmu.edu/classes/dynamic/node3.html

where denotes the length of arc SZ. This gives the recursion needed to solve this problem. We begin by setting . Here are the rest
of the calculations:

Stage 4.
During stage 4, there are no real decisions to make: you simply go to your destination J. So you get:
by going to J,
by going to J.

Stage 3.
Here there are more choices. Here's how to calculate . From F you can either go to H or I. The immediate cost of going to H is 6. The
following cost is . The total is 9. The immediate cost of going to I is 3. The following cost is for a total of 7.
Therefore, if you are ever at F, the best thing to do is to go to I. The total cost is 7, so .

The next table gives all the calculations:

You now continue working back through the stages one by one, each time completely computing a stage before continuing to the preceding one.
The results are:

Stage 2.

2 of 3 4/10/2011 3:20 PM
A second example http://mat.gsia.cmu.edu/classes/dynamic/node3.html

Stage 1.

next previous contents


Next: Common Characteristics Up: A Tutorial on Dynamic Previous: First Example

Michael A. Trick
Sun Jun 14 13:05:46 EDT 1998

3 of 3 4/10/2011 3:20 PM

You might also like