Blind Search Russell and Norvig Chapter 3 Sections
Blind Search Russell and Norvig: Chapter 3, Sections 3. 4 – 3. 6
Simple Agent Algorithm Problem-Solving-Agent 1. initial-state sense/read state 2. goal select/read goal formulation and test: a function for goal testing 3. successor select/read action models successor function to calculate next states 4. problem (initial-state, goal, successor) 5. solution search(problem) 6. perform(solution) Blind Search 3
Search of State Space search tree Blind Search 4
Basic Search Concepts Search tree Search node Node expansion Search strategy: At each stage it determines which node to expand Blind Search 5
Search Nodes States 8 2 3 4 7 5 1 6 8 2 7 3 4 5 1 The search tree may be infinite even when the state space is finite 6 8 2 8 4 2 8 2 7 3 4 7 6 5 1 6 3 4 7 3 5 1 6 5 Blind Search 1 6
Node Data Structure STATE PARENT ACTION COST If a state is too large, it may DEPTH be preferable to only represent the initial state and (re-)generate the other states when needed Blind Search 7
Fringe Set of search nodes that have not been expanded yet Implemented as a queue FRINGE n n INSERT(node, FRINGE) REMOVE(FRINGE) The ordering of the nodes in FRINGE defines the search strategy Blind Search 8
Search Algorithm 1. If GOAL? (initial-state) then return initial-state 2. INSERT(initial-node, FRINGE) 3. Repeat: If FRINGE is empty then return failure n REMOVE(FRINGE) s STATE(n) For every state s’ in SUCCESSORS(s) § Create a node n’ as a successor of n § If GOAL? (s’) then return path or goal state § INSERT(n’, FRINGE) Blind Search 9
Performance Measures Completeness Is the algorithm guaranteed to find a solution when there is one? Probabilistic completeness: If there is a solution, the probability that the algorithms finds one goes to 1 “quickly” with the running time Blind Search 10
Performance Measures Completeness Is the algorithm guaranteed to find a solution when there is one? Optimality Is this solution optimal? Time complexity How long does it take? Space complexity How much memory does it require? Blind Search 11
Important Parameters Maximum number of successors of any state branching factor b of the search tree Minimal length of a path in the state space between the initial and a goal state depth d of the shallowest goal node in the search tree Blind Search 12
Blind vs. Heuristic Strategies Blind (or un-informed) strategies do not exploit any of the information contained in a state Heuristic (or informed) strategies exploits such information to assess that one node is “more promising” than another Blind Search 13
Example: 8 -puzzle 8 2 3 4 7 5 1 6 1 2 4 5 7 8 STATE N 1 For a heuristic blind strategy, strategy N 1 and N 2 are counting thejust number two nodes of (at some depth misplaced tiles, in. N 2 the is more search tree) promising than N 1 3 STATE 6 N 2 Blind Search 1 2 3 4 5 6 7 8 Goal state 14
Important Remark Some problems formulated as search problems are NP-hard problems (e. g. , (n 2 -1)-puzzle We cannot expect to solve such a problem in less than exponential time in the worst-case But we can nevertheless strive to solve as many instances of the problem as possible Blind Search 15
Blind Strategies Breadth-first n Bidirectional Step cost = 1 Depth-first n n Depth-limited Iterative deepening Uniform-Cost Step cost = c(action) >0 Blind Search 16
Breadth-First Strategy New nodes are inserted at the end of FRINGE 1 2 4 FRINGE = (1) 3 5 6 7 Blind Search 17
Breadth-First Strategy New nodes are inserted at the end of FRINGE 1 2 4 FRINGE = (2, 3) 3 5 6 7 Blind Search 18
Breadth-First Strategy New nodes are inserted at the end of FRINGE 1 2 4 FRINGE = (3, 4, 5) 3 5 6 7 Blind Search 19
Breadth-First Strategy New nodes are inserted at the end of FRINGE 1 2 4 FRINGE = (4, 5, 6, 7) 3 5 6 7 Blind Search 20
Evaluation b: branching factor d: depth of shallowest goal node Complete Optimal if step cost is 1 Number of nodes generated: 1 + b 2 + … + bd = (bd+1 -1)/(b-1) = O(bd) Time and space complexity is O(bd) Blind Search 21
Big O Notation g(n) is in O(f(n)) if there exist two positive constants a and N such that: for all n > N, g(n) a f(n) Blind Search 22
Time and Memory Requirements d 2 4 6 8 10 12 14 #Nodes 111 11, 111 ~106 ~108 ~1010 ~1012 ~1014 Time. 01 msec 100 sec 2. 8 hours 11. 6 days 3. 2 years Memory 11 Kbytes 1 Mbyte 100 Mb 10 Gbytes 1 Tbyte 100 Tbytes 10, 000 Tb Assumptions: b = 10; 1, 000 nodes/sec; 100 bytes/node Blind Search 23
Time and Memory Requirements d 2 4 6 8 10 12 14 #Nodes 111 11, 111 ~106 ~108 ~1010 ~1012 ~1014 Time. 01 msec 100 sec 2. 8 hours 11. 6 days 3. 2 years Memory 11 Kbytes 1 Mbyte 100 Mb 10 Gbytes 1 Tbyte 100 Tbytes 10, 000 Tb Assumptions: b = 10; 1, 000 nodes/sec; 100 bytes/node Blind Search 24
Bidirectional Strategy 2 fringe queues: FRINGE 1 and FRINGE 2 Time and space complexity = O(bd/2) << O(bd) Blind Search 25
Depth-First Strategy New nodes are inserted at the front of FRINGE 1 2 4 FRINGE = (1) 3 5 Blind Search 26
Depth-First Strategy New nodes are inserted at the front of FRINGE 1 2 4 FRINGE = (2, 3) 3 5 Blind Search 27
Depth-First Strategy New nodes are inserted at the front of FRINGE 1 2 4 FRINGE = (4, 5, 3) 3 5 Blind Search 28
Depth-First Strategy New nodes are inserted at the front of FRINGE 1 2 4 3 5 Blind Search 29
Depth-First Strategy New nodes are inserted at the front of FRINGE 1 2 4 3 5 Blind Search 30
Depth-First Strategy New nodes are inserted at the front of FRINGE 1 2 4 3 5 Blind Search 31
Depth-First Strategy New nodes are inserted at the front of FRINGE 1 2 4 3 5 Blind Search 32
Depth-First Strategy New nodes are inserted at the front of FRINGE 1 2 4 3 5 Blind Search 33
Depth-First Strategy New nodes are inserted at the front of FRINGE 1 2 4 3 5 Blind Search 34
Depth-First Strategy New nodes are inserted at the front of FRINGE 1 2 4 3 5 Blind Search 35
Depth-First Strategy New nodes are inserted at the front of FRINGE 1 2 4 3 5 Blind Search 36
Evaluation b: branching factor d: depth of shallowest goal node m: maximal depth of a leaf node Complete only for finite search tree Not optimal Number of nodes generated: 1 + b 2 + … + bm = O(bm) Time complexity is O(bm) Space complexity is O(bm) or O(m) Blind Search 37
Depth-Limited Strategy Depth-first with depth cutoff k (maximal depth below which nodes are not expanded) Three possible outcomes: n n n Solution Failure (no solution) Cutoff (no solution within cutoff) Blind Search 38
Iterative Deepening Strategy Repeat for k = 0, 1, 2, …: Perform depth-first with depth cutoff k Complete Optimal if step cost =1 Time complexity is: (d+1)(1) + db + (d-1)b 2 + … + (1) bd = O(bd) Space complexity is: O(bd) or O(d) Blind Search 39
Calculation db + (d-1)b 2 + … + (1) bd = bd + 2 bd-1 + 3 bd-2 +… + db = bd(1 + 2 b-1 + 3 b-2 + … + db-d) bd( i=1, …, ib(1 -i)) = bd (b/(b-1))2 Blind Search 40
Comparison of Strategies Breadth-first is complete and optimal, but has high space complexity Depth-first is space efficient, but neither complete nor optimal Iterative deepening is asymptotically optimal Blind Search 41
Repeated States No Few search tree is finite 8 -queens Many 1 2 3 search tree is infinite 4 5 7 8 6 assembly planning Blind Search 8 -puzzle and robot navigation 42
Avoiding Repeated States Requires comparing state descriptions Breadth-first strategy: n n Keep track of all generated states If the state of a new node already exists, then discard the node w The cost to find the repeated state (space and time) Blind Search 43
Avoiding Repeated States Depth-first strategy: n Solution 1: w Keep track of all states associated with nodes in current path w If the state of a new node already exists, then discard the node Avoids loops n Solution 2: w Keep track of all states generated so far w If the state of a new node has already been generated, then discard the node Space complexity of breadth-first Blind Search 44
Detecting Identical States Use explicit representation of state space Use hash-code or similar representation Blind Search 45
Revisiting Complexity Assume a state space of finite size s Let r be the maximal number of states that can be attained in one step from any state In the worst-case r = s-1 Assume breadth-first search with no repeated states Time complexity is O(rs). In the worst case it is O(s 2) Blind Search 46
Example s = nx x ny r = 4 or 8 Time complexity is O(s) Blind Search 47
Uniform-Cost Strategy • Each step has some cost > 0. • The cost of the path to each fringe node N is g(N) = costs of all steps. • The goal is to generate a solution path of minimal cost. • The queue FRINGE is sorted in increasing cost. S A S 1 5 B 5 15 C 10 G A 5 G 1 11 Blind Search B G 0 5 C 15 10 48
Modified Search Algorithm 1. INSERT(initial-node, FRINGE) 2. Repeat: If FRINGE is empty then return failure n REMOVE(FRINGE) s STATE(n) If GOAL? (s) then return path or goal state For every state s’ in SUCCESSORS(s) § Create a node n’ as a successor of n § INSERT(n’, FRINGE) Blind Search 49
Exercises Adapt uniform-cost search to avoid repeated states while still finding the optimal solution Uniform-cost looks like breadth-first (it is exactly breadth first if the step cost is constant). Adapt iterative deepening in a similar way to handle variable step costs Blind Search 50
Summary Search tree state space Search strategies: breadth-first, depthfirst, and variants Evaluation of strategies: completeness, optimality, time and space complexity Avoiding repeated states Optimal search with variable step costs Blind Search 51
- Slides: 51