# D*

D* (pronounced "D star") is any one of the following three related incremental search algorithms:
* The original D*, by Anthony Stentz, is an informed incremental search algorithm.
* Focused D* is an informed incremental heuristic search algorithm by Anthony Stentz that combines ideas of A* and the original D*. Focused D* resulted from a further development of the original D*.
* D* Lite is an incremental heuristic search algorithm by Sven Koenig and Maxim Likhachev that builds on LPA*, an incremental heuristic search algorithm that combines ideas of A* and Dynamic SWSF-FP.
All three search algorithms solve the same assumption-based path planning problems, including planning with the freespace assumption, where a robot has to navigate to given goal coordinates in unknown terrain. It makes assumptions about the unknown part of the terrain (for example: that it contains no obstacles) and finds a shortest path from its current coordinates to the goal coordinates under these assumptions. The robot then follows the path. When it observes new map information (such as previously unknown obstacles), it adds the information to its map and, if necessary, replans a new shortest path from its current coordinates to the given goal coordinates. It repeats the process until it reaches the goal coordinates or determines that the goal coordinates cannot be reached. When traversing unknown terrain, new obstacles may be discovered frequently, so this replanning needs to be fast. Incremental (heuristic) search algorithms speed up searches for sequences of similar search problems by using experience with the previous problems to speed up the search for the current one. Assuming the goal coordinates do not change, all three search algorithms are more efficient than repeated A* searches.
D* and its variants have been widely used for mobile robot and autonomous vehicle navigation. Current systems are typically based on D* Lite rather than the original D* or Focused D*. In fact, even Stentz's lab uses D* Lite rather than D* in some implementations. Such navigation systems include a prototype system tested on the Mars rovers Opportunity and Spirit and the navigation system of the winning entry in the DARPA Urban Challenge, both developed at Carnegie Mellon University.
The original D* was introduced by Anthony Stentz in 1994. The name D* comes from the term "Dynamic A*", because the algorithm behaves like A* except that the arc costs can change as the algorithm runs.

## Operation

The basic operation of D* is outlined below.
Like Dijkstra's algorithm and A*, D* maintains a list of nodes to be evaluated, known as the "OPEN list". Nodes are marked as having one of several states:
* NEW, meaning it has never been placed on the OPEN list
* OPEN, meaning it is currently on the OPEN list
* CLOSED, meaning it is no longer on the OPEN list
* RAISE, indicating its cost is higher than the last time it was on the OPEN list
* LOWER, indicating its cost is lower than the last time it was on the OPEN list

### Expansion

The algorithm works by iteratively selecting a node from the OPEN list and evaluating it. It then propagates the node's changes to all of the neighboring nodes and places them on the OPEN list. This propagation process is termed "expansion". In contrast to canonical A*, which follows the path from start to finish, D* begins by searching backwards from the goal node. This means that the algorithm is actually computing the A* optimal path for every possible start node. Each expanded node has a back pointer which refers to the next node leading to the target, and each node knows the exact cost to the target. When the start node is the next node to be expanded, the algorithm is done, and the path to the goal can be found by simply following the back pointers.
* Expansion in progress. The finish node (yellow) is in the middle of the top row of points, the start node is in the middle of the bottom row. Red indicates an obstacle; black/blue indicates expanded nodes (brightness indicating cost). Green indicates nodes which are being expanded.
* Expansion finished. The path is indicated in cyan.

### Obstacle handling

When an obstruction is detected along the intended path, all the points that are affected are again placed on the OPEN list, this time marked RAISE. Before a RAISED node increases in cost, however, the algorithm checks its neighbors and examines whether it can reduce the node's cost. If not, the RAISE state is propagated to all of the nodes' descendants, that is, nodes which have back pointers to it. These nodes are then evaluated, and the RAISE state is passed on, forming a wave. When a RAISED node can be reduced, its back pointer is updated, and passes the LOWER state to its neighbors. These waves of RAISE and LOWER states are the heart of D*.
By this point, a whole series of other points are prevented from being "touched" by the waves. The algorithm has therefore only worked on the points which are affected by change of cost.
* An obstacle has been added (red) and nodes marked RAISE (yellow).
* Expansion in progress. Yellow indicates nodes marked RAISE, green indicates nodes marked LOWER.

### Another deadlock occurs

This time, the deadlock cannot be bypassed so elegantly. None of the points can find a new route via a neighbor to the destination. Therefore, they continue to propagate their cost increase. Only points outside of the channel can be found, which can lead to destination via a viable route. This is how two Lower waves develop, which expand as points marked as unattainable with new route information.
* Channel blocked by additional obstacles (red)
* Expansion in progress (Raise wave in yellow, Lower wave in green)
* New path found (cyan)

## Variants
### Focused D*

As its name suggests, Focused D* is an extension of D* which uses a heuristic to focus the propagation of RAISE and LOWER toward the robot. In this way, only the states that matter are updated, in the same way that A* only computes costs for some of the nodes.

### D* Lite

D* Lite is not based on the original D* or Focused D*, but implements the same behavior. It is simpler to understand and can be implemented in fewer lines of code, hence the name "D* Lite". Performance-wise, it is as good as or better than Focused D*. D* Lite is based on Lifelong Planning A*, which was introduced by Koenig and Likhachev few years earlier. D* Lite

## Minimum cost versus current cost

For D*, it is important to distinguish between current and minimum costs. The former is only important at the time of collection and the latter is critical because it sorts the OpenList. The function which returns the minimum cost is always the lowest cost to the current point since it is the first entry of the OpenList.