basic problem solving
play

Basic Problem-Solving 2.2 Best-first heuristic search Strategies - PDF document

Chapter 2 2. Basic Problem-Solving Strategies 2.1 Basic search techniques Basic Problem-Solving 2.2 Best-first heuristic search Strategies 2.3 Problem decompositon and AND/OR graphs 2.4 Searching


  1. Chapter 2 2. Basic Problem-Solving Strategies 2.1 Basic search techniques Basic Problem-Solving 2.2 Best-first heuristic search Strategies 2.3 Problem decompositon and —————————————— AND/OR graphs 2.4 Searching in Games Christian Jacob 2.5 Efficient Searching (SMA*) jacob@cpsc.ucalgary.ca Department of Computer Science University of Calgary 2.1 Basic Search Techniques 2.1 Basic Search Techniques 2.1.1 Introductory Concepts and 2.1.1 Introductory Concepts and Examples Examples 2.1.2 Depth-First or Backtracking 2.1.2 Depth-First or Backtracking Search Search 2.1.3 Iterative Deepening Search 2.1.3 Iterative Deepening Search 2.1.4 Breadth-First Search 2.1.4 Breadth-First Search What should we know for a preliminary Analyzing and Exploring Problem Spaces analysis of a search problem? Problem space: What are the givens? Do we have all of them? a complete set of possible states, generated by – Are the givens specific to a particular situation? exploring all possible – Can we generalize? steps , or moves, which – Is there a notation that represents the may or may not lead givens and other states succinctly? from a given state or start state to a goal state.

  2. Fox-Goose-Corn Problem What should we know for a preliminary analysis of a search problem? (cont.) State Space Graph What is the goal? P F G C / – Is there a single goal, or are there several? F G C / P G C / P F F C / P G F G / P C – If there is a single goal, can it be split into pieces? P G C / F P F C / G P F G / C – If there are several goals or subgoals, are they independent or are they connected? C / P F G G / P F C F / P G C – Are there any constraints on developing a solution? P C / F G P G / F C P F / G C / P F G C Components of a State Space Graph Blocks Rearrangement Problem – Start: description with which to label the start node – Operators: functions that transform from one state to another, within the constraints of the search problem – Goal condition: state description(s) that correspond(s) to goal state(s) [Bratko, 2001] Towers of Hanoi Blocks Rearrangement Problem: State Space Graph C B A [Bratko, 2001]

  3. Towers of Hanoi: Eight-Queens Problem Problem Decomposition 8 queens on a chess board A B C A B C No queen attacked move tower with n-1 disks States: any arrangement of e 0 to 8 queens on the v o m k s board. i d A B C A B C move tower Operators: add a queen to with n-1 disks any square 96 solutions, 12 (wt. symmetry) Travelling Salesperson Problem Eight Puzzle Problem Goal Start Start 1: 4 steps Start 2: 5 steps Start 3: 18 steps www.cacr.caltech.edu/~manu/tsp.html Eight Puzzle Problem Chess Anatoly Karpow and Gary Kasparow, 1986 [Kurzweil, 1990] [Newborn, 1997] [Bratko, 2001]

  4. Rubik’s Cube 2.1 Basic Search Techniques 2.1.1 Introductory Concepts and Examples 2.1.2 Depth-First or Backtracking Search 2.1.3 Iterative Deepening Search 2.1.4 Breadth-First Search 2.1.2 Depth-First Search Depth-First Search: Eight-Puzzle [Bratko, 2001] [Nilsson, 1998] Depth First Search Evaluation Depth-First Search in Cyclic Graphs Good: Bad: - If you have deep search Since we don’t expand all nodes at a level, space trees (or infinite – which complexity is modest. is quite possible), DFS may end up running off to infinity and may not be For branching factor b and able to recover. depth m , we require bm number of nodes to be stored in - Thus DFS is neither memory. optimal nor complete However, the worst case is still O( b m ). Add cycle-detection! [Bratko, 2001]

  5. Depth-Limited Search: Depth-Limited Search Space and Time Complexity Modifies DFS to avoid its pitfalls. Say that within a given area, we had to find the shortest path to visit 10 cities. If we start at one of the cities, then there are at DLS is O( b l ) in time, where l is the limit least 9 other cities to visit. So 9 is the limit we impose. we impose. Since we impose a limit, there are little changes Space complexity is bl. from DFS — with the exception that we will avoid searching an infinite path. DLS is complete if the limit we impose is Not optimal greater than or equal to the depth of our solution. 2.1 Basic Search Techniques 2.1.3 Iterative Deepening Search 2.1.1 Introductory Concepts and Examples 2.1.2 Depth-First or Backtracking Search 2.1.3 Iterative Deepening Search 2.1.4 Breadth-First Search Depth bound = 1 2 3 4 [Nilsson, 1998] Iterative Deepening Search: 2.1 Basic Search Techniques Evaluation 2.1.1 Introductory Concepts and We look at the bottom most nodes once. Examples We look at the level above that twice, 2.1.2 Depth-First or Backtracking … and the level above that thrice, … and so on, up to the root. Search 2.1.3 Iterative Deepening Search Therefore, we get: 2.1.4 Breadth-First Search ( d +1)1 + ( d ) b + ( d -1) b 2 + … + 3 b d-2 + 2 b d-1 + 1 b d Like DFS, IDS is still O( b d ) while space complexity is bd .

  6. 2.1.4 Breadth-First Search Breadth-First Search: Eight-Puzzle [Nilsson, 1998] [Bratko, 2001] Breadth First Search Bi-directional Search Time and space complexity : Simultaneously search from the start node and - If we look at how BFS expands from the root we from the goal(s). see that it first expands on a fixed number of nodes, say b. The search ends somewhere in the middle - On the second level we expand b 2 nodes. when the two touch each other. - On the third level we expand b 3 nodes. Time & space complexity: O(2b d/2 ) = O(b d/2 ) - And so on, until it reaches b d for some depth d . 1 + b + b 2 + b 3 + . . . . + b d , which is O( b d ) It is complete and optimal. Since all leaf nodes need to be stored in memory, space complexity is the same as time complexity. Bi-directional Search Uniform Cost Search Uniform Cost search is a modification of Problems: BFS. • Do we know where the goal is? BFS returns a solution, but it may not be • What if there is more than one possible goal state? optimal. • We may be able to apply a multiple state search but this sounds a lot easier said than done. Example: How many checkmate UCS takes into account the cost of states are there in chess? moving from one node to the next. • We may utilize many different methods of search, but which one is the choice?

  7. Categories of Search Uniform Cost Search (Greedy Search): Example Uninformed Search Informed Search We can distinguish the We know something goal state(s) from the non- about the nature of our goal state. path that might increase the effectiveness of our The path and cost to find search. the goal is unknown. Generally superior to Also known as blind uninformed search. search. [Russel & Norvig, 1995] Uninformed Search Strategies 2. Basic Problem-Solving Strategies 2.1 Basic search techniques We covered these uninformed strategies : 2.2 Best-first heuristic search 2.3 Problem decompositon and • Depth First Search • Depth Limited Search AND/OR graphs • Iterative Deepening Search 2.4 Searching in Games • Breadth First Search 2.5 Efficient Searching (SMA*) • Bidirectional Search • Uniform Cost Search 2.2.1 Greedy Search 2.2 Best-First Heuristic Search with Straight-Line Distance Heuristic h SLD (n) = straight-line distance between n and the goal location 2.2.1 Greedy Search B State h(n) 2.2.2 Best-First Heuristic Search (A*) 75 A 366 B 374 – Routing Problem 140 A C 329 99 E D 244 F – Best-First Search for Scheduling E 253 118 F 178 211 80 G 193 C G H 98 I 0 111 97 D H I 101

  8. A A E B C h=253 E C B h=253 329 374 B State h(n) 75 F G A 366 A B 374 140 A C 329 99 E h = 366 h = 178 h = 193 D 244 F E 253 118 F 178 80 211 G 193 C Total distance G H 98 = 253 + 178 I 0 111 A E F 97 D H I = 431 101 h = 253 h = 178 A Optimality? h = 253 E C B Cost(A — E — F — I )= 431 vs. A F G h =366 h=178 h=193 Cost(A — E — G — H — I) = 418 B 75 E I h = 253 h = 0 State h(n) 140 A 99 Total distance E A 366 F B 374 =253 + 178 + 0 118 C 329 211 80 D 244 =431 C A E F I G E 253 F 178 111 h = 253 h = 178 h = 0 97 G 193 D H I 101 H 98 I 0 Completeness 2.2.2 Best-First Search Heuristics Greedy Search is incomplete Worst-case time complexity g O(b m ) h Straight-line h (n) distance A 6 A B 5 C 7 B Starting node D 0 f(n) = g(n) + h(n) D C Target node heuristic estimator [Bratko, 2001]

Recommend


More recommend