Download presentation

Presentation is loading. Please wait.

Published byAlyssa Childress Modified over 2 years ago

1
Greedy best-first search Use the heuristic function to rank the nodes Search strategy –Expand node with lowest h-value Greedily trying to find the least-cost solution

2
Greedy Best-First Search Path search(start, operators, is_goal) { fringe = makeList(start); while (state=fringe.popFirst()) { if (is_goal(state)) return pathTo(state); S = successors(state, operators); fringe = insert (S, fringe); } return NULL; } Order the nodes in increasing values of h(N)

3
Procedure Best-First Search begin open [Start] closed [ ] while open [ ] do begin remove leftmost state from open and call it X if X is a goal then return the path from Start to X else begin generate children of X for each child of X do begin switch case the child is not on open or closed assign the child a heuristic value and add the child to open case the child is already on open if the child was reached by a shorter path then give the state on open the shorter path case the child is already on closed if the child was reached by a shorter path then remove the state from closed and add the child to open put X on closed re-order states on open by heuristic merit (best leftmost) end return failure end

4
Example A-5 B-4 C-4 D-6 E-5 F-5 G-4 H-3 1.Open = [A5];closed = [] 2.Evl A5; open=[B4,C4,D6];closed=[A5] 3.Eval B4;open=[C4,E5,F5,D6]; closed=[B4,A5] 4.Eval C4; open = [H3,G4,E5,F5,D6] ; closed=[C4,B4,A5]

5
A search algorithm is admissible if it is guaranteed to find a minimal path to a solution whenever such a path exist. f*(n) = g*(n) + h*(n) g*(n) is the cost of the shortest path from the start node to n. h*(n) is the actual cost of the shortest path n to the goal. Then f*(n) is the actual cost of the optimal path from a start node to a goal node that passes through node n.

6
f* does not exist. Algorithm A –Use f(n) = g(n) + h(n) and best-first-search algorithm Algorithm A* –If h(n) h*(n) in the algorithm A then it is called Algorithm A* Theorem: All A* algorithms are admissible

7
Implementing Heuristic Evaluations For 8-puzzle, two heuristics are … –Counts the tiles out of place in each state when it is compared with the goal. –Sum all the distances by which the tiles are out of place, one for each square a tile must be moved to reach its position in the goal state. 283 14 75 6 left 283 14 75 6 283 14 756 283 14 75 6

8
Example h 1(S)=7 h 2(S)=4+0+3+3+1+0+2+1=14

9
Comparison of Heuristics applied to states in the 8-puzzle 283 14 75 6 283 14 756 283 14 75 6 5 6 3 4 56 Tile out of place Sum of distances out of place h1 h2

10
Admissible Heuristic

11
A* Search Greedy best-first search is too greedy –It does not take into account the cost of the path so far! Define –f(n)=g(n)+h(n) –g(n) is the cost of the path to node n –h(n) is the heuristic estimate of the cost of reaching the goal from node n A* search –Expand node in fringe (queue) with lowest f value

12
283 14 75 6 left 283 14 75 6 283 14 756 283 14 75 6 64 6 283 14 756 283 14 756 2 8 3 14 756 5 5 6 2 83 14 756 283 147 56 2 8 3 14 756 5 1 2 3 4 5

14
A* Another Example

15
A*

21
A* Search Complete : Yes Time Complexity: Exponential - Depends on h(n) Space Complexity: Exponential - Keeps all nodes in memory Optimal: Yes. If h(n) is an admissible heuristic Optimally efficient

22
How fast is A*? A* is the fastest search algorithm. That is, for any given heuristic, no algorithm can expand fewer nodes than A*. How fast is it? Depends of the quality of the heuristic. [(relative error in h) x (length of solution)] Exponential time complexity in worst case. A good heuristic will help a lot here O(bm) if the heuristic is perfect If the heuristic is useless (ie h(n) is hardcoded to equal 0 ), the algorithm degenerates to uniform cost. If the heuristic is perfect, there is no real search, we just march down the tree to the goal. Generally we are somewhere in between the two situations above. The time taken depends on the quality of the heuristic.

23
Dominance Given two admissible heuristics h1(n) and h2(n), which is better? If h2(n) h1(n) for all n, then –h2 is said to dominate h1 –h2 is better for search For our 8-puzzle heuristic, does h2 dominate h1?

24
A*’s space complexity Main problem: space complexity A* has worst case O(b d ) space complexity, but an iterative deepening version is possible ( IDA* )

Similar presentations

OK

Heuristic Search Russell and Norvig: Chapter 4 Slides adapted from:

Heuristic Search Russell and Norvig: Chapter 4 Slides adapted from:

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google