Download presentation

Presentation is loading. Please wait.

Published byJacqueline Dewberry Modified over 2 years ago

1
State Space 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)

5
All Three Algorithms will find a solution Partial Look At Search Space ABCDBCDA CBC CBC B A DAD B A DAD Etc.

6
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

7
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

9
Problem: heuristic is local Given CandCB BDA AD 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

10
The vertical structure must be undone entirely C B B A A A D C DCB ABCD BC D ACDB ADDCBA For a total of 6 moves

11
But CBCD DABC ADB A 2 moves

12
Task Design a global heuristic that 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

13
f(n) = g(n) + (3+2+1+0) =g(n) + 6 CB Agoal D DC BA CB f(n) = g(n) + (1 + 0 -1+ 0) = g(n) DA So the heuristic correctly chose the second structure

14
Leads to a New Algorithm: Best First The Road Not Taken The Road Not Taken Best first Keeps nodes on open in a priority queue ordered by h(n) so that if it goes down a bad path that at first looks good, it can retry a new path Contains algorithm for generating h(n) Nodes could contain backward pointers so that path back to root can be recovered

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

16
State Space of a Hypothetical Search Next Slide Goal: P States with attached evaluations are those generated by best-first States expanded by best-first are indicated in bold Just before evaluating O, closed contains HCBA Just before evaluating O, open contains OPGEFD

18
Admissibility A search algorithm is admissible if it finds the optimal path whenever one exists BF is admissible DF is not admissible Suppose on the previous slide Node S were replaced by a P The optimal path is ACHP But DF discovers ABEKP

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

20
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

21
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

22
Consider h*(n) We can’t know it unless exhaustive search is possible and we’ve already searched the state space But we can know sometimes if a given h-1(n) is bounded above by some h-2(n)

23
8-puzzle Example 283 123 164 -> 8 4 7 5 765 h-1(n) number of tiles not in goal position = 5 (1,2,6,8, B) H-2(n) number of moves required to move them to goal (T1 = 1, T2 = 1, T6 = 1, T8 = 2, TB = 1) = 6 So h-1(n) <= h-2(n)

24
h-2(n) cannot exceed h*(n) because each tile has to be moved a certain distance to reach goal no matter what. h-2(n) could equal h*(n) h-1(n) is certainly <= h-2(n) which requires moving each incorrect tile at least as far as h-1(n) So, h-1(n) <= h-2(n) <=h*(n)

25
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*

26
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 If g(n) is the actual cost to n, f(n) becomes BF because the sole reason for examining a node is its distance from start. We already know that this terminates in an optimal solution

27
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

28
Informedness For any two A* heuristics, h-a, h-b If h-a(n) <= h-b(n), h-b(n) is more informed.

29
Comparison h-a is BF h-b is the # of tiles out of place Since h-a is 0, h-b is better informed than h-a

30
P. 149 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

Presentation is loading. Please wait....

OK

Heuristic Search Ref: Chapter 4.

Heuristic Search Ref: Chapter 4.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on channels of distribution in france Ppt on national education day essay Ppt on property management system Viewer ppt online training Ppt on history of badminton Ppt on railway track laying Ppt on networking related topics about psychology Ppt on game theory wikipedia Ppt on steps in designing hrd system Ppt on nanocomposites