State Space Search - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

State Space Search

Description:

If dead end, backtrack until you reach the most recent node ... List of nodes whose descendents have not been generated and searched. DE. List of dead end nodes ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 18
Provided by: paulde8
Category:

less

Transcript and Presenter's Notes

Title: State Space Search


1
State Space Search
2
Backtracking
  • Suppose
  • We are searching depth-first
  • No further progress is possible (i.e., we can
    only generate nodes weve already generated),
    then backtrack.

3
The algorithm First Pass
  • Pursue path until goal is reached or dead end
  • If goal, quit and return the path
  • If dead end, backtrack until you reach the most
    recent node whose children have not been fully
    examined

4
BT maintains Three Lists and A State
  • SL
  • List of nodes in current path being tried. If
    goal is found, SL contains the path
  • NSL
  • List of nodes whose descendents have not been
    generated and searched
  • DE
  • List of dead end nodes
  • All lists are treated as stacks
  • CS
  • Current state of the search

5
The Algorithm
6
State Space
a
d
b
c
h
j
a
F
i
g
A as a child of C is intentional
7
Trace
  • Goal J, Start A
  • NSL SL CS DE
  • A A A
  • BCDA BA B
  • FBCDA FBA F
  • GFBCDA GFBA G
  • FBCDA FBA F FG
  • BCDA BA B BFG
  • CDA A C
  • CA C
  • DA DA D
  • JDA JDA J(GOAL)

8
Depth-First A Simplification of BT
  • Eliminate saved path
  • 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

9
  • 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)

10
State Space
a
d
b
c
h
j
a
E
i
g
A as a child of C is intentional
11
  • Goal J
  • Start A
  • Open CS Closed
  • A
  • A A
  • BCD
  • CD B
  • BA
  • ECD
  • CD E BA
  • EBA
  • GCD
  • CD G
  • GEBA
  • D C
  • D
  • D
  • JH
  • H J(return true)

12
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

13
Trace
  • If you trace this, youll notice that the
    algorithm examines each node at each level before
    descending to another level
  • You will also notice that open contains
  • Unopened children of current state
  • Unopened states at current level

14
Both Algorithms
  • Open forms frontier of search
  • 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.

15
  • Breadth-First
  • Finds shortest solution
  • If branching factor is high, could require a lot
    of storage
  • Depth-First
  • If 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

16
8 PuzzleDF (p. 105)
17
8 Puzzle-BF (p. 103)
Write a Comment
User Comments (0)
About PowerShow.com