Search in AI:
Problem Solving by Search
Systematic Exploration of
Alternatives
Example Problems
States
:
•
Dirt and
hoover
locations
•
Integer location of tile
Actions
:
•
Left, right, suck, noop
•
Move blank left, right, up,
down
Goal Test
:
•
No dirt
•
Goal state as given
Path Cost
:
•
1 per action, 0 for noop
•
1 per move
Represent and Search
•
Characterise abstract representations of well
defined problems and their solutions
–
state space, initial and goal states;
–
traverse statespace, successor function
–
goal test
–
path cost
•
Examples
–
8puzzle, 8queens, route
finding,
•
travelling salesman, websearch, p2p file
search
Search Strategies
Blind
(independent of the domain):
depthfirst, breadthfirst, iterativedeepening
Heuristic
(utilises domainspecific features):
bestfirst, A*
Local
(if only finding goal state matters):
hillclimbing, simulated annealing, genetic
algorithm
Tree Search Algorithms
•
Node expansion a key idea
–
for exploration of state
space
How do you search for a file in your directory structure?
Tree Search Example:
From
Arad
to Bucharest
Macros: from State to Node
•
Node
Makenode(State)
•
List
Insert(Node)  called
fringe
or
open
(graph)
•
List may be LIFO, FIFO,
unordered,
organised
by
some other criterion
Fringe? Later
“
Open
”
BreadthFirst
Search
•
Expand shallowest unexpanded node
•
Implementation: fringe as FIFO queue
DepthFirst Search
•
Expand deepest unexpanded node
•
Implementation: fringe as LIFO queue
Features for Evaluation of Strategies
i
.
Completeness
:
Does the method always find a solution?
(Is there a path from initial state to goal state?)
ii
.
Optimality
:
Does the strategy find the optimal solution?
(Does this path have lowest cost among other such paths?)
iii
.
Time Complexity
:
How long does it take?
(The number of nodes expanded.)
iv
.
Space Complexity
:
How much memory does it require?
(The number of search nodes it keeps track of.)
•
In CS, complexities measured in terms of graph (explicit representation); in AI
the graph is represented implicitly.
•
Complexity expressed in terms of
 b, the
branching factor
(
maximum number of successors of any node )
 d, the
depth
of the
shallowest goal
node
 m, the
maximum path length
in the state space
Evaluation of Breadthfirst search
•
Assume the branching factor is uniform
–
b
•
Completeness
–
if shallowest goal state is at finite depth d, and
b is finite, BFS will find the goal
•
Optimality

s
hallowest goal node is not necessarily optimal; it is
optimal if
path cost is nondecreasing function of node depth
•
Complexity
In BFS, every node generated is held in memory
–
it
is either a search node or an ancestor of one.
If goal is at level d,
the
best
case scenario is
the goal
is
first node at level d; no more
nodes need to be expanded;
hence (b+b
2
+b
3
+∙ ∙ ∙+
b
d
) nodes in memory
the
worst
case: if the goal is the last one at level d; number of nodes
in memory is (b+b
2
+b
3
+∙ ∙ ∙+
b
d
+1
ʵ
b) = O(
b
d
+1
)
Evaluation of DepthFirst Search
•
Not optimal
: expands deepest node
first, can get stuck exploring long
(infinite) paths
•
Space:
Modest memory requirements
bm
+ 1 =
O(
bm
)
–
stores single path
from root to leaf node, plus unexpanded
nodes along the way. Once node
expanded and descendants explored,
delete from memory.
•
Time
:
b
m
; bad if d << m, but if solutions
are dense, better than BFS
•
Variant of DFS
–
backtracking search:
only one of b successors expanded at a
time, O(m) instead of O(
bm
)
Making use of depthfirst
’
s memory efficiency
Iterative deepening search:
the depthlimited subroutine
Illustrating Iterative Deepening Search
Illustrating Iterative Deepening Search
Illustrating Iterative Deepening Search
Illustrating Iterative Deepening Search
Properties of IDS
•
Appears wasteful, revisiting same states over and over; but most states
in a
large tree are in the bottom level, so revisiting upper levels is not as wasteful as
it seems:
•
level d nodes are expanded once: # of nodes = (1)
b
d
,
level d
1 nodes expanded twice: # of nodes = (2)b
d
, etc.
Adding up: total # nodes generated is
(1)
b
d
+ (2)b
d
+ ∙ ∙ ∙ + (d
1)b
2
+ (d)b = O(
b
d
)
•
Time complexity
:
IDS generates O(
b
d
) nodes,
and so is
faster
than BFS which generates O(
b
d
+1
)
Properties of IDS
Algorithm
:
1: Do depthfirst search until fixed depth D
2: If no goal node found, D++ and go to 1
•
Completeness:
yes
•
Time complexity
: IDS generates O(
b
d
) nodes
•
Space
: O(
bd
)
•
Optimal
if step cost = 1.
•
Preferred uninformed search method if search space is large and
the depth of solution unknown
Open and Closed Nodes
•
Fringe to be
explored is
called
OPEN
•
Instead of
discarding
nodes from
the queue,
place them
in a
CLOSED or
VISITED list
•
Graph
search
BFS on a graph: Goal
“
g
”
DFS on a graph: Goal
“
g
”
Enter the password to open this PDF file:
File name:

File size:

Title:

Author:

Subject:

Keywords:

Creation Date:

Modification Date:

Creator:

PDF Producer:

PDF Version:

Page Count:

Preparing document for printing…
0%
Comments 0
Log in to post a comment