/
Chapter  9 Shortest Paths and Chapter  9 Shortest Paths and

Chapter 9 Shortest Paths and - PowerPoint Presentation

briana-ranney
briana-ranney . @briana-ranney
Follow
344 views
Uploaded On 2019-06-23

Chapter 9 Shortest Paths and - PPT Presentation

Discrete Dynamic Programming Example 91 Littleville Suppose that you are the city traffic engineer for the town of Littleville Figure 91a depicts the arrangement of one and twoway streets in a proposed improvement plan for ID: 760161

node path nodes shortest path node shortest nodes negative start algorithm step dicycles graph dynamic paths optimal length project solution activity functional

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Chapter 9 Shortest Paths and" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Chapter

9

Shortest Paths and

Discrete Dynamic Programming

Slide2

Example 9.1 Littleville

Suppose

that you are the city traffic engineer for the town of

Littleville

. Figure

9.1(a

) depicts the arrangement of one- and two-way streets in a proposed improvement plan for

Littleville’s

downtown, including the estimated average time in seconds that a car will require to transit each block.

From

survey and other data we can estimate how many driver trips originate at various origin points in the town, and the destination for which each trip is bound. But such survey data cannot indicate what streets will be selected by motorists to move from origin to destination in a street network that does not yet exist

.

Slide3

Example 9.1 Littleville

One

of the tasks of a traffic engineer is to project the route that drivers will elect, so that city leaders can evaluate whether flows will concentrate where they hope. A good starting point is to assume that drivers will do the most rational thing-follow the shortest time path from their origin to their destination. We need to compute all such shortest paths.

Slide4

Example 9.1 Littleville

20

18

12

18

13

28

38

32

30

18

28

36

25

49

21

40

Slide5

Example 9.1 Littleville

1

2

3

4

10

9

7

6

5

8

20

12

18

13

25

21

28

49

18

28

36

40

18

38

32

30

Slide6

9.1 Shortest Path Models

Urban traffic, Satellite communications, or surface of a microchip.

Mathematical

graphs

model travel, flow, and adjacency patterns in a

network

. [9.1]

The

nodes

or

vertices

of a graph represent entities, intersections, and transfer points of the network. [9.2]

The

arcs

of

a graph

model available directed (one-way) links between nodes. Edges represent undirected (two-way

)

links.

[

9.3]

Slide7

9.1 Shortest Path Models

A path is a sequence of arcs or edges connecting two specified nodes in a graph. Each arc or edge must have exactly one node in common with its predecessors in the sequence, any arcs must passed in the forward direction, and no node may be visited more than once. [9.4]

Slide8

Shortest Path Problems

Shortest

path problems seek minimum total length paths between specified pairs of nodes in a graph. [9.5]

Slide9

Example 9.1 Littleville

1

2

3

4

10

9

7

6

5

8

20

12

18

13

25

21

28

49

18

28

36

40

18

38

Name:

Littleville

Graph

: arcs and edges

Costs

: nonnegative

Output

: shortest paths

Pairs

: all nodes to all others

Slide10

Example 9.2 Texas Transfer

Texas Transfer, a major trucker in the southwest, ships goods from its hub warehouse in Ft. Worth to all the cities shown. Trucks leave the hub and proceed directly to their destination city, with no intermediate

dropoffs

or pickups.

Texas

Transfer drivers are allowed to choose their own route from Ft. Worth to their destination. However, management’s proposal in current labor negotiations calls for drivers to be paid on the basis of shortest standard mileage to the location. That is, they will be paid according to the length of the shortest path from Ft. Worth to their destination city in the network of Figure 9.3. To see the impact of this proposal, we need to compute such shortest path distances for all cities

.

Slide11

Example 9.2 Texas Transfer

Notice

that the character of this shortest path task differs significantly from the

Littleville

example. Here we need only optimal path lengths, not the paths themselves.

Also

, we need shortest path lengths for only one origin or source—the Ft. Worth hub.

Slide12

Example 9.2 Texas Transfer

1

2

3

4

10

9

7

6

5

8

359

122

345

443

92

199

246

213

195

79

215

153

180

167

415

El Paso

Lubbock

Amarillo

Ft. Worth

Abilene

San Angelo

San Antonio

Corpus Christi

Houston

Austin

Name: Texas Transfer

Graph

:

edges only

Costs

: nonnegative

Output

: shortest

path lengths

Pairs

:

one node

to all others

Slide13

Example 9.3 Two Ring Circus

The Two Ring Circus is nearing the end of its season and planning a return to winter headquarters near Tallahassee, Florida. Present commitments will end in Lincoln, Nebraska, but there are still some opportunities for bookings in cities along the route home.

Figure

9.4(a) shows the travel routes available and the estimated costs (in $1000) of moving the circus over those routes. It also designates the cities where bookings have been offered and the anticipated net receipts (in thousands of dollars).

We

want to compute the optimal path home for Two Ring. Notice that the cost of a path is the difference of travel costs and net receipts from performances along the way. But receipts occur at nodes of the network, not on edges as shortest path models require.

