For a given network of cities, find an optimal path to reach from a given source city to any other destination city using an admissible heuristic.
Objective: For a given network of cities, find an optimal path to reach from a given source city to any other destination city using an admissible heuristic.
Theory:
Heuristics: The heuristic function h(n) tells A* an estimate of the minimum cost from any vertex n to the goal. It’s important to choose a good heuristic function.
The heuristic can be used to control A*’s behavior.
- At one extreme, if h(n) is 0, then only g(n) plays a role, and A* turns into Dijkstra’s Algorithm, which is guaranteed to find a shortest path.
- If h(n) is always lower than (or equal to) the cost of moving from n to the goal, then A* is guaranteed to find a shortest path. The lower h(n) is, the more node A* expands, making it slower.
- If h(n) is exactly equal to the cost of moving from n to the goal, then A* will only follow the best path and never expand anything else, making it very fast. Although you can’t make this happen in all cases, you can make it exact in some special cases. It’s nice to know that given perfect information, A* will behave perfectly.
- If h(n) is sometimes greater than the cost of moving from n to the goal, then A* is not guaranteed to find a shortest path, but it can run faster.
- At the other extreme, if h(n) is very high relative to g(n), then only h(n) plays a role, and A* turns into Greedy Best-First-Search.
So we have an interesting situation in that we can decide what we want to get out of A*. With 100% accurate estimates, we’ll get shortest paths really quickly. If we’re too low, then we’ll continue to get shortest paths, but it’ll slow down. If we’re too high, then we give up shortest paths, but A* will run faster.
Procedure:
- Put the start node son a list called OPENof unexpanded nodes.
- If OPEN is empty exit with failure; no solutions exists.
- Remove the first OPEN node n at which f is minimum (break ties arbitrarily), and place it on a list called CLOSEDto be used for expanded nodes.
- If nis a goal node, exit successfully with the solution obtained by tracing the path along the pointers from the goal back to s.
- Otherwise expand node n, generating all it’s successors with pointers back to n.
- For every successor n’on n:a. Calculate f(n’).b. if n’ was neither on OPENnor on CLOSED, add it to OPEN. Attach a pointer from n’back to n. Assign the newly computed f(n’)to node n’.c. if n’ already resided on OPENor CLOSED, compare the newly computed f(n’)with the value previously assigned to n’. If the old value is lower, discard the newly generated node. If the new value is lower, substitute it for the old (n’ now points back to n instead of to its previous predecessor). If the matching node n’ resides on CLOSED, move it back to OPEN.
- Go to step 2.
Conclusion: When h is consistent, the f values of nodes expanded by A* are never decreasing. When A* selected n for expansion it already found the shortest path to it. When h is consistent every node is expanded once.Normally the heuristics we encounter are consistent
–the number of misplaced tiles
–Manhattan distance
–straight-line distance
Comments
Post a Comment