Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 4310 Lecture 4: Search 2 – Including A*. Book Winston Chapters 4,5,6.

Similar presentations


Presentation on theme: "CSCI 4310 Lecture 4: Search 2 – Including A*. Book Winston Chapters 4,5,6."— Presentation transcript:

1 CSCI 4310 Lecture 4: Search 2 – Including A*

2 Book Winston Chapters 4,5,6

3 Heuristically Informed Searches Explore the promising choices first Using external information saves work

4 Branch-and-Bound Searching for a path from S to G We know the path S-G has minimum distance 14. Stop expanding W S ACR VQFWRE 4 3 5 92 341 7

5 Branch and Bound Underestimate remaining distance at each step Book uses straight-line distance between cities as underestimate of highway distance Knowing this optimal solution enables bounded tree branches Heuristic: length total path = length traveled + estimate remaining distance

6 Redundancy Checks Requires storing partial paths Stop expansion of S-A-E S ACE VQFWRE 4 3 5 92 341 7

7 One caveat This works for episodic traversal If S-E-Q does not influence paths from Q to the goal ie. If there is a tripwire on link E-Q that blows the bridge from Q-R, it’s back to the drawing board

8 Branch & Bound + Redundancy S AD 34 Total path cost

9 Branch & Bound + Redundancy S AD DB 7 8 4 3

10 S AD DB 7 8 AE 4 3 9 6

11 S AD DB 7 8 AE 4 3 9 6 CEBF 12 11 10

12 A* Search Adding techniques A* includes a heuristic for remaining distance Measure of cost to reach the goal

13 A* Search A* algorithm maintains 2 lists OPEN = nodes that need to be expanded CLOSED = expanded nodes Initial Lists OPEN = {START NODE} CLOSED = { }

14 A* Search f (n) = g (n) + h (n) f(n): cost from n to goal g(n): cost to get to n h(n): estimate of least cost path from n to goal f(n) must be maintained by each node Using an estimate of remaining distance and dynamic programming

15 Search algorithm properties Complete: The algorithm is guaranteed to find a solution when there is one Optimal: The algorithm finds the path with the least cost

16 A* properties If h(n) never over-estimates the cost to reach the goal from the present position h(n) is an admissible heuristic Also sometimes called an optimistic heuristic If h(n) is admissible, A* is complete and optimal

17 A* Pathfinding Navigation Obstacle Avoidance More non-intuitive applications 8-puzzle

18 Heuristics for 8-puzzle h 1 : number of misplaced tiles Any tile out of place must be moved at least once h 2 : sum of the orthogonal distances of the tiles from goal position No tile can move diagonally city block or Manhattan distance “1” is 3 from its goal position 12 345 678 724 56 831

19 Heuristics for 8-puzzle h 1 : number of misplaced tiles h 2 : sum of the orthogonal distances of the tiles from goal position Are both heuristics admissible? Yes 12 345 678 724 56 831

20 A* search algorithm adapted from Bryan Stout, gamasutra priorityQueue Open, list Closed AStarSearch // s is the start node s.g = 0; s.h = GoalDistEstimate( s ); s.f = s.g + s.h; s.parent = null; push s on Open while Open is not empty { pop node n from Open // n has the lowest f if n is a goal node construct path and return success for each successor n' of n { // n' is a child of n in the tree newg = n.g + cost(n,n') if n' is in Open or Closed AND n'.g <= newg skip n'.parent = n; n'.g = newg; n'.h = GoalDistEstimate( n' ); n'.f = n'.g + n'.h if n' is in Closed remove it from Closed if n' is not yet in Open push n' on Open } push n onto Closed } return failure // if no path found

21 When path finding goes wrong

22 Example path finding with A* 1234567 81314 151617182021 222728 29303132333435 start goal

23 Example 1234567 81314 1516182021 222728 293031323334 S G 17 1816 1,4 = 51,6 = 7 Assumptions (simplifications): Costs 1 to move to any square No diagonal moves Heuristic is minimum number of orthogonal moves OPEN = 17 CLOSED = 

24 Example 1234567 81314 151617182021 222728 293031323334 S G 17 1816 1,4 = 51,6 = 7 17 2,5 = 7 We would not actually move here Remember, path from S to G is not returned until the termination of the algorithm Nodes already in open or closed list OPEN = 18,16 CLOSED = 17

25 Example 1234567 81314 151617182021 222728 293031323334 S G 17 1816 1,4 = 51,6 = 7 17 2,5 = 7 1517 2,7 = 9 Nodes already in open or closed list

26 Example 1234567 81314 151617182021 222728 293031323334 S G 17 1816 1,4 = 51,6 = 7 17 2,5 = 7 1517 2,7 = 9 82216 3,6 = 93,8 = 11 With multiple choices from 15, follow the path with the least f value (22). Recall f is the sum of cost and heuristic Nodes already in open or closed list

27 Example 1234567 81314 151617182021 222728 293031323334 S G 17 1816 1,4 = 51,6 = 7 17 2,5 = 7 1517 2,7 = 9 82216 3,6 = 93,8 = 11 1529 4,6 = 104,7 = 11 Nodes already in open or closed list

28 Example 1234567 81314 151617182021 222728 293031323334 SG 17 1816 1,4 = 5 Now a straight shot to the goal 1,6 = 7 17 2,5 = 7 1517 2,7 = 9 82216 3,6 = 93,8 = 11 1529 4,6 = 104,7 = 11 Nodes already in open or closed list

29 Game situations more complex

30 May have real-time constraints Estimate (heuristic) function will have more factors Uneven terrain Coming under enemy guns or entering dangerous areas Weather Shortest is not always the best Go slightly longer but avoid minefield A* performs well in these situations

31 Why heuristic underestimates Overestimates can cause us to miss good paths We can wander away from good paths permanently, as we believe they are worse than they actually are

32 Why heuristic underestimates Estimating every path as 0 is an underestimate, but… This is just breadth-first search We do not gain any performance

33 Why heuristic underestimates Admissible heuristics just guarantee optimality We would also like performance improvement

34 A* Considerations Problem is much harder in a continuous environment Optimizations almost always find a way to reduce the continuous space into a few discrete choices for consideration Reduce the branching factor Limit the number of choices you have at each decision step

35 Improvements Transforming the Search Space Usually easier to clean up your search space than tweak your algorithm Have a scripted opening sequence This is very common in Chess Reduce the space by following a known good opening

36 Improvements Transforming the Search Space Increase granularity in pathfinding Ex: rather than step-by-step from an address in Denton to an address in Brazil First country by country


Download ppt "CSCI 4310 Lecture 4: Search 2 – Including A*. Book Winston Chapters 4,5,6."

Similar presentations


Ads by Google