Slide14

Example 9.3 Two Ring Circus

Chattanooga(3.0)

1

3

2

9

8

7

5

4

6

3.6

2.8

3.8

4.5

2.1

2.6

5.5

4.5

4.5

2.4

2.2

5.1

Wichita

(3.2)

Lincoln

(0.0)

Davenport (1.6)

Little Rock(3.0)

Jackson(1.0)

Tallahassee(0.0)

Montgomery (1.5)

Springfield (1.5)

4.6

1.7

4.6

Slide15

Undirected and Directed Graph (Digraph)

A shortest path problems including edges (i, j) of cost ci,j can be converted to an equivalent one on a digraph by replacing each edge with a pair of opposed arcs as [9.6]

i

j

c

i,j

i

j

c

i,j

c

j,i

Slide16

Example 9.3 Two Ring Circus

Chattanooga (3.0)

1

3

2

9

8

7

5

4

6

3.6

2.8

3.8

4.5

2.1

2.6

5.5

4.5

4.5

2.4

2.2

5.1

Wichita

(3.2)

Lincoln

(0.0)

Davenport (1.6)

Little Rock(3.0)

Jackson(1.0)

Tallahassee(0.0)

Montgomery (1.5)

Springfield (1.5)

4.6

1.7

4.6

3.6

1.7

4.6

2.8

5.1

4.5

4.5

5.5

4.6

2.1

3.8

2.4

2.6

2.2

4.5

Slide17

Two Ring Example Model

Chattanooga

1

3

2

9

8

7

5

4

6

3.6

-0.4

0.8

1.5

1.1

1.1

2.5

3.5

3.0

0.9

2.2

3.6

Wichita

Lincoln

Davenport

Little Rock

Jackson

Tallahassee

Montgomery

Springfield

4.6

0.2

1.6

2.0

0.1

3.1

2.8

2.3

1.3

1.5

4.0

1.6

-0.9

2.8

-0.6

1.6

0.7

4.5

Name: Two Ring Circus

Graph

:

directed

Costs

:

arbitrary

Output

: shortest

path Pairs

:

one source to one destination

Slide18

9.2 Dynamic Programming Approach to Shortest Paths

Dynamic programming methods exploit the fact that it is sometimes easiest to solve one optimization problem by taking on an entire family.

Shortest path algorithms exploit relationships among optimal paths (and path lengths) for different pairs on the nodes. [9.7]

Slide19

Functional Notationfor One Source to All Other Nodes

[k]  length of a shortest path from the source node to the node k (= + if no path exists)xi,j[k]  1 if arc/edge (i, j) is part of the optimal path from the source node to node k 0 otherwise

Slide20

Functional Notationfor All Nodes to All Other Nodes

[k, l]  length of a shortest path from node k to the node l (= + if no path exists)xi,j[k, l]  1 if arc/edge (i,j) is part of the optimal path from the node k to node l 0 otherwise

Slide21

Optimal Paths and Subpaths

If the highlighted path (through Austin and San Antonio) is the shortest from Ft. Worth to Corpus Christi, the subpath from Ft. Worth to San Antonio must also be the shortest. (No negative dicycle)

1

2

3

4

10

9

7

6

5

8

359

122

345

443

92

199

246

213

195

79

215

153

180

167

415

El Paso

Lubbock

Amarillo

Ft. Worth

Abilene

San Angelo

San Antonio

Corpus Christi

Houston

Austin

Slide22

Negative Dicycles Exception

A dicycle is a path that begins and ends at the same node, and a negative dicycle is a dicycle of negative total length. [9.8]Shortest path models with negative dicycles are much less tractable than other cases because dynamic programming methods usually do not apply. [9.9]

1

2

3

4

2

10

-25

3

12

[1]=0

[2]=-3

[3]=5

[4]=17

Slide23

Principle of Optimality

In a graph with no negative

dicycles

, optimal paths must have optimal

subpaths

. [9.10]

Functional equations of a dynamic program encode the recursive connections among optimal solution values that are implied by a principle of optimality.

[9.11]

Slide24

Functional Equationsfor One Node to All Others

The

functional equations for shortest path problems from a single source

s

in a graph with no negative

dicycles

are [9.12]

[

s

] = 0

[

k

] =

min

{

[

i

] +

c

i,k

:

(

i,

k

) exists

}

all

k≠s

Slide25

Sufficiency of Functional Equationsin One to All Case

Node

value [

k

]

in a graph with no negative

dicycles

are lengths of shortest paths from a given source

s

if and only if they satisfy functional equations in [9.12]. [9.13]

Slide26

Sufficiency of Functional Equationsin One to All Case

[4]=[5]+ c5,4[5]=[3]+ c3,5[4]+[5]=[5]+ c5,4+ [3]+ c3,5[4]=cs,5+ c5,4[4] cs,1+ c1,2+c2,4

1

2

3

4

10

9

7

6

5

8

359

122

345

443

92

199

246

213

195

79

215

153

180

167

415

El Paso

[

4

]

=623

Lubbock

[

2

]

