Download presentation

Presentation is loading. Please wait.

Published byElvin Davis Modified over 6 years ago

1
Dijkstra’s Algorithm and Heuristic Graph Search David Johnson

2
DFS and BFS Examples of uninformed graph search –Only metric of quality is number of vertices in path Want to look at difficulty of moving along an edge –Weighted graph –Want the minimum cost path

3
Dijkstra’s Algorithm Always finds the lowest cost path –For positive edge weight graphs Some subtle differences with breadth-first search Maintains a cost to visit every vertex Looks at the successors of the current lowest cost vertex in the wavefront

4
Dijkstra’s Outline Initialize a cost array to infinity Set the start vertex cost to 0.0, put in search list Find the minimum cost vertex in searchList For each successor –Compute tentative cost = current cost + edge –If tentative cost < existing cost then overwrite Mark min cost vertex as visited/locked –This has a different meaning than breadth-first Terminate when goal is minimum cost vertex

5
Example Look at graph in matlab, run through by hand.

6
Heuristic Search More powerful techniques employ a heuristic –Estimate cost to goal –Expand most promising vertices first –Try to avoid the expanding ring of BFS and Dijkstra

7
Search Heuristics Heuristic –Informal approach to solving a problem –“rule-of-thumb” –Estimates On a terrain map, what would be an example heuristic for choosing which node to expand?

8
Greedy Best-First Search Expands the vertex in the search list with the smallest valued estimated cost to goal –Can only use when a meaningful heuristic is available –Ignores the cost so far

9
Dijkstra vs Best-First

10
Problem Solved?

11
A* Combines –Dijkstra’s current path cost G(n) –Best-first’s cost to goal heuristic H(n) Finds shortest paths –Under some conditions Doesn’t search as much as BFS Pretty standard

12
A* Expands the node with smallest F(n) = G(n) + H(n) Need to choose H(n) –If H(n) < true cost, finds shortest path What if G(n) >> H(n)? What if H(n) >> G(n)?

13
Some Example Heuristics 4-point connectivity (Manhattan distance)

14
Some Example Heuristics 8-point connectivity

15
Some Example Heuristics Euclidean Distance –Cannot move to match heuristic –H(n) does not match G(n)

16
One complication Multiple paths may have same cost A* will explore them all What kind of terrain would this map represent?

17
Add a tie-breaker Makes the costs not exactly the same

18
Implementation Just like Dijkstra –Need a cost-so-far plus heuristic cost summed array –Select current vertex based on that

19
More resources Amit’s A* page –http://theory.stanford.edu/~amitp/GameProgra mming/Heuristics.htmlhttp://theory.stanford.edu/~amitp/GameProgra mming/Heuristics.html –Applet –http://www.vision.ee.ethz.ch/~cvcourse/astar/ AStar.html

Similar presentations

© 2022 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google