Search-Problem Solving Part2
Search-Problem Solving Part2
successor function
Search tree
Initial state
The root of the search tree is a search node
Expanding
applying successor function to the current state
thereby generating a new set of states
leaf nodes
the states having no successors
Fringe/Frontier : Set of search nodes that have
not been expanded yet.
Refer to next figure
Tree search example
Tree search example
Search tree
The essence of searching
in case the first choice is not correct
choosing one option and keep others for later
inspection
Hence we have the search strategy
which determines the choice of which state to
expand
good choice fewer work faster
Important:
state space ≠ search tree
Search tree
State space
has unique states {A, B}
while a search tree may have cyclic paths:
A-B-A-B-A-B- …
A good search strategy should avoid
such paths
Search tree
A node is having five components:
STATE: which state it is in the state space
PARENT-NODE: from which node it is generated
to generate it
PATH-COST: the cost, g(n), from initial state to
initial state
Measuring problem-solving performance
The evaluation of a search strategy
Completeness:
isthe strategy guaranteed to find a solution when
there is one?
Optimality:
doesthe strategy find the highest-quality solution
when there are several different solutions?
Time complexity:
how long does it take to find a solution?
Space complexity:
how much memory is needed to perform the search?
Measuring problem-solving performance
In AI, complexity is expressed in
b, branching factor, maximum number of
successors of any node
d, the depth of the shallowest goal node.
Bidirectional search
Breadth-first search
The root node is expanded first (FIFO)
All the nodes generated by the root
node are then expanded
And then their successors and so on
Breadth-first search
S
A D
B D A E
C E E B B F
11
D F B F C E A C G
14 17 15 15 13
G C G F
19 19 17
G 25
Breadth-First Strategy
2 3 FRINGE = (1)
4 5 6 7
Breadth-First Strategy
2 3 FRINGE = (2, 3)
4 5 6 7
Breadth-First Strategy
2 3 FRINGE = (3, 4, 5)
4 5 6 7
Breadth-First Strategy
2 3 FRINGE = (4, 5, 6, 7)
4 5 6 7
Breadth-first search (Analysis)
Breadth-first search
Complete – find the solution eventually
Optimal, if step cost is 1
The disadvantage
if the branching factor of a node is large,
let
ε is possitive constant (every action cost)
Backtracking search
only one successor is generated on expansion
rather than all successors
fewer memory
Depth-first search
Expand deepest unexpanded node
fringe = LIFO queue, i.e., put successors at front
Implementation:
Depth-first search
Expand deepest unexpanded node
fringe = LIFO queue, i.e., put successors at front
Implementation:
Depth-first search
Expand deepest unexpanded node
fringe = LIFO queue, i.e., put successors at front
Implementation:
Depth-first search
Expand deepest unexpanded node
fringe = LIFO queue, i.e., put successors at front
Implementation:
Depth-first search
Expand deepest unexpanded node
fringe = LIFO queue, i.e., put successors at front
Implementation:
Depth-first search
Expand deepest unexpanded node
fringe = LIFO queue, i.e., put successors at front
Implementation:
Depth-first search
Expand deepest unexpanded node
fringe = LIFO queue, i.e., put successors at front
Implementation:
Depth-first search
Expand deepest unexpanded node
fringe = LIFO queue, i.e., put successors at front
Implementation:
Depth-first search
Expand deepest unexpanded node
fringe = LIFO queue, i.e., put successors at front
Implementation:
Depth-first search
Expand deepest unexpanded node
fringe = LIFO queue, i.e., put successors at front
Implementation:
Depth-first search
Expand deepest unexpanded node
fringe = LIFO queue, i.e., put successors at front
Implementation:
Depth-first search
Expand deepest unexpanded node
fringe = LIFO queue, i.e., put successors at front
Implementation:
Depth-first search
S
A D
B D A E
C E E B B F
11
D F B F C E A C G
14 17 15 15 13
G C G F
19 19 17 G 25
Depth-first search (Analysis)
Not complete
because a path may be infinite or looping
then the path will never fail and go back try
another option
Not optimal
it doesn't guarantee the best solution
It overcomes
the time and space complexities
Properties of depth-first search
Complete? No: fails in infinite-depth spaces, spaces
with loops
Modify to avoid repeated states along path
complete in finite spaces
Time? O(bm): terrible if m is much larger than d
but if solutions are dense, may be much faster than
breadth-first
Space? O(bm), i.e., linear space!
Optimal? No
Depth-Limited Strategy
Depth-first with depth cutoff k (maximal
depth below which nodes are not
expanded)
C E E B B F
11
D F B F C E A C G
14 17 15 15 13
G C G F
19 19 17
G 25
Iterative deepening search
No choosing of the best depth limit
It tries all possible depth limits:
first
0, then 1, 2, and so on
combines the benefits of depth-first and
breadth-first search
Iterative deepening search
Iterative deepening search
(Analysis)
optimal
complete
Time and space complexities
reasonable
B D A E
C E E B B F
11
D F B F C E A C G
14 17 15 15 13
G C G F
19 19 17
G 25
Comparing search strategies
Avoiding repeated states
for all search strategies
There is possibility of expanding states
that
have already been encountered and expanded
before, on some other path
may cause the path to be infinite loop forever
Algorithms that forget their history
are doomed to repeat it
Avoiding repeated states
Three ways to deal with this possibility
Do not return to the state it just came from
Refusegeneration of any successor same as its
parent state
Do not create paths with cycles
Refuse
generation of any successor same as its
ancestor states
Do not generate any generated state
Not
only its ancestor states, but also all other
expanded states have to be checked against
Avoiding repeated states
We then define a data structure
closed list:
a set storing every expanded node so far
If the current node matches a node on the