=347

Amarillo

[

1

]

=359

Ft. Worth

[

3

]

=0

Abilene

[

5

]

=180

San Angelo

[

6

]

=272

San Antonio

[

7

]

=274

Corpus Christi

[

10

]=427

Houston[9]=246

Austin

[

8

]

=195

Slide27

Functional Equationsfor All Nodes to All Others

The

functional equations for shortest path problems from a single source

s

in a graph with no negative

dicycles

are [9.14]

[

k,k

] = 0 all

k

[

k,l

] =

min

{

c

k,l

,

{

[

k

,

i

] +

[

i

,

l

] :

i

k, l

}

}

all

k≠l

Node

pair values

[

k,l

]

in a graph with no negative

dicycles

are lengths of shortest paths

from

k

to

l

if

and only if they satisfy functional equations in [

9.14].

[

9.15]

Slide28

Solving Shortest Path Problems byLinear Programming

Although shortest path problems over graphs with no negative

dicycles

can be solved by linear programming, dynamic programming methods based on the principle of optimality are far more efficient. [9.16]

Slide29

9.3 Shortest Paths from One Node to All Others: Bellman-Ford

Solving the functional equations can be carried out by calculating the single value

[

k

] (one-pass evaluation).

Dicycles

introduce circular dependencies in functional equations that preclude their solution by

one-pass

evaluation, even if the length of all

dicycles

is non-negative.

[9.17]

Slide30

Repeated Evaluation Algorithm: Bellman-Ford

(t)

[

k

]  value of

[

k

] obtained on the

t

th

iteration

d

[

k

]node preceding

k

in the best known path from

s

to

k

.

Slide31

Algorithm 9A: One to All (no Negative Dicycles) Bellman-Ford

Step 0: Initiation

. With

s

the source node, initialize optimal path lengths

(0)

[

k

] = 0 if

k

=

s

= + otherwise

and set iteration counter t

 1

Step

1: Evaluation.

For each

k

evaluate

(t)

[

k

]

min

{

(

t-1)

[

i

] +

c

i,k

: (

i, k

) exists

}

if 

(t)

[

k

]

<

(

t-1)

[

k

], also set

d

[

k

]

 the number of a neighboring node

i

achieving the minimum

(t)

[

k

]

.

Slide32

Algorithm 9A: One to All (no Negative Dicycles) Bellman-Ford

Step 2: Stopping

.

Terminate if 

(t)

[

k

]

<

(t-1)

[

k

] for every

k

, or if t= the number of nodes in the graph. Value

(t)

[

k

]

then equal the required shortest path lengths unless some

(t)

[

k

]

changed at the last t, in which case the graph contains a negative

dicycle

.

Step 3: Advance.

If some [

k

]

changed and t < the number of nodes, increment t

 t+1 and return to Step 1.

Slide33

Two Ring Example Model

Chattanooga

1

3

2

9

8

7

5

4

6

3.6

-0.4

0.8

1.5

1.1

1.1

2.5

3.5

3.0

0.9

2.2

3.6

Wichita

Lincoln

Davenport

Little Rock

Jackson

Tallahassee

Montgomery

Springfield

4.6

0.2

1.6

2.0

0.1

3.1

2.8

2.3

1.3

1.5

4.0

1.6

-0.9

2.8

-0.6

1.6

0.7

4.5

Slide34

Bellman-Ford Solution of the Two Ring Circus Example

t

(t)

[

1

]

(t)

[

2

]

(t)

[

3

]

(t)

[4]

(t)

[

5

]

(t)

[

6

]

(t)

[

7

]

(t)

[

8

]

(t)

[

9

]

0

0

+

+

+

+

+

+

+

+

1

3.6

2.8

4.6

2

3.7

4.1

3

5.7

3.2

4

4.8

6.7

5

5.5

t

d

[

1

]

d[

2

]

d[

3

]

d[4]

d[

5

]

d[

6

]

d[

7

]

d[

8

]

d[

9

]

1

1

1

1

2

2

3

3

5

5

4

7

7

5

8

Slide35

Bellman-Ford Algorithm

At the completion of Bellman-Ford Algorithm, a shortest path from source

s

to any other node

k

can be recovered by starting at

k

, backtracking to neighboring node

d

[

k

], and continuing with an optimal path from

s

to the neighbor until source s is encountered. [9.18]

If Bellman-Ford Algorithm encounters negative

dicycles

, it will demonstrate their presence by continuing to change

(t)

[

k

] on iteration t = the number of nodes. Any node

k

with such changing

(t)

[

k

] belongs to a negative

dicycle

. [9.19]

Slide36

Two Ring Example Model

Chattanooga

1

3

2

9

8

7

5

4

6

3.6

-0.4

0.8

1.5

1.1

1.1

2.5

3.5

3.0

0.9

2.2

3.6

Wichita

Lincoln

Davenport

Little Rock

Jackson

Tallahassee

Montgomery

Springfield

4.6

0.2

1.6

2.0

0.1

3.1

2.8

2.3

1.3

1.5

4.0

1.6

-0.9

2.8

-0.6

1.6

0.7

4.5

Slide37

9.4 Shortest Paths from All Nodes to All Others: Floyd-Warshall

(t)

[

k, l

]  length of a shortest path for

k

to

l

using only intermediate nodes numbered less than or equal to t.

d

[

k, l

]  node just before

l

on the current path from

k

to

l

.

Slide38

Algorithm 9B: All to All (no Negative Dicycles) Floyd-Warshall

Step 0: Initiation

. All nodes should have consecutive positive numbers starting with 1. For all arcs and edges (

k, l)

in the graph, initialize

(0)

[

k, l

]

c

k,l

d

[

k, l

]

k

For

k

, l

pairs with no arc/edge (

k,

l

), assign

(0)

[

k, l

]

= 0 if

k

=

l =

+ otherwise

also set iteration counter t

 1

Step

1: Evaluation.

For all

k, l

≠ t update

(t)

[

k, l

]

min {

(

t-1)

[

k, l

],

(t-1)

[

k,

t

]

+

(t-1)

[t

, l

]

}

if 

(t)

[

k, l

]

<

(

t-1)

[

k, l

], also set

d

[

k, l

]

d

[t

,

l

]

Slide39

Algorithm 9B: All to All (no Negative Dicycles) Floyd-Warshall

Step 2: Stopping

.

Terminate

if t = the number of nodes in the graph, or if

(t)

[

k, k

]

<

0

for any node

k

. Value

(t)

[

k, l

]

then equal the required shortest path lengths unless some

(t)

[

k, k

]

is negative, in which case the graph contains a negative

dicycle

through

k

.

Step 3: Advance.

If t < the

number of nodes and

(t)

[

k,k

]0

, increment t

 t+1 and return to Step 1.

Slide40

Example 9.1 Littleville

1

2

3

4

10

9

7

6

5

8

20

12

18

13

25

21

28

49

18

28

36

40

18

38

32

30

Slide41

Floyd-Warshall Solution of the Littleville Example

Nu

l=1

l=2

l=3

l=4

l=5

l=6

l=7

l=8

l=9

l=10

k=1

0

12

¥

¥

¥

¥

¥

¥

¥

¥

k=2

¥

0

18

¥

¥

32

¥

¥

¥

¥

k=3

¥

¥

0

13

¥

¥

30

¥

¥

¥

k=4

¥

¥

¥

0

¥

¥

¥

¥

¥

38

k=5

20

¥

¥

¥

0

18

¥

¥

¥

¥

k=6

¥

32

¥

¥

18

0

¥

¥

25

¥

k=7

¥

¥

30

¥

¥

28

0

¥

21

49

k=8

¥

¥

¥

¥

18

¥

¥

0

36

¥

k=9

¥

¥

¥

¥

¥

25

21

36

0

40

k=10

¥

¥

¥

¥

¥

¥

49

28

40

0

d

k=1

1

k=2

2

2

k=3

3

3

k=4

4

k=5

5

5

k=6

6

6

6

k=7

7

7

7

7

k=8

8

8

k=9

9

9

9

9

k=10

10

10

10

Slide42

Floyd-Warshall Solution of the Littleville Example

Nu

l=1

l=2

l=3

l=4

l=5

l=6

l=7

l=8

l=9

l=10

k=1

0

12

¥

¥

¥

¥

¥

¥

¥

¥

k=2

¥

0

18

¥

¥

32

¥

¥

¥

¥

k=3

¥

¥

0

13

¥

¥

30

¥

¥

¥

k=4

¥

¥

¥

0

¥

¥

¥

¥

¥

38

k=5

20

32

¥

¥

0

18

¥

¥

¥

¥

k=6

¥

32

¥

¥

18

0

¥

¥

25

¥

k=7

¥

¥

30

¥

¥

28

0

¥

21

49

k=8

¥

¥

¥

¥

18

¥

¥

0

36

¥

k=9

¥

¥

¥

¥

¥

25

21

36

0

40

k=10

¥

¥

¥

¥

¥

¥

49

28

40

0

d

 

k=1

 

1

 

 

 

 

 

 

 

 

k=2

 

2

2

k=3

 

3

3

k=4

 

4

k=5

5

1

5

k=6

 

6

6

6

k=7

 

7

7

7

7

k=8

 

8

8

k=9

 

9

9

9

9

k=10

 

10

10

10

Slide43

Floyd-Warshall Solution of the Littleville Example

Nu

l=1

l=2

l=3

l=4

l=5

l=6

l=7

l=8

l=9

l=10

k=1

0

12

30

¥

¥

44

¥

¥

¥

¥

k=2

¥

0

18

¥

¥

32

¥

¥

¥

¥

k=3

¥

¥

0

13

¥

¥

30

¥

¥

¥

k=4

¥

¥

¥

0

¥

¥

¥

¥

¥

38

k=5

20

32

50

¥

0

18

¥

¥

¥

¥

k=6

¥

32

50

¥

18

0

¥

¥

25

¥

k=7

¥

¥

30

¥

¥

28

0

¥

21

49

k=8

¥

¥

¥

¥

18

¥

¥

0

36

¥

k=9

¥

¥

¥

¥

¥

25

21

36

0

40

k=10

¥

¥

¥

¥

¥

¥

49

28

40

0

d

 

k=1

1

2

2

k=2

 

 

2

 

 

2

 

 

 

 

k=3

 

3

3

k=4

 

4

k=5

5

1

2

5

k=6

6

2

6

6

k=7

 

7

7

7

7

k=8

 

8

8

k=9

 

9

9

9

9

k=10

 

10

10

10

Slide44

Floyd-Warshall Solution of the Littleville Example

Nu

l=1

l=2

l=3

l=4

l=5

l=6

l=7

l=8

l=9

l=10

k=1

0

12

30

43

¥

44

60

¥

¥

¥

k=2

¥

0

18

31

¥

32

48

¥

¥

¥

k=3

¥

¥

0

13

¥

¥

30

¥

¥

¥

k=4

¥

¥

¥

0

¥

¥

¥

¥

¥

38

k=5

20

32

50

63

0

18

80

¥

¥

¥

k=6

¥

32

50

63

18

0

80

¥

25

¥

k=7

¥

¥

30

43

¥

28

0

¥

21

49

k=8

¥

¥

¥

¥

18

¥

¥

0

36

¥

k=9

¥

¥

¥

¥

¥

25

21

36

0

40

k=10

¥

¥

¥

¥

¥

¥

49

28

40

0

d

 

k=1

1

2

3

2

3

k=2

2

3

2

3

k=3

 

 

 

3

 

 

3

 

 

 

k=4

 

4

k=5

5

1

2

3

5

3

k=6

6

2

3

6

3

6

k=7

7

3

7

7

7

k=8

 

8

8

k=9

 

9

9

9

9

k=10

 

10

10

10

Slide45

Floyd-Warshall Solution of the Littleville Example

Nu

l=1

l=2

l=3

l=4

l=5

l=6

l=7

l=8

l=9

l=10

k=1

0

12

30

43

62

44

60

105

69

81

k=2

70

0

18

31

50

32

48

93

57

69

k=3

96

90

0

13

76

58

30

79

51

51

k=4

104

116

117

0

84

102

87

66

78

38

k=5

20

32

50

63

0

18

80

79

43

83

k=6

38

32

50

63

18

0

80

61

25

65

k=7

66

60

30

43

46

28

0

57

21

49

k=8

38

50

68

81

18

36

96

0

36

76

k=9

63

57

51

64

43

25

21

36

0

40

k=10

66

78

79

92

46

64

49

28

40

0

d

 

k=1

1

2

3

6

2

3

9

6

4

k=2

6

2

3

6

2

3

9

6

4

k=3

7

7

3

7

7

3

10

7

4

k=4

10

10

10

10

10

10

10

10

4

k=5

5

1

2

3

5

3

9

6

9

k=6

5

6

2

3

6

3

9

6

9

k=7

6

6

7

3

6

7

9

7

7

k=8

5

5

5

5

8

5

5

8

9

k=9

6

6

7

7

6

9

9

9

9

k=10

8

8

7

7

8

8

10

10

10

 

Slide46

Floyd-Warshall Algorithm

At the completion of

Floyd-

Warshall

Algorithm, a shortest path from any node

k

to any other node

l

can be recovered by starting at

l

, backtracking to neighboring node

d

[

k, l

], and continuing with an optimal path from

k

to the neighbor until source

k

itself is encountered. [9.20]

If

Floyd-

Warshall

Algorithm is applied to a graph with negative

dicycles

, it will demonstrate their presence by making

some 

(t)

[

k,k

]

< 0 and terminating. Under those circumstances, the implied negative

dicycle

includes node

k

. [9.21]

Slide47

9.5 Shortest Path from One Node to All Others with Cost Non-negative: Dijkstra

The bellman-Ford and Floyd-

Warshall

algorithms can solve any of the shortest path models without negative

dicycles

.

With further assumptions, other algorithms may be more efficient.

Slide48

Algorithm 9C: One to All (Non-Negative Costs): Dijkstra

Step 0: Initiation

. With

s

the source node, initialize optimal path lengths

[

i

] = 0 if

i

=

s

= + otherwise

Then mark all nodes temporary, and choose

p

s

as the next permanently labeled node.

Step

1: Processing.

Mark node

p

permanent, and for every arc/edge (

p

,

i

) leading from

p

to a temporary

node, update [

i

]

min

{

[

i

], 

[

p

]

+

c

p,i

}

if [

i

] changed in value, also set

d

[

k

]

p

.

Slide49

Step 2: Stopping. If no temporary nodes remain, stop; values [i] now reflect the required shortest path lengths. Step 3: Next Permanent. Choose as next permanently labeled node p a temporary node with least current value [i], that is, [p] = min {[i] : i temporary } Then return to Step 1.

Algorithm 9C: One to All

(Non-Negative Costs):

Dijkstra

Slide50

