informed search
play

Informed search Lirong Xia Spring, 2017 Last class Search - PowerPoint PPT Presentation

Informed search Lirong Xia Spring, 2017 Last class Search problems state space graph: modeling the problem search tree: scratch paper for solving the problem Uninformed search BFS DFS 2 Todays schedule More on


  1. Informed search Lirong Xia Spring, 2017

  2. Last class Ø Search problems • state space graph: modeling the problem • search tree: scratch paper for solving the problem Ø Uninformed search • BFS • DFS 2

  3. Today’s schedule Ø More on uninformed search • iterative deepening: BFS + DFS • uniform cost search (UCS) • searching backwards from the goal Ø Informed search • best first (greedy) • A* 3

  4. Combining good properties of BFS and DFS Ø Iterative deepening DFS: • Call limited depth DFS with depth 0; • If unsuccessful, call with depth 1; • If unsuccessful, call with depth 2; • Etc. Ø Complete, finds shallowest solution Ø Flexible time-space tradeoff Ø May seem wasteful timewise because replicating effort

  5. Costs on Actions e 5 1 S a d G 1 3 2 1 1 c b 5

  6. Uniform-Cost Search (UCS) Ø BFS: finds shallowest solution Ø Uniform-cost search (UCS): work on the lowest- cost node first • so that all states in the fringe have more or less the same cost, therefore “uniform cost” Ø If it finds a solution, it will be an optimal one Ø Will often pursue lots of short steps first Ø Project 1 Q3

  7. Example e 5 1 S a d G 1 3 2 1 1 c b 7

  8. Priority Queue Refresher •A priority queue is a data structure in which you can insert and retrieve (key, value) pairs with the following operations: pq.push(key, value) Inserts (key, value) into the queue. returns the key with the lowest value, and pq.pop() removes it from the queue • Insertions aren’t constant time, usually • We’ll need priority queues for cost-sensitive search methods 8

  9. Uniform-Cost Search Ø The good: UCS is • complete: if a solution exists, one will be found • optimal: always find the solution with the lowest cost • really? § yes, for cases where all costs are positive Ø The bad • explores every direction • no information about the goal location 9

  10. Searching backwards from the goal Ø Switch the role of START and GOAL Ø Reverse the edges in the problem graph Ø Need to be able to compute predecessors instead of successors … g f b c d e Start GOAL

  11. Informed search Ø So far, have assumed that no non-goal state looks better than another Ø Unrealistic • Even without knowing the road structure, some locations seem closer to the goal than others Ø Makes sense to expand seemingly closer nodes first .

  12. Search Heuristics •Any estimate of how close a state is to a goal •Designed for a particular search problem •Examples: Manhattan distance, Euclidean distance 12

  13. Best First (Greedy) •Strategy: expand a node that you think is closest to a goal state • Heuristic function: estimate of distance to nearest goal for each state • h(n) •Often easy to compute •A common case: •Best-first takes you straight to the (wrong) goal •Worst-case: like a badly-guided DFS 13

  14. Example 1 g a f 1 1 1 2 e Start GOAL 1 1 b 1 d 1 c h(b) = h(c) = h(d) = h(e) = h(f) = h(g) =1 14 h(a) = 2

  15. A more problematic example a h(b) = h(c) = h(d)=1 h(a) = 2 2 1 h(G) = 0 Start GOAL 1 1 d b 1 1 c Ø Greedy will choose SbcdG Ø Optimal: SaG Ø Should we stop when the fringe is empty? 15

  16. A* 16

  17. A*: Combining UCS and Greedy g n ( ) •Uniform-cost orders by path cost h n •Greedy orders by goal proximity, or forward cost ( ) f n g n h n ( ) ( ) ( ) •A* search orders by the sum: = + 17

  18. When should A* terminate? •Should we stop when we add a goal to the fringe? a 2 2 h( a )=2 h( S )=7 c S h( G )=0 h( b )=0 2 3 b •No: only stop when a goal pops from the fringe 18

  19. A* Ø Never expand a node whose state has been visited Ø Fringe can be maintained as a priority queue Ø Maintain a set of visited states Ø fringe := {node corresponding to initial state} Ø loop: • if fringe empty, declare failure • choose and remove the top node v from fringe • check if v’s state s is a goal state; if so, declare success • if v’s state has been visited before, skip • if not, expand v, insert resulting nodes with f(v)=g(v)+h(v) to fringe 19

  20. Is A* Optimal? a h( a )=6 3 1 G S 5 h( G )=0 h( S )=7 Ø Problem: overestimate the true cost to a goal • so that the algorithm terminates without expanding the actual optimal path 20

  21. Admissible Heuristics • A heuristic h is admissible if: h ( n ) ≤ h* ( n ) where h* ( n ) is the true cost to a nearest goal • Examples: • h ( n )=0 • h ( n ) = h* ( n ) • another example • Coming up with admissible heuristics is most challenging part in using A* in practice 21

  22. Is Admissibility enough? a 1 5 h( a )=0 h( c )=0 5 c G S h( b )=6 h( S )=7 h( G )=0 1 1 b Ø Problem: the first time to visit a state may not via the shortest path to it 22

  23. Consistency of Heuristics • Stronger than admissibility • Definition: a 1 • cost( a to c ) + h ( c ) ≥ h ( a ) c • Triangle inequality • Be careful about the edges h ( a )=4 • Consequences: h ( c )=1 The f value along a path never • G decreases • so that the first time to visit a state corresponds to the 23 shortest path

  24. Violation of consistency a 1 5 h( a )=0 h( c )=0 5 c G S h( b )=6 h( S )=7 h( G )=0 1 1 b Ø b à c 24

  25. Correctness of A* Ø A* finds the optimal solution for consistent heuristics • but not for the admissible heuristics (as in the previous example) Ø However, if we do not maintain a set of “visited” states, then admissible heuristics are good enough 25

  26. Proof Ø Proof by contradiction: suppose the output is incorrect. • Let the optimal path be S à a à … à G § for simplicity, assume it is unique • When G pops from the fringe, f(G) is no more than f(v) for all v in the fringe. • Let v denote the state along the optimal path in the fringe § guaranteed by consistency • Contradiction § addimisbility: f(G) <= f(v) <= g(v) + h*(v) 26

  27. Creating Admissible Heuristics • Most of the work in solving hard search problems optimally is in coming up with admissible heuristics 12.4 27

  28. Example: 8 Puzzle Start State Goal State • What are the states? • How many states? • What are the actions? • What should the costs be? 28

  29. 8 Puzzle I • Heuristic: Number of tiles misplaced • Why is it admissible? Start State Goal State Average nodes expanded when • h(START) = 8 optimal path has length…. …4 steps …8 steps …12 steps UCS 112 6,300 3,600,000 TILES 13 39 227 29

  30. 8 Puzzle II • What if we had an easier 8-puzzle where any tile could slide any direction at any time ignoring other tiles? Start State Goal State • Total Manhattan Average nodes expanded when optimal path has length…. distance …4 steps …8 steps …12 steps • Why admissible? TILES 13 39 227 Manhattan 12 25 73 • h(START) = 3+2+…+18 30

  31. 8 Puzzle III Start State Goal State • Total Manhattan distance for grid 1 and 2 • Why admissible? • Is it consistent? • h(START) = 3+1=4 31

  32. 8 Puzzle IV • How about using the actual cost as a heuristic? • Would it be admissible? • Would we save on nodes expanded? • What’s wrong with it? • With A*: a trade-off between quality of estimate and work per node! 32

  33. Other A* Applications • Pathing / routing problems • Resource planning problems • Robot motion planning • Language analysis • Machine translation • Speech recognition • Voting! 33

  34. Features of A* Ø A* uses both backward costs and (estimates of) forward costs Ø A* computes an optimal solution with consistent heuristics Ø Heuristic design is key 34

  35. Search algorithms Ø Maintain a fringe and a set of visited states Ø fringe := {node corresponding to initial state} Ø loop: • if fringe empty, declare failure • choose and remove the top node v from fringe • check if v’s state s is a goal state; if so, declare success • if v’s state has been visited before, skip • if not, expand v, insert resulting nodes to fringe Ø Data structure for fringe • FIFO: BFS • Stack: DFS • Priority Queue: UCS (value = h(n)) and A* (value = g(n)+h(n)) 35

  36. Take-home message Ø No information • BFS, DFS, UCS, iterative deepening, backward search Ø With some information • Design heuristics h(n) • A*, make sure that h is consistent • Never use Greedy! 36

  37. Project 1 Ø You can start to work on UCS and A* parts Ø Start early! Ø Ask questions on Piazza 37

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend