3.0 State Space Representation of Problems
3.0 State Space Representation of Problems
0
of Problems
3.1 Graphs
3.2 Formulating Search Problems
3.3 The 8-Puzzle as an example
3.4 State Space Representation using graphs
3.5 Performing a State Space Search
3.6 Basic Depth First Search (DFS)
3.7 Basic Breadth First Search (DFS)
3.8 Best First Search (DFS)
3.1 Graphs
Definitions:
a graph consists of:
3
4
5
Figure 4.1:5 nodes, and 6
arcs graph.
a
b
c
d
e
a
b
c
d
e
The root
The root
b
h
In a graph:
1. An ordered sequence of nodes [ N1, N2, N3 ..,
Nn], where each Ni, Ni+1 in the sequence
represent an arc (Ni,Ni+1), is called a path of
length n-1.
2. If a path contains any node more than once it
said to contain a cycle or loop.
3. Two nodes in a graph are said to be
connected if there is a path that includes
them both.
4. On a path on a rooted graph, a node is said
to be the ancestor of all nodes positioned
after it ( to its right) as well as descendent of
all nodes before it ( to its left)
-For example, in figure 4.5, d is the ancestor of e,
while it is the descendent of a in the path [a, d, e].
5 4 .
1 2 3
6 1 8
8 . 4
7 3 2
7 6 5
State space search involves finding a path from the initial state
of a search problem to a goal state.
To do this,
1-build a search graph, starting from the initial state (or the
goal state)
2- expand a state by applying the search operators to that
state, generating ALL of its successor states.
These successors are in the next level down of the search graph
3-The order in which we choose states for expansion is
determined by the search strategy
Different strategies result in (sometimes massively) different
behaviour
KEY CONCEPT: We want to find the solution while realizing
in memory as few as possible of the nodes in the search space.
closed=[]
2-Open=[AC], closed=[S]
3-Open=[BC], closed=[AS]
4-Open=[DC], closed=[BAS]
A
5-Open=[GC], closed=[DBAS]
6-Open=[C],
closed=[GDBAS]
Report success
Path is SABDG
D
A
B
D
G
closed=[]
2-Open=[AC], closed=[S]
3-Open=[CB], closed=[AS]
4-Open=[BD], closed=[CAS]
A
5-Open=[D], closed=[CAS]
6-Open=[G],
closed=[DCAS]
7-Open=[],
closed=[GDCAS]
Report success
Path is SCDG
D
G
closed=[]
3
S
2-Open=[C7A8], closed=[S]
3-Open=[D3A8], closed=[CS]
4-Open=[G0B3A8], closed=[DCS]
A
5-Open=[B3A8], closed=[GDCS]
Report success
Path is SCDG
A
B
D
G