What makes a heuristic admissible




















If, after profiling, you find the cost of the square root is significant, either use a fast square root approximation with Euclidean distance or use the diagonal distance as an approximation to Euclidean.

If you want to search for any of several goals, construct a heuristic h' x that is the minimum of h1 x , h2 x , h3 x , One way to think about this is that we can add a new zero-cost edge from each of the goals to a new graph node.

A path to that new node will necessarily go through one of the goal nodes. While processing nodes from the OPEN set, exit when you pull a node that is near enough.

In some grid maps there are many paths with the same length. For example, in flat areas without variation in terrain, using a grid will lead to many equal-length paths. Ties in f values. The quick hack to work around this problem is to either adjust the g or h values.

The tie breaker needs to be deterministic with respect to the vertex i. One way to break ties is to nudge the scale of h slightly. If we scale it downwards, then f will increase as we move towards the goal.

We can instead scale h upwards slightly even by 0. Tie-breaking scaling added to heuristic. Tie-breaking scaling added to heuristic, works nicely with obstacles. Steven van Dijk suggests that a more straightforward way to do this would to pass h to the comparison function. When the f values are equal, the comparison function would break the tie by looking at h. Another way to break ties is to add a deterministic random number to the heuristic or edge costs. One way to choose a deterministic random number is to compute a hash of the coordinates.

This breaks more ties than adjusting h as above. Thanks to Cris Fuhrman for suggesting this. A different way to break ties is to prefer paths that are along the straight line from the starting point to the goal:.

This code computes the vector cross-product between the start to goal vector and the current point to goal vector. The result is that this code will give some slight preference to a path that lies along the straight line path from the start to the goal. Tie-breaking cross-product added to heuristic, produces pretty paths. However, because this tie-breaker prefers paths along the straight line from the starting point to the goal, weird things happen when going around obstacles note that the path is still optimal; it will look strange :.

Tie-breaking cross-product added to heuristic, less pretty with obstacles. Typically there is a trade-off between the amount of work it takes to compute a heuristic value for a node and the accuracy of the heuristic value. A standard way to derive a heuristic function is to solve a simpler problem and to use the cost to the goal in the simplified problem as the heuristic function of the original problem [see Section 3. For the graph of Figure 3. The examples that follow assume the following heuristic function:.

This h function is an admissible heuristic because the h value is less than or equal to the exact cost of a lowest-cost path from the node to a goal. The h function can be extended to be applicable to paths by making the heuristic value of a path equal to the heuristic value of the node at the end of the path.

That is:. A simple use of a heuristic function in depth-first search is to order the neighbors that are added to the stack representing the frontier. The neighbors can be added to the frontier so that the best neighbor is selected first. This is known as heuristic depth-first search. An optimal solution to the simpler problem cannot have a higher cost than an optimal solution to the full problem because any solution to the full problem is a solution to the simpler problem. In many spatial problems where the cost is distance and the solution is constrained to go via predefined arcs e.

For many problems one can design a better heuristic function, as in the following examples. Consider the delivery robot of Example 3. Suppose the cost function is the total distance traveled by the robot to deliver all the parcels. If the robot could carry multiple parcels, one possible heuristic function is the maximum of a and b :. This is not an overestimate because it is a solution to the simpler problem which is to ignore that it cannot travel though walls, and to ignore all but the most difficult parcel.

Note that a maximum is appropriate here because the agent has to both deliver the parcels it is carrying and go to the parcels it is not carrying and deliver them to their destinations. If the robot could only carry one parcel, one possible heuristic function is the sum of the distances that the parcels must be carried plus the distance to the closest parcel.



0コメント

  • 1000 / 1000