SlideShare a Scribd company logo
1 of 19
CSCI 6212
Presented by Team Flash
Member: Shuqing Zhang
Yang Cao
Tong Qiao
A* Algorithm
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 1
 A* is one of the many search algorithm that take an input, evaluates a
number of possible paths and returns a solution.
 A* combines feartures of uniform-cost search and pure heuristic search to
effectively compute optimal solutions
 A* evaluates nodes by combining g(n) and h(n) f(n) = g(n) + h(n)
 f(n) is called evaluation function.
 A* is both complete and optimal.
Introduction
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 2
 f(n) = g(n) + h(n)
 f(n) is the estimated total cost of the cheapest solution through n
 g(n) gives the path cost from the start node to node n
 h(n) named as heuristic function is the estimated cost of the cheapest path
from n to the goal node.
Evaluation Function
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 3
Algorithm Process
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 4
 Given: A graph of nodes, is start, is goal
 Aim: To find out the path from to with the minimum cost
 Procedure
1. Create a search graph G, consisting solely of the start node s. Put s on a list called OPEN.
2. Create a list called CLOSED that is initially empty.
3. LOOP: if OPEN is empty, exit with failure
4. Select the first node on OPEN, remove it from OPEN and put it into CLOSED. Call this node n.
5. If n is a goal node, exit successfully with the solution obtained by tracing a path along the pointers from n to s in G.
6. Expand node n, generating the set M of its successors and install them as successors of n in G.
7. Establish a pointer to n from those members of M that were not already in G(i.e not already on either OPEN or CLOSED). Add these members of M to
OPEN. For each member of M that was already on OPEN or CLOSED, decide whether or not to redircet its pointer to n. For each member of M already
on CLOSED, decide for each its descendents in G whether or not to redirect its pointer.
8. Recorder the list OPEN, eitheraccording to some scheme or some heuristic merit
9. Goto LOOP
sn gn
sn gn
Find the shortest path from Arad to Bucharest
Example
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 5
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 6
OS { }
CS { (Arad, 0, 366) }
OS { (Arad, 0, 366) }
CS { }
OpenSet { (CityName, g(n), f(n)),… }
CloseSet { }
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 7
OS {(Sibiu, 140, 253), (Timisoara,118, 329),
(Zerind, 75, 374)}
CS {(Arad, 0, 366)}
OS { (Timisoara,118, 329), (Zerind, 75, 374)}
CS {(Arad, 0, 366), (Sibiu, 140, 253) }
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 8
OS {(Timisoara,118, 329), (Zerind, 75, 374),
(Fagaras, 239, 176), (Oradea, 291, 380),
(Rimnicu Vikea, 220, 193)}
CS {(Arad, 0, 366), (Sibiu, 140, 253) }
OS {(Timisoara,118, 329), (Zerind, 75, 374),
(Arad, 280, 366), (Fagaras, 239, 176),
(Oradea, 291, 380) }
CS { (Arad, 0, 366), (Sibiu, 140, 253),
(Rimnicu Vikea, 220, 193) }
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 9
OS {(Timisoara,118, 329), (Zerind, 75, 374),
(Fagaras, 239, 176), (Oradea, 291, 380),
(Craiova, 366, 160), (Pitesti, 317, 100)}
CS {(Arad, 0, 366), (Sibiu, 140, 253),
(Rimnicu Vikea, 220, 193)}
OS {(Timisoara,118, 329), (Zerind, 75, 374),
(Oradea, 291, 380), (Craiova, 366, 160),
(Pitesti, 317, 100)}
CS { (Arad, 0, 366), (Sibiu, 140, 253),
(Rimnicu Vikea, 220, 193), (Fagaras, 239, 176)}
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 10
OS {(Timisoara,118, 329), (Zerind, 75, 374),
(Oradea, 291, 380), (Craiova, 366, 160),
(Pitesti, 317, 100), (Bucharest, 450, 0)}
CS { (Arad, 0, 366), (Sibiu, 140, 253),
(Rimnicu Vikea, 220, 193), (Fagaras, 239, 176)}
OS {(Timisoara,118, 329), (Zerind, 75, 374),
(Oradea, 291, 380), (Craiova, 366, 160),
(Bucharest, 450, 0)}
CS { (Arad, 0, 366), (Sibiu, 140, 253),
(Rimnicu Vikea, 220, 193), (Fagaras, 239, 176),
(Pitesti, 317, 100) }
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 11
OS {(Timisoara,118, 329), (Zerind, 75, 374),
(Oradea, 291, 380), (Craiova, 366, 160),
(Bucharest, 450, 0), (Bucharest, 418, 0),
(Craiova, 455, 160)}
CS { (Arad, 0, 366), (Sibiu, 140, 253),
(Rimnicu Vikea, 220, 193), (Fagaras, 239,176),
(Pitesti, 317, 100) }
OS {(Timisoara,118, 329), (Zerind, 75, 374),
(Oradea, 291, 380), (Craiova, 366, 160),
(Bucharest, 450, 0), (Bucharest, 418, 0),
(Craiova, 455, 160)}
CS { (Arad, 0, 366), (Sibiu, 140, 253),
(Rimnicu Vikea, 220, 193), (Fagaras, 239,176),
(Pitesti, 317, 100), (Bucharest, 418, 0) }
Construct the path:
Set pointer from each node to its predecessor.
Construct the path start from the goal, then reverse it.
The path:
Arad->Sibiu->Rimnicu Vikea->Pitesti->Bucharest
Pseudocode
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 12
1: initialize the open list
2: initialize the closed list
3: put the starting node on the open list (leave its f at zero)
-
4: while the open list is not empty
5: find the node with the least f on the open list, call it “q”
6: pop q off the open list
7: generate q’s successors and set their parents to q
8: for each successor
9: if successor is the goal, stop the search
10: successor.g = q.g + distance between successor and q
11: successor.h = distance from goal to successor
12: successor.f = successor.g + successor.h
-
13: if a same node is in the open list which has a lower f than successor, skip this successor
14: if a same node is in the closed list which has a lower f than successor, skip this successor
15: otherwise, add the node to the open list
16: end
17: push q on the closed list
18: end
 Admissibility
 Consistency
Conditions for Optimality
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 13
 A heuristic h(n) is admissible if for every node n, h(n) ≤ h*(n), where h*(n) is
the true cost to reach the goal from n.
 An admissible heuristics never overestimates the cost to reach the goal
 Property: The tree-search version of A* is optimal if h(n) is admissible
Admissible Heuristics
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 14
 A heuristic is consistent if for every node n, every successor n’ of n generated
by any action a,
 If h is consistent, we have
 Property: The graph-search version of A* is optimal if h(n) is consistent.
Consistent Heuristics
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 15
h(n) ≤ c(n, a, n’) + h(n’)
f(n’) = g(n’) + h(n’)
= g(n) + c(n, a, n’) + h(n’)
f(n’) ≥ g(n) + h(n)
f(n’) ≥ f(n)
 The time complexity depends on heuristic function
 In worst case of an unbound search space: O(bd)
 The time complexity is polynomial,when
 Search space is tree
 There is a single goal state
 Heuristic function meets: | h(x) – h*(x)| = O(logh*(x)), where h* is the optimal heuristic, the
exact cost to get from x to the goal
Time Complexity
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 16
 A* algorithm
 f(n) = g(n) + h(n)
 Each step expand the node with lowest value of f(n)
 No other optimal algorithm is guaranteed to expand fewer nodes than A*
 Dijkstra’s algorithm
 f(n) = g(n), as a special case of A* where h(n) = 0
 Each step expand all closest unexamined nodes
 Can be implemented more efficiently without a h(x) value at each node
Compare to Dijkstra’s Algorithm
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 17
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 18
Conclusion
 Advantage:
 The A* algorithm is complete, optimal, and optimally efficient among all such algorithms.
 Disadvantage:
 A* is not practical for many large-scale problems, due to space time complexity is O(bd). That means A*
usually runs out of space long before it runs out of time.
 Applications
 Network routing
 Image processing
 A.I path finding
 Artificial Intelligence: A Modern Approach, third edition by Stuart Russell & Peter Norvig
 Principles of Artificial Intelligence by Nils J.Nilsson
 https://en.wikipedia.org/wiki/A*_search_algorithm
 https://www.ics.uci.edu/~welling/teaching/ICS175winter12/A-starSearch.ppt
 http://theory.stanford.edu/~amitp/GameProgramming/AStarComparison.html
 http://web.mit.edu/eranki/www/tutorials/search/
Reference
Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 19

More Related Content

What's hot

Lecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star searchLecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star searchHema Kashyap
 
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptProblem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptarunsingh660
 
I. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMI. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMvikas dhakane
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaEdureka!
 
Heuristic Searching: A* Search
Heuristic Searching: A* SearchHeuristic Searching: A* Search
Heuristic Searching: A* SearchIOSR Journals
 
Lecture 11 Informed Search
Lecture 11 Informed SearchLecture 11 Informed Search
Lecture 11 Informed SearchHema Kashyap
 
hospital management
hospital managementhospital management
hospital managementguestbcbbb5c
 
Solving problems by searching Informed (heuristics) Search
Solving problems by searching Informed (heuristics) SearchSolving problems by searching Informed (heuristics) Search
Solving problems by searching Informed (heuristics) Searchmatele41
 
09 heuristic search
09 heuristic search09 heuristic search
09 heuristic searchTianlu Wang
 
Informed search (heuristics)
Informed search (heuristics)Informed search (heuristics)
Informed search (heuristics)Bablu Shofi
 
Lecture 08 uninformed search techniques
Lecture 08 uninformed search techniquesLecture 08 uninformed search techniques
Lecture 08 uninformed search techniquesHema Kashyap
 
Jarrar: Informed Search
Jarrar: Informed Search  Jarrar: Informed Search
Jarrar: Informed Search Mustafa Jarrar
 
Pathfinding - Part 1: Α* heuristic search
Pathfinding - Part 1: Α* heuristic searchPathfinding - Part 1: Α* heuristic search
Pathfinding - Part 1: Α* heuristic searchStavros Vassos
 
Lecture 12 Heuristic Searches
Lecture 12 Heuristic SearchesLecture 12 Heuristic Searches
Lecture 12 Heuristic SearchesHema Kashyap
 
Example of iterative deepening search & bidirectional search
Example of iterative deepening search & bidirectional searchExample of iterative deepening search & bidirectional search
Example of iterative deepening search & bidirectional searchAbhijeet Agarwal
 

What's hot (20)

AI Lesson 05
AI Lesson 05AI Lesson 05
AI Lesson 05
 
A star algorithms
A star algorithmsA star algorithms
A star algorithms
 
Lecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star searchLecture 21 problem reduction search ao star search
Lecture 21 problem reduction search ao star search
 
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.pptProblem reduction AND OR GRAPH & AO* algorithm.ppt
Problem reduction AND OR GRAPH & AO* algorithm.ppt
 
Heuristic search
Heuristic searchHeuristic search
Heuristic search
 
I. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMI. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHM
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
 
Game Paper
Game PaperGame Paper
Game Paper
 
And or graph problem reduction using predicate logic
And or graph problem reduction using predicate logicAnd or graph problem reduction using predicate logic
And or graph problem reduction using predicate logic
 
Heuristic Searching: A* Search
Heuristic Searching: A* SearchHeuristic Searching: A* Search
Heuristic Searching: A* Search
 
Lecture 11 Informed Search
Lecture 11 Informed SearchLecture 11 Informed Search
Lecture 11 Informed Search
 
