Heuristics: A*-algorithm 3: Unterschied zwischen den Versionen

Aus Operations-Research-Wiki
Wechseln zu: Navigation, Suche
[unmarkierte Version][unmarkierte Version]
Zeile 29: Zeile 29:
 
<math>f(n)= g(n) + h(n)</math>
 
<math>f(n)= g(n) + h(n)</math>
  
<math>g(n)</math><math>Formel hier einfügen</math>: previous costs from the start node
+
<math>g(n)</math>: previous costs from the start node
 
<math>h(n)</math>: approximated costs from the current node to the end node
 
<math>h(n)</math>: approximated costs from the current node to the end node
  
Zeile 43: Zeile 43:
 
During the search the nodes will be classified in three categories:
 
During the search the nodes will be classified in three categories:
 
• Unknown nodes: nodes which were not analyzed yet
 
• Unknown nodes: nodes which were not analyzed yet
• Known nodes: a path to these nodes is known. All other nodes with their specific value will be saved in the OPEN LIST. From this list the most cost-saving node gets picked out. It is a kind of list of precedence rating
+
• Known nodes: a path to these nodes is known. All other nodes with their specific value will be saved in the OPEN LIST. From this list
• Node which have to be analyzed: the shortest path to these nodes is known and they can be saved and checked in the CLOSED LIST because every node should be analyzed only once
+
        the most cost-saving node gets picked out. It is a kind of list of precedence rating
 +
• Node which have to be analyzed: the shortest path to these nodes is known and they can be saved and checked in the CLOSED LIST because  
 +
        every node should be analyzed only once
  
 
If the end node is reached, than the A* ends.
 
If the end node is reached, than the A* ends.
Zeile 57: Zeile 59:
 
• The heuristic is monotonous if the path's costs are positive
 
• The heuristic is monotonous if the path's costs are positive
  
Some other characteristics of A*
+
 
 +
'''Some other characteristics of A*'''
 +
 
  
 
• Complete: every existent solution will be found
 
• Complete: every existent solution will be found
Zeile 64: Zeile 68:
 
So the A* is optimal, if a monotnous heuristic is used.  
 
So the A* is optimal, if a monotnous heuristic is used.  
  
Claim: The A* always finds the optimal solution.
+
''Claim'': The A* always finds the optimal solution.
  
Evidence: <math>L1</math> is an optimal solution with the costs of <math>K*</math> and <math>L2</math> is a sub-optimal solution. The heuristic should not overrate the costs of the most cost-saving solution and that is why <math>h(L2)=0</math>.
+
''Evidence'': <math>L1</math> is an optimal solution with the costs of <math>K*</math> and <math>L2</math> is a sub-optimal solution. The heuristic should not overrate the costs of the most cost-saving solution and that is why <math>h(L2)=0</math>.
  
 
The fact that <math>L2</math> is a sub-optimal solution means for <math>K2</math> that: <math>K2=f(L2)=g(L2)+h(L2)=g(L2)>K*</math>.
 
The fact that <math>L2</math> is a sub-optimal solution means for <math>K2</math> that: <math>K2=f(L2)=g(L2)+h(L2)=g(L2)>K*</math>.
Zeile 77: Zeile 81:
 
So the A* does not show the sub-optimal solution <math>L2</math> as long there exists an another optimal solution like <math>L1</math>.
 
So the A* does not show the sub-optimal solution <math>L2</math> as long there exists an another optimal solution like <math>L1</math>.
  
Area of application
+
 
 +
== Area of application ==
 +
 
  
 
Theoretically the A* can solve every problem which can be transferred into a graph and in which a heuristic function can be used. Examples are Puzzles, routes through several cities, houses etc.
 
Theoretically the A* can solve every problem which can be transferred into a graph and in which a heuristic function can be used. Examples are Puzzles, routes through several cities, houses etc.
Zeile 83: Zeile 89:
 
In general the A* is often used in route planning software or computer games.  
 
In general the A* is often used in route planning software or computer games.  
  
'''Example'''
+
 
 +
== Example ==
 +
 
  
 
[[Datei:Folie1.jpg]]
 
[[Datei:Folie1.jpg]]
Zeile 100: Zeile 108:
  
  
Related algorithms and Disadvantages
+
 
 +
== Related algorithms and Disadvantages ==
 +
 
  
 
A related algorithm to the A*-Algorithm is the Dijkstra-Algorithm. In comparision, the Dijkstra does not use any information about the position of the end node. It searches in all possible ways simoultaneously until the end node is found.  
 
A related algorithm to the A*-Algorithm is the Dijkstra-Algorithm. In comparision, the Dijkstra does not use any information about the position of the end node. It searches in all possible ways simoultaneously until the end node is found.  
Zeile 106: Zeile 116:
  
 
Although the A* does not analyze so much as the Dijkstra there are still some disadvantages in comparision to other algorithms.  
 
Although the A* does not analyze so much as the Dijkstra there are still some disadvantages in comparision to other algorithms.  
First of all, during the search all nodes will be saved in the OPEN List and CLOSED LIST which requires a big storage to save these information. So if there exists a very complexe problem, the A* is inapplicable for that. A good example for that is the 15-Puzzle in which the graph has 16! = 20.922.789.888.000 nodes.
+
First of all, during the search all nodes will be saved in the OPEN List and CLOSED LIST which requires a big storage to save these information. So if there exists a very complexe problem, the A* is inapplicable for that. A good example for that is the 15-Puzzle in which the graph has <math>16! = 20.922.789.888.000</math> nodes.
 
The next problem is that the heuristic can be very complexe according to the time. If the heuristic does not work with a big preciseness and monotonously than some nodes can be analyzed more than once, thus the required time during the search grows exponentially.  
 
The next problem is that the heuristic can be very complexe according to the time. If the heuristic does not work with a big preciseness and monotonously than some nodes can be analyzed more than once, thus the required time during the search grows exponentially.  
  
References
+
 
 +
== References ==
 +
  
 
1. http://de.wikipedia.org/wiki/A*-Algorithmus
 
1. http://de.wikipedia.org/wiki/A*-Algorithmus

Version vom 27. Juni 2013, 20:15 Uhr

A*-Algorithm

Algorithms search bidirectional and are used to search for a specific destination. One of these algorithms is the A*-Algorithm. The A*-Algorithm is a heuristic search algorithm which was developed in the year 1968 by Peter Hart, Nils J. Nilsson and Bertram Raphael and is used to find the shortest path between two nodes in a complete graph. Today it represents an extension to the Dijkstra-Algorithm and is the most used heuristic algorithm.

Contents 1. Definition 2. Idea of A* 3. Function 4. Properties 5. Area of application 6. Example 7. Related algorithms and Disadvantages 8. References

Idea of the A*

The A*-Algorithm is based on the shortest-path algorithm of Dijkstra. The first step of Dijkstra is expanding from a start node to the next nodes. Then this step gets repeated until the destination is reached. In the end all paths get summed and the path which has the most minimal costs will be prioritized. In contrast to Dijkstra the A* does not search for all possible paths it searches for these nodes which lead over the fastest path to the end node. So the A* is used for getting the most cost-saving and most-efficient path between start and end node.


Function

All nodes of the graph have a specific value which are noted as ( can describe for example length, costs etc.). The node with the most minimal value will be analyzed futhermore.

: previous costs from the start node : approximated costs from the current node to the end node

Because of the usage of the heuristic funciton, a more target-oriented search towards the end note is possible. So the course of action by using the A*-Algorithm is like this:

1. Note the values of all neighbors of the current node in your OPEN LIST 2. Sort the OPEN LIST according to the node's values in an ascending order 3. The node with the most minimal value gets deleted from the OPEN LIST and gets written down in the CLOSED LIST. This note is now your current node 4. Repeat step 1,2 and 3 until you reach the end note 5. Construct your optimal path and show your final CLOSED LIST

During the search the nodes will be classified in three categories: • Unknown nodes: nodes which were not analyzed yet • Known nodes: a path to these nodes is known. All other nodes with their specific value will be saved in the OPEN LIST. From this list

       the most cost-saving node gets picked out. It is a kind of list of precedence rating

• Node which have to be analyzed: the shortest path to these nodes is known and they can be saved and checked in the CLOSED LIST because

       every node should be analyzed only once

If the end node is reached, than the A* ends.


Characteristics

If are the costs for expanding to the end node than there are two conditions for the heuristic

• The heuristic is admissable if the values do not overrate the costs of the most cost-saving solution • The heuristic is monotonous if the path's costs are positive


Some other characteristics of A*


• Complete: every existent solution will be found • Optimal: only the optimal solution will be found although there are more than one valid solutions

So the A* is optimal, if a monotnous heuristic is used.

Claim: The A* always finds the optimal solution.

Evidence: is an optimal solution with the costs of Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): K*

and  is a sub-optimal solution. The heuristic should not overrate the costs of the most cost-saving solution and that is why .

The fact that is a sub-optimal solution means for that: Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): K2=f(L2)=g(L2)+h(L2)=g(L2)>K* . The heuristic estimates the real costs, so that for every node x of the fastest path is applied that: Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): f(x) = g(x) + h(x) <=K* , and thats means Fehler beim Parsen (http://mathoid.testme.wmflabs.org Serverantwort ist ungültiges JSON.): f(x)<=K* < f(L2) , thus

So the A* does not show the sub-optimal solution as long there exists an another optimal solution like .


Area of application

Theoretically the A* can solve every problem which can be transferred into a graph and in which a heuristic function can be used. Examples are Puzzles, routes through several cities, houses etc.

In general the A* is often used in route planning software or computer games.


Example

Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden

In this example we have to find the shortest path betwenn node H and node A. For that we use A*-Algorithm.

First Iteration

First of all the two neighbor nodes of H will be analyzed according to their distances and air-line distances. The next step is summing these distances up and choosing the minimal one. These air-line distances are given.





Related algorithms and Disadvantages

A related algorithm to the A*-Algorithm is the Dijkstra-Algorithm. In comparision, the Dijkstra does not use any information about the position of the end node. It searches in all possible ways simoultaneously until the end node is found. The A* does not analyze so many nodes but it must be informed of the position of the end node to use it's heuristic function.

Although the A* does not analyze so much as the Dijkstra there are still some disadvantages in comparision to other algorithms. First of all, during the search all nodes will be saved in the OPEN List and CLOSED LIST which requires a big storage to save these information. So if there exists a very complexe problem, the A* is inapplicable for that. A good example for that is the 15-Puzzle in which the graph has nodes. The next problem is that the heuristic can be very complexe according to the time. If the heuristic does not work with a big preciseness and monotonously than some nodes can be analyzed more than once, thus the required time during the search grows exponentially.


References

1. http://de.wikipedia.org/wiki/A*-Algorithmus 2. http://www.geosimulation.de/methoden/a_stern_algorithmus.htm 3. http://pille.iwr.uni-heidelberg.de/~astar01/ 4. http://www.policyalmanac.org/games/aStarTutorial_de.html 5. http://www.hubertus-becker.de/files/khepera-workout.de.pdf