Download presentation
Presentation is loading. Please wait.
1
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Heuristic Search Notes for Ch.12 of Bratko and Ch.2 of Shoham For CSCE 580 Sp03 Marco Valtorta
2
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Generic Search Procedure procedure search(graph,startnode,goal) OPEN := [startnode]; CLOSED := [ ] found := false while OPEN is not empty and not found transfer a node N from OPEN to CLOSED if goal(N) then found := true else find all neighbors of N in the graph that are neither in OPEN nor in CLOSED and add them to OPEN if found then return N else fail
3
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Example Graph a i b c d e f l hj kg
4
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Depth-First Search The OPEN list is treated as a stack New paths are appended “on top” of the stack Complexity is quadratic in the length of solution path found, because of the membership test for OPEN and CLOSED: –each call to the test requires time proportional to the length of OPEN and CLOSED –the test is performed once per edge traversed, and in the worst case all edges will be traversed sect2_4.pl
5
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Complexity of DFS Complexity is quadratic in the length of solution path found, because of the membership test for OPEN and CLOSED: –each call to the test requires time proportional to the length of OPEN and CLOSED –the test is performed once per edge traversed, and in the worst case all edges will be traversed Version with side effects exploits the Prolog indexing mechanism to speed up tests
6
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Breadth-First Search sect2_5.pl In DFS, OPEN is treated as a stack: –append(NewPaths,MoreOPEN,NewOPEN) In BFS, OPEN is treated as a queue –append(MoreOPEN, NewPaths, NewOPEN) In the fast implementation, OPEN is implemented as a difference list
7
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Best-First Search BFS uses a heuristic function to estimate the promise of a node A* uses f = g + h as the heuristic h is admissible if is a lower bound (on h*). h is monotone (consistent) if h(n) <= h(m) + c(n,m) when n is a successor of m a_star in sect2_7.pl IDA* is an iterative deepening version of A*.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.