Once a node is classified permanent by Dijkstra Algorithm, its [p] and d[p] labels never change again. Nodes that are not yet permanently labeled are classified temporary. [9.22]Dijkstra Algorithm is the most efficient method available for computing shortest paths from one node to all others in (general) graphs and digraphs having all are/edge costs non-negative. [9.23]Each iteration of Dijkstra’s Algorithm selects as the new permanently labeled node p a temporary node of minimum [i]. [9.24]

Permanently and Temporary Labeled Nodes

Slide51

Dijkstra Algorithm Solution of the Texas Transfer Example

1

2

3

4

10

9

7

6

5

8

359

122

345

443

92

199

246

213

195

79

215

153

180

167

415

El Paso

Lubbock

Amarillo

Ft. Worth

Abilene

San Angelo

San Antonio

Corpus Christi

Houston

Austin

Slide52

Dijkstra Algorithm Solution of the Texas Transfer Example

p

n[1]

n[2]

n[3]

n[4]

n[5]

n[6]

n[7]

n[8]

n[9]

n[10]

init.

¥

¥

0

¥

¥

¥

¥

¥

¥

¥

3

359

Perm

180

195

246

5

347

623

Perm

272

8

274

Perm

9

Perm

461

6

Perm

7

Perm

427

2

Perm

1

Perm

10

Perm

4

Perm

p

d[1]

d[2]

d[3]

d[4]

d[5]

d[6]

d[7]

d[8]

d[9]

d[10]

3

3

3

3

3

5

5

5

5

8

8

9

9

6

7

7

2

1

10

4

Slide53

After each major iteration, Dijkstra Algorithm values [i] represent lengths of shortest paths from source s to i that use only permanently labeled nodes. [9.25]

Justification of the Dijkstra Algorithm

s

i

p

All permanent path length

[

p

]

All permanent path length

[

i

]

Non-negative cost

[

i

] 

[

p

]

Slide54

9.6 Shortest Path from One Node to All Others in Acyclic Digraph

Acyclic DigraphsA digraph (completely directed graph) is acyclic if and only if its nodes can be numbered so that every arc (I, j) has I < j. [9.26].

1

2

3

5

4

Acyclic

1

2

3

5

4

Has edges

1

2

3

5

4

Has

dicycles

Slide55

9.6 Shortest Path from One Node to All Others in Acyclic Digraph

Any acyclic digraph can be numbered as required in principle [9.26] by transiting the graph in depth-first fashion, numbering nodes in decreasing sequence as soon as all their outbound arcs lead to nodes already visited. [9.27].

c

a

d

b

e

1st

2nd

3rd

5

4

3

2

1

c

a

d

b

e

1st

2nd

3rd

4th

5

4

3

2

1

Slide56

Algorithm 9D: One to All (Acyclic Digraph)

Step 0: Initiation.

Number nodes so that each arc (

i

,

j

) of the digraph has

i

<

j

. Then set the source

s

optimal path length [

s

]

0

Step 1:

Stopping.

Terminate if all

[

k

] have now been fixed. Otherwise, let

p

be the lowest number of an unprocessed node.

Step

2: Processing.

If there are no inbound arcs at node

p,

set

[

p

]

+. Otherwise, compute

[

p

]

min

{

[

i

] +

c

i,p

: (

i, p

) exists

}

And let d[

p

]

 the number of node

i

achieving the minimum. Then return to Step 1.

Slide57

Algorithm 9D is the most efficient possible for computing shortest paths from one node to all others in acyclic digraphs. [9.28]

Permanently and Temporary Labeled Nodes

Slide58

Figure 9.11 Acyclic Shortest path Example

1

3

2

8

7

5

4

6

5

16

4

-10

1

13

7

18

3

8

9

9

2

5

[

1

]=0

[

2

]=5; d[

2

]=1

[

3

]=-5; d[

3

]=2

[

4

]=-3; d[

4

]=3

[

5

]=;

[

6

]=;

[

7

]=9; d[

7

]=2

[

8

]=22; d[8]=7

[

9

]=4; d[

9

]=4

Slide59

9.7 CPM Project Scheduling and Longest Paths

Project Management

For planning and control purposes, projects are usually subdivided into a collection of work

activities

. Each activity has an estimated

duration

,

a

k

 time required to accomplish activity

k

Activity

j

is a

predecessor

of activity

k

if activity

j

must be completed before activity

k

can begin. [9.29].

Slide60

CPM Project Networks

CPM project networks

have special

start

and

finish

nodes, plus one node for each activity. Arcs of zero length connect

start

to all activities without predecessors. Other arcs of length

a

k

connect each activity node

k

to all activities of which it is a predecessor, or to

finish

if there are no such nodes. [9.30]

Slide61

Example 9.4: We Build Construction

We Build is developing a 1-story medical office building on available land near a hospital.

kActivityDurationPredecessors1Foundation15--2Rough plumbing5--3Concrete slab41, 24Structural members335Roof746Rough electrical1047Heating & AC132, 48Walls184, 6, 79Interior finish205, 8