hospital management
hospital managementhospital management
hospital management
 
Solving problems by searching Informed (heuristics) Search
Solving problems by searching Informed (heuristics) SearchSolving problems by searching Informed (heuristics) Search
Solving problems by searching Informed (heuristics) Search
 
09 heuristic search
09 heuristic search09 heuristic search
09 heuristic search
 
Informed search (heuristics)
Informed search (heuristics)Informed search (heuristics)
Informed search (heuristics)
 
Lecture 08 uninformed search techniques
Lecture 08 uninformed search techniquesLecture 08 uninformed search techniques
Lecture 08 uninformed search techniques
 
Jarrar: Informed Search
Jarrar: Informed Search  Jarrar: Informed Search
Jarrar: Informed Search
 
Pathfinding - Part 1: Α* heuristic search
Pathfinding - Part 1: Α* heuristic searchPathfinding - Part 1: Α* heuristic search
Pathfinding - Part 1: Α* heuristic search
 
Lecture 12 Heuristic Searches
Lecture 12 Heuristic SearchesLecture 12 Heuristic Searches
Lecture 12 Heuristic Searches
 
Example of iterative deepening search & bidirectional search
Example of iterative deepening search & bidirectional searchExample of iterative deepening search & bidirectional search
Example of iterative deepening search & bidirectional search
 

Similar to AstarAlgorithm_v5_TeamFlash

Jarrar.lecture notes.aai.2011s.ch4.informedsearch
Jarrar.lecture notes.aai.2011s.ch4.informedsearchJarrar.lecture notes.aai.2011s.ch4.informedsearch
Jarrar.lecture notes.aai.2011s.ch4.informedsearchPalGov
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsSigSegVSquad
 
Unit 3 Informed Search Strategies.pptx
Unit  3 Informed Search Strategies.pptxUnit  3 Informed Search Strategies.pptx
Unit 3 Informed Search Strategies.pptxDrYogeshDeshmukh1
 
4 informed-search
4 informed-search4 informed-search
4 informed-searchMhd Sb
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treeoneous
 
module4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdfmodule4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdfShiwani Gupta
 
Algorithm Design and Complexity - Course 7
Algorithm Design and Complexity - Course 7Algorithm Design and Complexity - Course 7
Algorithm Design and Complexity - Course 7Traian Rebedea
 
Informed Search.pptx
Informed Search.pptxInformed Search.pptx
Informed Search.pptxMohanKumarP34
 
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and SparkCrystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and SparkJivan Nepali
 
Astar.ppt hjguyjgukyjgoyjgugukgulgoyulgyilglyi
Astar.ppt hjguyjgukyjgoyjgugukgulgoyulgyilglyiAstar.ppt hjguyjgukyjgoyjgugukgulgoyulgyilglyi
Astar.ppt hjguyjgukyjgoyjgugukgulgoyulgyilglyikamaleshs183
 
talk at Virginia Bioinformatics Institute, December 5, 2013
talk at Virginia Bioinformatics Institute, December 5, 2013talk at Virginia Bioinformatics Institute, December 5, 2013
talk at Virginia Bioinformatics Institute, December 5, 2013ericupnorth
 
ClosestPairClosestPairClosestPairClosestPair
ClosestPairClosestPairClosestPairClosestPairClosestPairClosestPairClosestPairClosestPair
ClosestPairClosestPairClosestPairClosestPairShanmuganathan C
 
An improved spfa algorithm for single source shortest path problem using forw...
An improved spfa algorithm for single source shortest path problem using forw...An improved spfa algorithm for single source shortest path problem using forw...
An improved spfa algorithm for single source shortest path problem using forw...IJMIT JOURNAL
 
An improved spfa algorithm for single source shortest path problem using forw...
An improved spfa algorithm for single source shortest path problem using forw...An improved spfa algorithm for single source shortest path problem using forw...
An improved spfa algorithm for single source shortest path problem using forw...IJMIT JOURNAL
 

