Download presentation

Presentation is loading. Please wait.

Published byTania Gray Modified over 2 years ago

1
State Space 3 Chapter 4 Heuristic Search

2
Three Algorithms Backtrack Depth First Breadth First All work if we have well-defined: Goal state Start state State transition rules But could take a long time

3
Heuristic An informed guess that guides search through a state space Can result in a suboptimal solution

4
Blocks World: A Stack of Blocks StartGoal AD BC CB DA Two rules: clear(X) on(X, table) clear(X) ^ clear(Y) on(X,Y) Generate part of the search space BF. We’ll find the answer, but it could take a long time.

5
Heuristic 1 1. For each block that is resting where it should, subtract 1 2. For each block that is not resting where it should, add 1

6
Hill Climbing 1. At every level, generate all children 2. Continue down path with lowest score Define three functions: f(n) = g(n) + h(n) Where: h(n) is the heuristic estimate for n--guides the search g(n) is path length from start to current node—ensures that we choose node closest to root when more than 1 have same h value

8
Problem: heuristic is local Given CandCB BDA A D At level n The f(n) of each structure is the same f(n) = g(n) = (1+1-1-1) = g(n) But which is actually better

9
Problem with local heuristics C B A D Must be entirely undone Goal Requires 6 moves CB DA Goal requires only two moves

10
Global Heuristic Takes the entire structure into account 1. Subtract 1 for each block that has correct support structure 2. Add 1 for each block in an incorrect support structure

11
Seems to Work Goal:D C B A C f(n) = g(n) + (3+2+1+0) =g(n) + 6 B A D CB f(n) = g(n) + (1 + 0 -1+ 0) = g(n) DA So the heuristic correctly chose the second structure

12
Best First The Road Not Taken Open contains current fringe of the search Open: priority queue ordered by f(n) Closed: queue of states already visited Nodes could contain backward pointers so that path back to root can be recovered

13
path best_first(Start) { open = [start], closed = []; while (!open.isEmpty()) { cs = open.serve(); if (cs == goal) return path; generate children of cs; for each child { case: { child is on open;//node has been reached by a shorter path if (g(child) < g(child) on open) g(child on open) = g(child); break; child is on closed; if (g(child < g(child on closed)) { //node has been reached by a shorter path and is more attractive remove state from closed; open.enqueue(child); } break; default: { f(child) = g(child) + h(child);//child has been examined yet open.enqueue(child); } closed.enqueue(cs);//all cs’ children have been examined. open.reorder();//reorder queue because case statement may have affected ordering } return([]); //failure }

15
Admissibility Admissible Search Algorithms ◦Find the optimal path to the goal if a path to the goal exists Breadth-First: Admissible Depth-First: Not admissible

16
Algorithm A Uses Best First f(n) = g(n) + h(n)

17
f* f*(n) = g*(n) + h*(n) Where g*(n) is the cost of the shortest path from start to n h*(n) is the cost of the shortest path from n to goal So, f*(n) is the actual cost of the optimal path Can we know f*(n)?

18
The Oracle Not without having exhaustively searched the graph Goal: Approximate f*(n)

19
Consider g*(n) g(n) – actual cost to n g*(n) – shortest path from start to n So g(n) >= g*(n) When g*(n) = g(n), the search has discovered the optimal path to n

20
Consider h*(n) Often we can know ◦If h(n) is bounded above by h*(n) ◦(This sometimes means finding a function h2(n) such that h(n) <= h2(n) <= h*(n)) Meaning: the optimal path is more expensive than the one suggested by the heuristic Turns out this is a good thing (within bounds)

21
An 8-puzzle Intuition 283 123 164 -> 8 4 7 5 765 Invent two heuristics: h1 and h2 h1(n): number of tiles not in goal position h1(n) = 5 (1,2,6,8,B) h2(n): number of moves required to move out-of-place tiles to goal T1 = 1, T2 = 1, T6 = 1, T8 = 2, TB = 1 h2(n) = 6 h1(n) <= h2(n) ?

22
h1(n) is bounded above by h*(n) h2(n) <= h*(n) Each out-of-place tile has to be moved a certain distance to reach goal h1(n) <= h2(n) h2(n) requires moving out-of-place tiles at least as far as h1(n) So, h1(n) <= h2(n) <=h*(n)

23
Leads to a Definition A* If algorithm A uses a heuristic that returns a value h(n) <= h*(n) for all n, then it is called A* What does this property mean?

24
It means that the heuristic estimate chosen never thinks a path is better than it is goal Suppose: h(rst) = 96 But we know it is really 1 (i.e. h*(rst) = 1) because we’re the oracle Suppose: h(lst) = 42 Left branch looks better than it really is This makes the left branch seem better than it actually is

25
Claim: All A* Algorithms are admissible Suppose: 1. h(n) = 0 and so <= h*(n) Search will be controlled by g(n) If g(n) = 0, search will be random: given enough time, we’ll find an optimal path to the goal If g(n) is the actual cost to n, f(n) becomes breadth-first because the sole reason for examining a node is its distance from start. We already know that this terminates in an optimal solution

26
2. h(n) = h*(n) Then the algorithm will go directly to the goal since h*(n) computes the shortest path to the goal Therefore, if our algorithm is between these two extremes, our search will always result in an optimal solution Call h(n) = 0, h’(n) So, for any h such that h’(n) <= h(n) <= h*(n) we will always find an optimal solution The closer our algorithm is to h’(n), the more extraneous nodes we’ll have to examine along the way

27
Informedness For any two A* heuristics, ha, hb If ha(n) <= hb(n), hb(n) is more informed.

28
Comparison Comparison of two solutions that discover the optimal path to the goal state: 1. BF: h(n) = 0 2. h(n) = number of tiles out of place The better informed solution examines less extraneous information on its path to the goal

Similar presentations

OK

CSE 390B: Graph Algorithms Based on CSE 373 slides by Jessica Miller, Ruth Anderson 1.

CSE 390B: Graph Algorithms Based on CSE 373 slides by Jessica Miller, Ruth Anderson 1.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on 5 electrical appliances Ppt on direct taxation in india Free download ppt on the road not taken Ppt on cross-site scripting attack Ppt on model view controller architecture Ppt on statistics and probability tutorial Ppt on campus recruitment system Ppt on next generation 2-stroke engine compression Project ppt on student information system Ppt on human resource recruitment