To plan materials deliveries and arrange subcontractors to do the various activities, We Build needs a schedule. In particular, they want to know the earliest time after project start that each activity can begin.

Slide62

Figure 9.12 We Build Construction Project Network

Start

3

1

9

6

2

8

0

0

4

15

7

13

3

20

10

5

4

5

7

Finish

5

3

3

3

18

Slide63

CPM Schedules and Longest Paths

The earliest start time of any activity

k

in

a project equals the length of the longest path from

start

to node

k

in the corresponding network. [9.31]

The

minimum time to complete a project equals the

length of the longest

or critical path

from

start

to

finish

in

the corresponding

project network

. [

9.32]

Slide64

Critical Paths

kActivityEarly StartCritical Path1Foundation0Start-12Rough plumbing0Start-23Concrete slab15Start-1-34Structural members19Start-1-3-45Roof22Start-1-3-4-56Rough electrical22Start-1-3-4-67Heating & AC22Start-1-3-4-78Walls35Start-1-3-4-7-89Interior finish53Start-1-3-4-7-8-9

Start

3

1

9

6

2

8

0

0

4

15

7

13

3

20

10

5

4

5

7

Finish

5

3

3

3

18

Slide65

Computing an Early Start Schedule for the We Build Construction Example

a

k

 time required to accomplish activity

k

[

k

]  length of the longest path from

start

to node

k

d[

k

] 

immediate predecessor of node

k

in a longest path

The minimum time to complete a project equals the

length of the longest

or critical path

from

start

to

finish

in

the corresponding

project network

. [

9.32]

Slide66

Algorithm 9E: CPM Early Start Scheduling

Step 0: Initiation.

Number activity nodes so that each precedence arc (

i

,

j

) of the CPM project network has

i

<

j

. Then initialize the schedule time of the project start node as

[

start

]

0

Step 1:

Stopping.

Terminate if the early start of the project

finish

node has been fixed. Otherwise, let

p

be the lowest number of an unprocessed node.

Step

2: Processing.

Compute the activity

p

early start schedule time

[

p

]

max

{

[

i

] +

a

i

:

i

is a predecessor of

p

}

And let d[

p

]

 the number of node

i

achieving the maximum. Then return to Step 1.

Slide67

Early Start Schedules

[s]=0;

[1]=0; d[1]=s

[2]=0; d[2]=s

[3]=15; d[3]=1

[4]=19; d[4]=3

[5]=22; d[5]=4

[6]=22; d[6]=4

[7]=22; d[7]=4

[8]=35; d[8]=7

[9]=53; d[9]=8

Start

3

1

9

6

2

8

0

0

4

15

7

13

3

20

10

5

4

5

7

Finish

5

3

3

3

18

[

f

]=73; d[

f

]=

9

Slide68

Late Start Schedules and Schedule Slack

The latest start time of any activity

k

in

a project equals the due date less the length path from

k

to

finish

node in the corresponding CPM network. [9.33]

Schedule slack is the difference between the earliest and latest times that an activity can begin. [9.34]

Slide69

Late Start Schedules

[s]=0; d[s]=1

[1]=0; d[1]=3

[2]=10; d[2]=3

[3]=15; d[3]=4

[4]=19; d[4]=7

[5]=46; d[5]=9

[6]=25; d[6]=8

[7]=22; d[7]=8

[8]=35; d[8]=9

[9]=53; d[9]=f

Start

3

1

9

6

2

8

0

0

4

15

7

13

3

20

10

5

4

5

7

Finish

5

3

3

3

18

[

f

]=73;

Slide70

Schedule Slack

k

Activity

Early Start

Late Start

Slack

1

Foundation

0

0

0

2

Rough plumbing

0

10

10

3

Concrete slab

15

15

0

4

Structural members

19

19

0

5

Roof

22

46

24

6

Rough electrical

22

25

3

7

Heating

& AC

22

22

0

8

Walls

35

35

0

9

Interior finish

53

53

0

Slide71

More on CPM Network

Difficulty of General Longest Path Problems

Longest path problems are the maximize analogs of the shortest path problem. The difficult case of negative

dicycle

in shortest path problems becomes the case of

positive

dicycles

in longest path models –

dicycles

of positive total length. Positive

dicycles

are far more common than their negative relatives.

Acyclic Character of Project Network

Every well-formed project network is acyclic. [9.35]

Slide72

9.8 Discrete Dynamic Programming Models

In a

sequential decision problem

, decision can be arranged in a clear sequence. Then the decisions can be confronted one by one in sequence. That same sequence produces an acyclic digraph on which a shortest or longest path problem can be posed.

States

in dynamic programming characterize conditions of incomplete solution at which decisions should be considered. [9.36]

Slide73

Example 9.5: Wagner-Whitin Lot Sizing

Wagner-Whitin lot sizing – production planning in an environment where there is a substantial setup cost incurred with each production run.

Period, k123456Requirement, rk1040205515Setup cost, sk505050505050Production cost, pk133111Holding cost, hk222222

