1 / 8

Group 5

Group 5. Semir Elezovikj Mo'taz Abdul Aziz Ali Al- Hami Howard Liu. Heuristic Function H(n). F(n) = G(n) + H(n) How to decide the heuristic function H(n) in this project? Our choice for this project: for two points (x1, y1) and (x2, y2): H(n) = Diagonal Distance

oliana
Download Presentation

Group 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Group 5 SemirElezovikj Mo'taz Abdul Aziz Ali Al-Hami Howard Liu

  2. Heuristic Function H(n) • F(n) = G(n) + H(n) • How to decide the heuristic function H(n) in this project? • Our choice for this project: for two points (x1, y1) and (x2, y2): H(n) = Diagonal Distance = max(abs(x1-x2),abs(y1-y2))

  3. Consider a 3x6 map (in terms of edge length): 1. Costs are assigned to nodes but not edges. 2. Paths between two nodes can be vertical, horizontal, or diagonal. 3. costs are random numbers between 1 and 11.

  4. To find the minimum cost for a 3x6 map: 1. Assume all nodes have the lowest cost: 1. 2. Find the shortest path in this map. 3. The cost of this shortest path is the lowest cost of all possible “random number costs” 3x6 maps.

  5. 1. By brute force, we can find many shortest paths. Here are four of them. 2. They all consist of the start node, 3 diagonal moves, and 3 vertical moves. 3. They all have the lowest cost: 1 + 3 + 3 = 7. 4. The cost 7 should be the minimum cost of all possible “random number costs” 3x6 maps.

  6. 1. In a 3x3 square, the number of diagonal moves is equal to its side length 3. 2. In fact, 7 = the longer length of the rectangle + start node = 6 + 1. 3. Therefore, we can conclude the minimum cost of a map is its longer side length + 1. This is an admissible heuristic function. H(n) <= H*(n). 5. We can ignore the 1 cost of start node, since it is already counted in G(n). 6. Formula: for two points (x1, y1) and (x2, y2), H(n) = max(abs(x1-x2), abs(y1-y2)) 7. This is called “Diagonal Distance”, “Chessboard Distance”, or “Chebyshev Distance”.

  7. Speed Up the Program Our strategies: • Avoid repeatedly changing matrix size in a big loop. • Avoid repeatedly calling sub-functions in a big loop. • Since the map size is not very big, a simple algorithm is faster than a fancy algorithm. In our case, the simple linear search for minimum is faster than a complicated implementation of priority queue (min-heap) because the linear search has less data movements.

  8. Pseudo code (found on Wikipedia) • http://en.wikipedia.org/wiki/A*_search_algorithm

More Related