Similar to AstarAlgorithm_v5_TeamFlash (20)

Jarrar.lecture notes.aai.2011s.ch4.informedsearch
Jarrar.lecture notes.aai.2011s.ch4.informedsearchJarrar.lecture notes.aai.2011s.ch4.informedsearch
Jarrar.lecture notes.aai.2011s.ch4.informedsearch
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
 
Unit 3 Informed Search Strategies.pptx
Unit  3 Informed Search Strategies.pptxUnit  3 Informed Search Strategies.pptx
Unit 3 Informed Search Strategies.pptx
 
Final slide (bsc csit) chapter 5
Final slide (bsc csit) chapter 5Final slide (bsc csit) chapter 5
Final slide (bsc csit) chapter 5
 
4 informed-search
4 informed-search4 informed-search
4 informed-search
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
 
module4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdfmodule4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdf
 
Dstar Lite
Dstar LiteDstar Lite
Dstar Lite
 
Algorithm Design and Complexity - Course 7
Algorithm Design and Complexity - Course 7Algorithm Design and Complexity - Course 7
Algorithm Design and Complexity - Course 7
 
Informed Search.pptx
Informed Search.pptxInformed Search.pptx
Informed Search.pptx
 
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and SparkCrystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
Crystal Ball Event Prediction and Log Analysis with Hadoop MapReduce and Spark
 
A* Algorithm
A* AlgorithmA* Algorithm
A* Algorithm
 
Unit ii-ppt
Unit ii-pptUnit ii-ppt
Unit ii-ppt
 
Astar.ppt hjguyjgukyjgoyjgugukgulgoyulgyilglyi
Astar.ppt hjguyjgukyjgoyjgugukgulgoyulgyilglyiAstar.ppt hjguyjgukyjgoyjgugukgulgoyulgyilglyi
Astar.ppt hjguyjgukyjgoyjgugukgulgoyulgyilglyi
 
Graph
GraphGraph
Graph
 
A Star Search
A Star SearchA Star Search
A Star Search
 
talk at Virginia Bioinformatics Institute, December 5, 2013
talk at Virginia Bioinformatics Institute, December 5, 2013talk at Virginia Bioinformatics Institute, December 5, 2013
talk at Virginia Bioinformatics Institute, December 5, 2013
 
ClosestPairClosestPairClosestPairClosestPair
ClosestPairClosestPairClosestPairClosestPairClosestPairClosestPairClosestPairClosestPair
ClosestPairClosestPairClosestPairClosestPair
 
An improved spfa algorithm for single source shortest path problem using forw...
An improved spfa algorithm for single source shortest path problem using forw...An improved spfa algorithm for single source shortest path problem using forw...
An improved spfa algorithm for single source shortest path problem using forw...
 
An improved spfa algorithm for single source shortest path problem using forw...
An improved spfa algorithm for single source shortest path problem using forw...An improved spfa algorithm for single source shortest path problem using forw...
An improved spfa algorithm for single source shortest path problem using forw...
 

