Post on 16-Dec-2015
Search strategiesSearch strategies
A search strategy is defined by picking the A search strategy is defined by picking the order of node order of node expansionexpansion
Strategies are evaluated along the following dimensions:Strategies are evaluated along the following dimensions:– completenesscompleteness: does it always find a solution if one exists?: does it always find a solution if one exists?– time complexitytime complexity: number of nodes generated/expanded: number of nodes generated/expanded– space complexityspace complexity: maximum number of nodes in memory: maximum number of nodes in memory– optimalityoptimality: does it always find a least-cost solution?: does it always find a least-cost solution?
Time and space complexity are measured in terms of Time and space complexity are measured in terms of – b:b: maximum branching factor of the search tree maximum branching factor of the search tree– d: d: depth of the least-cost solutiondepth of the least-cost solution– mm: maximum depth of the state space (may be ∞): maximum depth of the state space (may be ∞)
2
Uninformed search strategiesUninformed search strategies
UninformedUninformed search strategies use only the search strategies use only the information available in the problem definitioninformation available in the problem definition
Breadth-first searchBreadth-first search
Uniform-cost searchUniform-cost search
Depth-first searchDepth-first search
Depth-limited searchDepth-limited search
Iterative deepening searchIterative deepening search
3
Breadth-first searchBreadth-first search
Expand shallowest unexpanded nodeExpand shallowest unexpanded node
ImplementationImplementation::– fringefringe is a FIFO queue, i.e., new successors go is a FIFO queue, i.e., new successors go
at endat end
4
Breadth-first searchBreadth-first search
Expand shallowest unexpanded nodeExpand shallowest unexpanded node
ImplementationImplementation::– fringefringe is a FIFO queue, i.e., new successors go is a FIFO queue, i.e., new successors go
at endat end
5
Breadth-first searchBreadth-first search
Expand shallowest unexpanded nodeExpand shallowest unexpanded node
ImplementationImplementation::– fringefringe is a FIFO queue, i.e., new successors go is a FIFO queue, i.e., new successors go
at endat end
6
Breadth-first searchBreadth-first search
Expand shallowest unexpanded nodeExpand shallowest unexpanded node
ImplementationImplementation::– fringefringe is a FIFO queue, i.e., new successors go is a FIFO queue, i.e., new successors go
at endat end
7
Properties of breadth-first searchProperties of breadth-first search
Complete?Complete? Yes (if Yes (if bb is finite) is finite)
Time?Time? 1+b+b1+b+b22+b+b33+… ++… +bbdd + ( + (bbd+1d+1-b-b) = O(b) = O(bd+1d+1))
Space?Space? O(bO(bd+1d+1)) (keeps every node in memory) (keeps every node in memory)
Optimal?Optimal? Yes (if cost = 1 per step) Yes (if cost = 1 per step)
SpaceSpace is the bigger problem (more than time) is the bigger problem (more than time)
8
BFS; evaluationBFS; evaluation Two lessons:Two lessons:
– Memory requirements are a bigger problem than its execution time.Memory requirements are a bigger problem than its execution time.– Exponential complexity search problems cannot be solved by uninformed search Exponential complexity search problems cannot be solved by uninformed search
methods for any but the smallest instances.methods for any but the smallest instances.
Table is based on: b = 10; 10000/second; 1000 bytes/node Table is based on: b = 10; 10000/second; 1000 bytes/node
DEPTH2DEPTH2 NODESNODES TIMETIME MEMORYMEMORY
22 11001100 0.11 seconds0.11 seconds 1 megabyte1 megabyte
44 111100111100 11 seconds11 seconds 106 megabytes106 megabytes
66 101077 19 minutes19 minutes 10 gigabytes10 gigabytes
88 101099 31 hours31 hours 1 terabyte1 terabyte
1010 10101111 129 days129 days 101 terabytes101 terabytes
1212 10101313 35 years35 years 10 petabytes10 petabytes
1414 10101515 3523 years3523 years 1 exabyte1 exabyte
9
Uniform-cost searchUniform-cost search
Extension of BFS:Extension of BFS:– Expand node with Expand node with lowest path costlowest path cost
Implementation: Implementation: fringefringe = queue ordered by path cost. = queue ordered by path cost.
UCS is the same as BFS when all step-costs are equal.UCS is the same as BFS when all step-costs are equal.
10
Uniform-cost searchUniform-cost search
Completeness: Completeness: – YES, if step-cost > YES, if step-cost > (small positive constant) (small positive constant)
Time complexity:Time complexity:– Assume C* the cost of the optimal solution.Assume C* the cost of the optimal solution.
– Assume that every action costs at least Assume that every action costs at least – Worst-case: Worst-case:
Space complexity:Space complexity:– The same as time complexityThe same as time complexity
Optimality: Optimality: – nodes expanded in order of increasing path cost.nodes expanded in order of increasing path cost.– YES, if complete.YES, if complete.
)( /* CbO
11
Depth-first searchDepth-first search
Expand deepest unexpanded nodeExpand deepest unexpanded node ImplementationImplementation::
– fringe fringe = LIFO queue, i.e., put successors at front= LIFO queue, i.e., put successors at front
12
Depth-first searchDepth-first search
Expand deepest unexpanded nodeExpand deepest unexpanded node ImplementationImplementation::
– fringe fringe = LIFO queue, i.e., put successors at front= LIFO queue, i.e., put successors at front
13
Depth-first searchDepth-first search
Expand deepest unexpanded nodeExpand deepest unexpanded node ImplementationImplementation::
– fringe fringe = LIFO queue, i.e., put successors at front= LIFO queue, i.e., put successors at front
14
Depth-first searchDepth-first search
Expand deepest unexpanded nodeExpand deepest unexpanded node ImplementationImplementation::
– fringe fringe = LIFO queue, i.e., put successors at front= LIFO queue, i.e., put successors at front
15
Depth-first searchDepth-first search
Expand deepest unexpanded nodeExpand deepest unexpanded node ImplementationImplementation::
– fringe fringe = LIFO queue, i.e., put successors at front= LIFO queue, i.e., put successors at front
16
Depth-first searchDepth-first search
Expand deepest unexpanded nodeExpand deepest unexpanded node ImplementationImplementation::
– fringe fringe = LIFO queue, i.e., put successors at front= LIFO queue, i.e., put successors at front
17
Depth-first searchDepth-first search
Expand deepest unexpanded nodeExpand deepest unexpanded node ImplementationImplementation::
– fringe fringe = LIFO queue, i.e., put successors at front= LIFO queue, i.e., put successors at front
18
Depth-first searchDepth-first search
Expand deepest unexpanded nodeExpand deepest unexpanded node ImplementationImplementation::
– fringe fringe = LIFO queue, i.e., put successors at front= LIFO queue, i.e., put successors at front
19
Depth-first searchDepth-first search
Expand deepest unexpanded nodeExpand deepest unexpanded node ImplementationImplementation::
– fringe fringe = LIFO queue, i.e., put successors at front= LIFO queue, i.e., put successors at front
20
Depth-first searchDepth-first search
Expand deepest unexpanded nodeExpand deepest unexpanded node ImplementationImplementation::
– fringe fringe = LIFO queue, i.e., put successors at front= LIFO queue, i.e., put successors at front
21
Depth-first searchDepth-first search
Expand deepest unexpanded nodeExpand deepest unexpanded node ImplementationImplementation::
– fringe fringe = LIFO queue, i.e., put successors at front= LIFO queue, i.e., put successors at front
22
Depth-first searchDepth-first search
Expand deepest unexpanded nodeExpand deepest unexpanded node ImplementationImplementation::
– fringe fringe = LIFO queue, i.e., put successors at front= LIFO queue, i.e., put successors at front
23
Properties of depth-first searchProperties of depth-first search
Complete?Complete? No: fails in infinite-depth spaces, spaces No: fails in infinite-depth spaces, spaces with loopswith loops– Modify to avoid repeated states along pathModify to avoid repeated states along path
complete in finite spacescomplete in finite spaces
Time?Time? O(bO(bmm)): terrible if : terrible if mm is much larger than is much larger than dd– but if solutions are dense, may be much faster than but if solutions are dense, may be much faster than
breadth-firstbreadth-first
Space?Space? O(bm), O(bm), i.e., linear space!i.e., linear space! Optimal?Optimal? No No
–
24
Depth-limited search
= depth-first search with depth limit l,
i.e., nodes at depth l have no successors
Recursive implementation:
25
Is DFS with depth limit Is DFS with depth limit ll..– i.e. nodes at depth i.e. nodes at depth l l have no successors.have no successors.– Problem knowledge can be usedProblem knowledge can be used
Solves the infinite-path problem.Solves the infinite-path problem.
If If l < dl < d then incompleteness results. then incompleteness results.
If If l > dl > d then not optimal. then not optimal.
Time complexity:Time complexity:
Space complexity:Space complexity:
Depth-limited searchDepth-limited search
O(bl )
O(bl)26
Properties of iterative deepening searchProperties of iterative deepening search
Complete?Complete? Yes Yes
Time?Time? (d+1)b(d+1)b00 + d b + d b11 + (d-1)b + (d-1)b22 + … + b + … + bdd = O(b = O(bdd))
Space?Space? O(bd)O(bd)
Optimal?Optimal? Yes, if step cost = 1 Yes, if step cost = 1
29
ID search, evaluation
Completeness:– YES (no infinite paths)
Time complexity:– Algorithm seems costly due to repeated generation of certain states.– Node generation:
– level d: once– level d-1: 2– level d-2: 3– …– level 2: d-1– level 1: d
N(IDS) (d)b (d 1)b2 ... (1)bd
N(BFS) b b2 ... bd (bd 1 b)
O(bd )
N(IDS) 50 400 3000 20000100000 123450
N(BFS) 10 100 100010000100000 999990 1111100
Num. Comparison for b=10 and d=5 solution at far right
30
Repeated statesRepeated states
Failure to detect repeated states can turn a Failure to detect repeated states can turn a linear problem into an exponential one!linear problem into an exponential one!
32
Bidirectional search
Two simultaneous searches from start an goal.– Motivation:
Check whether the node belongs to the other fringe before expansion. Space complexity is the most significant weakness. Complete and optimal if both searches are BFS.
bd / 2 bd / 2 bd
34