Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

# A* search and use of heuristic

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Prochain SlideShare
A* algorithm
Chargement dans…3
×

## Consultez-les par la suite

1 sur 18 Publicité

# A* search and use of heuristic

Definition of A * search with the example. What is heuristic technique and how heuristic technique is used in A * search. It also includes properties, advantages and disadvantages of A* search algorithm.

Definition of A * search with the example. What is heuristic technique and how heuristic technique is used in A * search. It also includes properties, advantages and disadvantages of A* search algorithm.

Publicité
Publicité

## Plus De Contenu Connexe

Publicité

Publicité

### A* search and use of heuristic

1. 1. A* search algorithm & Use of Heuristics in Search Bhagawat Adhikari
2. 2. What is A* Search Algorithm? • In computer science, A* (pronounced as "A star") is a computer algorithm that is widely used in pathfinding and graph traversal. • A* Search algorithm is one of the best and popular technique used in path-finding and graph traversals. • Peter Hart, Nils Nilsson and Bertram Raphael of Stanford Research Institute first described the algorithm in 1968. • It is an extension of Edsger Dijkstra's 1959 algorithm. • A* achieves better performance by using heuristics to guide its search. Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 24/5/2018
3. 3. A* Search  It is the combination of Dijkstra’s algorithm and Best first search. It can be used to solve many kinds of problems.  A* search finds the shortest path through a search space to goal state using heuristic function. This technique finds minimal cost solutions and is directed to a goal state called A* search.  In A*, the * is written for optimality purpose. The A* algorithm also finds the lowest cost path between the start and goal state, where changing from one state to another state.  A* requires heuristic function to evaluate the cost of path that passes through the particular state.  A* requires heuristic function to evaluate the cost of path that passes through the particular state. It can be defined by following formula. Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 34/5/2018
4. 4. Start state 3 24  A * Algorithm avoids expanding paths that are already expensive, but expands most promising paths. f(n) = g(n) + h(n) where: g(n): The actual cost path from the start state to current state. h(n): The actual cost path from the current state to the goal (final/destination) state (heuristic value). f(n): The actual cost path from the start state to the goal state. A B Current state Heuristic Path cost Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 44/5/2018
5. 5. • Movement for a single object seems easy. Pathfinding is complex. Why bother with pathfinding? Consider the following situation: Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 54/5/2018
6. 6. • The unit is initially at the bottom of the map and wants to get to the top. There is nothing in the area it scans (shown in pink) to indicate that the unit should not move up, so it continues on its way. Near the top, it detects an obstacle and changes direction. • It then finds its way around the “U”-shaped obstacle, following the red path. In contrast, a pathfinder would have scanned a larger area (shown in light blue), but found a shorter path (blue), never sending the unit into the concave shaped obstacle. • A* is like Dijkstra’s Algorithm in that it can be used to find a shortest path. A* is like Greedy Best-First-Search in that it can use a heuristic to guide itself. In the simple case, it is as fast as Greedy Best-First-Search. Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 64/5/2018
7. 7. Heuristics technique • It is a techniques for problem solving, learning, and discovery that find a solution which is not guaranteed to be optimal, but good enough for a given set of goals. • A heuristic is a mental shortcut that allows people to solve problems and make judgments quickly and efficiently. • When the comprehensive search and computation methods is impossible to do, heuristics methods are used to speed up the process of finding a satisfactory solution. • A heuristic method is used to rapidly come to a solution that is hoped to be close to the best possible answer, or 'optimal solution'. • Example of Heuristics are "rules of thumb", educated guesses, intuitive judgments or simply common sense. 74/5/2018 Bhagawat Adhikari | Sherubtse College | Computer Science (Honours)
8. 8. 4/5/2018 Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 8 Why Do We Use Heuristics? • Heuristics play important roles in both problem-solving and decision-making. • When we are trying to solve a problem or make a decision, we often turn to these mental shortcuts when we need a quick solution. • The world is full of information, yet our brains are only capable of processing a certain amount. If you tried to analyze every single aspect of every situation or decision, you would never get anything done! • In order to cope with the tremendous amount of information we encounter and to speed up the decision-making process, the brain relies on these mental strategies to simplify things so we don't have to spend endless amounts of time analyzing every detail. • You probably make hundreds or even thousands of decisions every day. What should you have for breakfast? What should you wear today? Should you drive or take the bus? The list of decisions you make each day is endless and varied. • Fortunately, heuristics allow you to make such decisions with relative ease without a great deal of agonizing.
9. 9. 4/5/2018 Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 9 Example • For example, when you are trying to decide if you should drive or ride the bus to work, you might suddenly remember that there is road construction along the standard bus route. You quickly realize that this might slow the bus and cause you to be late for work, so instead, you simply leave a little earlier and drive to work on an alternate route. • Your heuristics allow you to think through the possible outcomes quickly and arrive at a solution that will work for your unique problem.
10. 10. Example of A * Search • Aim: To find the path from the start state to goal state with minimum cost. • We are given with Heuristic value as follows: • We use A* algorithm to find the minimum cost of travel from start to goal state. • We have the equation as: f(n) = g(n) + h(n) And using this formula we will determine the minimum cost to reach goal state from start state. S 7 A 6 B 2 C 1 D 0 3 2 12 5 5 7 Goal State Start stateS 7 C 1 D 0 B 2 A 6 1 5 2 4 Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 104/5/2018
11. 11. • Start state is S, so we start with S and apply the formula on S. Since S is the starting state, hence g(n) will be 0. f(n) = g(n) + h(n) S: f(n) = 0 + 7 = 7 • Now S has two children, i.e., A & B. We need to determine the cost over the path SA & SB. SA: f(n) = 1 + 6 = 7 SB: f(n) = 4 + 2 = 6 • Now, we obtained the cost of the route from SA & SB. Since, we are concerned with the minimum cost of travel, we proceed with minimum path cost, i.e. SB. 3 2 12 5 5 7 Goal State Start stateS 7 C 1 D 0 B 2 A 6 1 5 2 4 Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 114/5/2018
12. 12. • Whenever we get such route between the nodes, we need to save it and proceed to next step taking the shortest path. • So our next path is SBC and we update the cost. SBC: f(n) = (4+2) +1 = 7 • Once we use the path, then we cannot use that path again, hence we check the used path. • Now we have two route with same cost, so we can select any, so lets go with SA. SAB: f(n) = (1+2) + 1 = 5 SAC: f(n) = (1+5) + 1 = 7 SAD: f(n) = (1+12) + 0 = 13 (final state) • Now from the available route, we go with minimum route again, i.e. SAB SABC: f(n) = (1+2+2) + 1 =6 • Moving with next Minimum path SABC SABCD: f(n) = (1+2+2+3) + 0 = 8 (final state) SA= 7 SB= 6 SBC= 7 SAB= 5 SAC= 7 SAD= 13 SABC= 6 SABCD=8 3 2 12 5 5 7 Goal State Start stateS 7 C 1 D 0 B 2 A 6 1 5 2 4 Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 124/5/2018
13. 13. SA= 7 SB= 6 SBC= 7 SAB= 5 SAC= 7 SAD= 13 SABC= 6 SABCD=8 SBCD = 9 SACD = 9 3 2 12 5 5 7 Goal State Start stateS 7 C 1 D 0 B 2 A 6 1 5 2 4 • Now we have two paths which are not been used or traversed, i.e. SAC & SBC. We cannot use SAD & SABCD as we have reached final state. • SO far we have optimal cost is 8 via SABCD, we will check other path. If we get cost less than 8, then we will take new path otherwise 8 will be the optimal cost and SABCD with be the optimal path. SBCD: f(n) = (4+2+3) + 0 =9 (final state) and SACD: f(n) = (1+5+3) + 0 = 9 (final state) • In total there are 4 paths to reach the goal state. • We select the path with the minimum cost, i.e. SABCD with the cost of 8 units. 3 2 12 5 5 7 Goal State Start stateS 7 C 1 D 0 B 2 A 6 1 5 2 4 Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 134/5/2018
14. 14. Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 144/5/2018
15. 15. Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 154/5/2018
16. 16. Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 164/5/2018
17. 17. Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 174/5/2018
18. 18. Reference • GeeksforGeeks. (2018). A* Search Algorithm - GeeksforGeeks. [online] Available at: https://www.geeksforgeeks.org/a-search-algorithm/ [Accessed 26 Feb. 2018]. • En.wikipedia.org. (2018). A* search algorithm. [online] Available at: https://en.wikipedia.org/wiki/A*_search_algorithm [Accessed 26 Feb. 2018]. • Verywell Mind. (2018). How Heuristics Help You Make Quick Decisions. [online] Available at: https://www.verywellmind.com/what-is-a-heuristic-2795235 [Accessed 6 Apr. 2018]. Bhagawat Adhikari | Sherubtse College | Computer Science (Honours) 184/5/2018