AstarAlgorithm_v5_TeamFlash

  • 1. CSCI 6212 Presented by Team Flash Member: Shuqing Zhang Yang Cao Tong Qiao A* Algorithm Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 1
  • 2.  A* is one of the many search algorithm that take an input, evaluates a number of possible paths and returns a solution.  A* combines feartures of uniform-cost search and pure heuristic search to effectively compute optimal solutions  A* evaluates nodes by combining g(n) and h(n) f(n) = g(n) + h(n)  f(n) is called evaluation function.  A* is both complete and optimal. Introduction Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 2
  • 3.  f(n) = g(n) + h(n)  f(n) is the estimated total cost of the cheapest solution through n  g(n) gives the path cost from the start node to node n  h(n) named as heuristic function is the estimated cost of the cheapest path from n to the goal node. Evaluation Function Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 3
  • 4. Algorithm Process Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 4  Given: A graph of nodes, is start, is goal  Aim: To find out the path from to with the minimum cost  Procedure 1. Create a search graph G, consisting solely of the start node s. Put s on a list called OPEN. 2. Create a list called CLOSED that is initially empty. 3. LOOP: if OPEN is empty, exit with failure 4. Select the first node on OPEN, remove it from OPEN and put it into CLOSED. Call this node n. 5. If n is a goal node, exit successfully with the solution obtained by tracing a path along the pointers from n to s in G. 6. Expand node n, generating the set M of its successors and install them as successors of n in G. 7. Establish a pointer to n from those members of M that were not already in G(i.e not already on either OPEN or CLOSED). Add these members of M to OPEN. For each member of M that was already on OPEN or CLOSED, decide whether or not to redircet its pointer to n. For each member of M already on CLOSED, decide for each its descendents in G whether or not to redirect its pointer. 8. Recorder the list OPEN, eitheraccording to some scheme or some heuristic merit 9. Goto LOOP sn gn sn gn
  • 5. Find the shortest path from Arad to Bucharest Example Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 5
  • 6. Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 6 OS { } CS { (Arad, 0, 366) } OS { (Arad, 0, 366) } CS { } OpenSet { (CityName, g(n), f(n)),… } CloseSet { }
  • 7. Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 7 OS {(Sibiu, 140, 253), (Timisoara,118, 329), (Zerind, 75, 374)} CS {(Arad, 0, 366)} OS { (Timisoara,118, 329), (Zerind, 75, 374)} CS {(Arad, 0, 366), (Sibiu, 140, 253) }
  • 8. Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 8 OS {(Timisoara,118, 329), (Zerind, 75, 374), (Fagaras, 239, 176), (Oradea, 291, 380), (Rimnicu Vikea, 220, 193)} CS {(Arad, 0, 366), (Sibiu, 140, 253) } OS {(Timisoara,118, 329), (Zerind, 75, 374), (Arad, 280, 366), (Fagaras, 239, 176), (Oradea, 291, 380) } CS { (Arad, 0, 366), (Sibiu, 140, 253), (Rimnicu Vikea, 220, 193) }
  • 9. Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 9 OS {(Timisoara,118, 329), (Zerind, 75, 374), (Fagaras, 239, 176), (Oradea, 291, 380), (Craiova, 366, 160), (Pitesti, 317, 100)} CS {(Arad, 0, 366), (Sibiu, 140, 253), (Rimnicu Vikea, 220, 193)} OS {(Timisoara,118, 329), (Zerind, 75, 374), (Oradea, 291, 380), (Craiova, 366, 160), (Pitesti, 317, 100)} CS { (Arad, 0, 366), (Sibiu, 140, 253), (Rimnicu Vikea, 220, 193), (Fagaras, 239, 176)}
  • 10. Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 10 OS {(Timisoara,118, 329), (Zerind, 75, 374), (Oradea, 291, 380), (Craiova, 366, 160), (Pitesti, 317, 100), (Bucharest, 450, 0)} CS { (Arad, 0, 366), (Sibiu, 140, 253), (Rimnicu Vikea, 220, 193), (Fagaras, 239, 176)} OS {(Timisoara,118, 329), (Zerind, 75, 374), (Oradea, 291, 380), (Craiova, 366, 160), (Bucharest, 450, 0)} CS { (Arad, 0, 366), (Sibiu, 140, 253), (Rimnicu Vikea, 220, 193), (Fagaras, 239, 176), (Pitesti, 317, 100) }
  • 11. Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 11 OS {(Timisoara,118, 329), (Zerind, 75, 374), (Oradea, 291, 380), (Craiova, 366, 160), (Bucharest, 450, 0), (Bucharest, 418, 0), (Craiova, 455, 160)} CS { (Arad, 0, 366), (Sibiu, 140, 253), (Rimnicu Vikea, 220, 193), (Fagaras, 239,176), (Pitesti, 317, 100) } OS {(Timisoara,118, 329), (Zerind, 75, 374), (Oradea, 291, 380), (Craiova, 366, 160), (Bucharest, 450, 0), (Bucharest, 418, 0), (Craiova, 455, 160)} CS { (Arad, 0, 366), (Sibiu, 140, 253), (Rimnicu Vikea, 220, 193), (Fagaras, 239,176), (Pitesti, 317, 100), (Bucharest, 418, 0) } Construct the path: Set pointer from each node to its predecessor. Construct the path start from the goal, then reverse it. The path: Arad->Sibiu->Rimnicu Vikea->Pitesti->Bucharest
  • 12. Pseudocode Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 12 1: initialize the open list 2: initialize the closed list 3: put the starting node on the open list (leave its f at zero) - 4: while the open list is not empty 5: find the node with the least f on the open list, call it “q” 6: pop q off the open list 7: generate q’s successors and set their parents to q 8: for each successor 9: if successor is the goal, stop the search 10: successor.g = q.g + distance between successor and q 11: successor.h = distance from goal to successor 12: successor.f = successor.g + successor.h - 13: if a same node is in the open list which has a lower f than successor, skip this successor 14: if a same node is in the closed list which has a lower f than successor, skip this successor 15: otherwise, add the node to the open list 16: end 17: push q on the closed list 18: end
  • 13.  Admissibility  Consistency Conditions for Optimality Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 13
  • 14.  A heuristic h(n) is admissible if for every node n, h(n) ≤ h*(n), where h*(n) is the true cost to reach the goal from n.  An admissible heuristics never overestimates the cost to reach the goal  Property: The tree-search version of A* is optimal if h(n) is admissible Admissible Heuristics Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 14
  • 15.  A heuristic is consistent if for every node n, every successor n’ of n generated by any action a,  If h is consistent, we have  Property: The graph-search version of A* is optimal if h(n) is consistent. Consistent Heuristics Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 15 h(n) ≤ c(n, a, n’) + h(n’) f(n’) = g(n’) + h(n’) = g(n) + c(n, a, n’) + h(n’) f(n’) ≥ g(n) + h(n) f(n’) ≥ f(n)
  • 16.  The time complexity depends on heuristic function  In worst case of an unbound search space: O(bd)  The time complexity is polynomial,when  Search space is tree  There is a single goal state  Heuristic function meets: | h(x) – h*(x)| = O(logh*(x)), where h* is the optimal heuristic, the exact cost to get from x to the goal Time Complexity Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 16
  • 17.  A* algorithm  f(n) = g(n) + h(n)  Each step expand the node with lowest value of f(n)  No other optimal algorithm is guaranteed to expand fewer nodes than A*  Dijkstra’s algorithm  f(n) = g(n), as a special case of A* where h(n) = 0  Each step expand all closest unexamined nodes  Can be implemented more efficiently without a h(x) value at each node Compare to Dijkstra’s Algorithm Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 17
  • 18. Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 18 Conclusion  Advantage:  The A* algorithm is complete, optimal, and optimally efficient among all such algorithms.  Disadvantage:  A* is not practical for many large-scale problems, due to space time complexity is O(bd). That means A* usually runs out of space long before it runs out of time.  Applications  Network routing  Image processing  A.I path finding
  • 19.  Artificial Intelligence: A Modern Approach, third edition by Stuart Russell & Peter Norvig  Principles of Artificial Intelligence by Nils J.Nilsson  https://en.wikipedia.org/wiki/A*_search_algorithm  https://www.ics.uci.edu/~welling/teaching/ICS175winter12/A-starSearch.ppt  http://theory.stanford.edu/~amitp/GameProgramming/AStarComparison.html  http://web.mit.edu/eranki/www/tutorials/search/ Reference Shuqing Zhang/Yang Cao/Tong Qiao CSCI 6121/Arora/2015 FALL 19