State Space Search 2 Chapter 3
description
Transcript of State Space Search 2 Chapter 3
![Page 1: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/1.jpg)
State Space Search 2Chapter 3
Three Algorithms
![Page 2: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/2.jpg)
Backtracking
SupposeWe are searching depth-firstNo further progress is possible (i.e., we
can only generate nodes we’ve already generated)
Backtrack
![Page 3: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/3.jpg)
The algorithm: First Pass
1. Pursue path until goal is reached or dead end
2. If goal, quit and return the path3. If dead end, backtrack until you reach
the most recent node whose children have not been fully examined
![Page 4: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/4.jpg)
BT maintains Three Lists and A State
SL◦List of nodes in current path being tried. If goal
is found, SL contains the pathNSL
◦List of nodes whose descendents have not been generated and searched
DE◦List of dead end nodes
All lists are treated as stacksCS
◦Current state of the search
![Page 5: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/5.jpg)
The Algorithm
![Page 6: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/6.jpg)
State Space
a
b
e
g
c
a
d
h
i
j
A as a child of C is intentional
![Page 7: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/7.jpg)
Trace
At Home Exercise:
Trace with Goal j, Start AShow SL, NSL, DE, CS at each step of the algorithm
![Page 8: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/8.jpg)
Depth-First: A Simplification of BT
Eliminate saved path (SL)Results in Depth-First search
◦Goes as deeply as possible◦Is not guaranteed to find a shortest path◦Maintains two lists
Open List◦Contains states generated◦Children have not been examined (like NSL)◦Open is implemented as a stack
Closed List◦Contains states already examined◦Union of SL and DE
![Page 9: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/9.jpg)
bool Depth-First(Start){
open = [Start];closed = [];while (!isEmpty.open()){
CS = open.pop();if (CS == goal)
return true; else { generate children of CS; closed.push(CS); eliminate children from CS that are on open or closed;
while (CS has more children) open.push(child of CS);
} } return false;}
![Page 10: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/10.jpg)
Trace
At Home Exercise:
Trace graph on slide 6 with Goal j, Start aShow Open, Close, CS at each step of the algorithm
![Page 11: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/11.jpg)
Breadth-First Search: DF but with a Queue
bool Breadth-First(Start){
open = [Start];closed = [];while (!isEmpty.open()){
CS = open.dequeue();if (CS == goal)
return true; else { generate children of CS; closed.enqueue(CS); eliminate children from CS that are on open or closed;
while (CS has more children) open.enqueue(child of CS);
} } return false;}
![Page 12: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/12.jpg)
Trace
At Home Exercise:
Trace graph on slide 6 with Goal j, Start aShow Open, Close, CS at each step of the algorithm
![Page 13: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/13.jpg)
Both Algorithms
1. Open forms frontier of search2. Path can be easily reconstructed
Each node is an ordered pair (x,y) X is the node name Y is the parent When goal is found, search closed for
parent, the parent of the parent, etc., until start is reached.
![Page 14: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/14.jpg)
Breadth-FirstFinds shortest solutionIf branching factor is high, could require a
lot of storageDepth-FirstIf it is known that the solution path is long,
DF will not waste time searching shallow states
DF can get lost going too deep and miss a shallow solution
DF and BF follow for the 8-puzzle
![Page 15: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/15.jpg)
8 Puzzle—DF (p. 105)
Depth First Search of 8-Puzzle (p. 105)Depth Bound = 5
![Page 16: State Space Search 2 Chapter 3](https://reader036.fdocuments.in/reader036/viewer/2022081503/5681458c550346895db27727/html5/thumbnails/16.jpg)