rk  product required at time ksk  setup cost at time kpk  variable prod. cost at time khk  unit holding cost through k

An optimal solution must carefully balance production and holding costs.

Slide74

States in Dynamic Programming

Produce or hold for period

k

, but not both.

Definition of

states

: The process has reached state

k

when requirements for periods

l

<

k

have been fulfilled and there is no on-hand inventory.

Nodes of the digraph associated with any dynamic program corresponding to state of incomplete solution. [9.37]

Arcs

of the digraph associated with any dynamic program corresponding to

decisions. They link state nodes with a subsequent state to which the decision leads.

[

9.38]

Slide75

Figure 9.13 Digraph for Wagner-Whitin Example

3

7

6

2

60

170

525

55

4

5

180

110

1

55

65

360

315

280

135

170

305

100

270

70

305

145

350

515

Period,

k

1

2

3

4

5

6

r

k

10

40

20

5

5

15

s

k

50

50

50

50

50

50

p

k

1

3

3

1

1

1

h

k

2

2

2222

C

3,6

= setup + production + holding

=s

3

+ (r

3

+ r

4

+ r

5

)p

3

+ [(r

4

+ r

5

)h

3

+r

5

h

4

]

=50 + (20+5+5)3 + [(5+5)2 + (5)2]

=170

Slide76

Dynamic Programming Solutionsas an Optimal Path

Optimal solutions to elementary dynamic programs correspond to shortest or longest paths from a beginning to an ending state in the associated digraph. [9.39]

Dynamic programming functional equation recursions encode connections among optimal values for different states of incomplete solution.

[

9.40]

Slide77

Solution for Wagner-Whitin Example

3

7

6

2

60

170

525

55

4

5

180

110

1

55

65

360

315

280

135

170

305

100

270

70

305

145

350

515

[

1

]=0

[

2

]=60; d[

2

]=1

[

3

]=180; d[

3

]=1

[

4

]=280; d[

4

]=1

[

5

]=315; d[

5

]=1, or 3

[

6

]=350; d[

6

]=3, or 4

[

7

]=415; d[

7

]=5, or 6

Slide78

Dynamic Programming Models with Both Stages and States

In dynamic programs with both stages and states, stages delineate the sequence of required decisions and states encode the conditions within which decisions can be considered. [9.41]

Slide79

Example 9.6: President’s Library

The retiring president is collecting all his papers in a new presidential library. Materials for its archives are stored in covered cardboard boxes. All are 1.25 feet wide, but their height varies. .

1234567Height (ft.), hi0.250.400.801.001.502.003.00# of boxes (1000), bi1021230864

Boxes in the archives will be placed on metal shelves, with no box stacked on top of another. The issue is how much shelving will be required. Figure 9.14 shows that if, for example, two shelf

spacings

are employed. Whether they choose to provide 1, 2 ,..., 7

spacings

, they

want to

use the space as efficiently as possible.

Slide80

Figure 9.14 President’s Library Shelving Face Areas (two shelf spacings)

0 10 20 30 40 50 60 70

Feet of Shelves(000’s)

Box Height(feet)

3

2

1

0

Slide81

Dynamic Programming Modeling of the President’s Library Example

stage k  kth-to-last choice of a spacing state i  having provided shelves for box sizes 0,1,.. i ci,j  choice to provide a spacing for box sizes through j 

 

Slide82

Figure 9.15 Digraph for President’s Library Example

7

0

0

0

0

0

0

0

6

1

1

1

1

1

1

2

2

2

2

2

3

3

3

3

4

4

4

5

5

K=7

K=6

K=5

K=4

K=3

K=2

K=1

K=0

S=1

S=2

S=3

S=4

S=5

S=6

S=7

S=6

15

S=5

15

37.5

S=4

15

35

67.5

S=3

37.5

71.25

110

180

S=2

12

52.5

93.75

140

225

S=1

1

14

55

97.5

145

232.5

S=0

3.125

6

24

67.5

116.25

170

270

Slide83

Backward Solution of Dynamic Programs

Elementary dynamic programs are often most easily conceptualized in backward sequence, that is, proceeding from final to initial conditions. [9.42]Functional equation for the President’s library example:k[i]  optimal cost to finish from stage k, state i 7[7] = 0 k[i] = min {ci,j + k-1[j] : j > i } k = 1,2,..,6; i  (7 - k)

 

Slide84

Backward Solution of Dynamic Programs

Stage kState ik[i] dk[i] 10270.0071232.5072225.0073180.007467.507537.507615.00720135.0041122.5042120.0043105.004450.006530.006

Stage kState ik[i] dk[i] 30117.5041105.0042102.504387.504445.00540108.1311100.004297.504382.50450103.131196.503294.503

Stage

k

State

i

k

[

i

]

d

k

[

i

]

6

0

99.63

1

1

95.50

2

7

0

98.63

1

Slide85

Multiple Problem Solutions Obtained Simultaneously

The dynamic programming strategy of exploiting connections among optimal solutions for a number of related problems often implies that optima for multiple problem scenarios are produced by a single shortest or longest path computation. [9.43]