Small Group Tutorials

Here to help students catch up, keep up, and move ahead. Book a consultation here.

How to Learn D* Lite: Incremental Heuristic Search, g/rhs Consistency, Priority Keys and Fast Replanning

Wait, What?

A shortest path can become wrong while you are already walking it.

That is the problem D* Lite was designed to teach us how to solve. A robot may plan through a corridor that later turns out to be blocked. A road network may change after a route has already been computed. Re-running A* from scratch is always an option, but it throws away useful work. D* Lite is an incremental heuristic-search algorithm that repairs a previous shortest-path computation when edge costs change.

The important idea is not “a more complicated A*.” It is reuse: preserve the parts of the earlier search that are still correct, identify the states whose local shortest-path equations are no longer consistent, and repair only what the change can affect.

Quick Answer

Learn D* Lite through A* → repeated replanning → backward search from the goal → g-values → rhs one-step lookahead values → local consistency → two-part priority keys → changed-edge repair → km key adjustment → path extraction → professional testing. If you cannot explain why a state with g(u) ≠ rhs(u) needs attention, the priority-queue details will feel arbitrary.

1. Begin With the Replanning Problem

Suppose a robot knows a grid only partially. It plans from its current position S to a goal G. It moves one step, senses that an obstacle blocks a cell, updates the affected edge costs, and needs a new route. Repeated A* would solve every new map independently. D* Lite asks a better systems question: which conclusions from the previous search are still useful?

This is the first professional lesson. Incremental algorithms are valuable when successive problems differ only slightly. Their advantage comes from exploiting continuity between problem instances, not from magically changing the definition of shortest path.

2. D* Lite Searches Backward

A convenient way to understand D* Lite is to imagine shortest-path information flowing from the goal back toward the robot’s current start. The goal is initialized with a one-step lookahead value of zero. Other states begin at infinity. As the algorithm repairs the graph, states learn the cheapest known cost of reaching the goal.

Searching backward is useful because the goal usually stays fixed while the robot’s start moves. That lets much of the goal-rooted shortest-path structure survive as the robot advances.

3. The Two Numbers: g and rhs

Each state u has two important values.

  • g(u) is the algorithm’s current stored estimate of the shortest cost from u to the goal.
  • rhs(u) is a one-step lookahead value: for an ordinary state, it is the best value obtained by taking one outgoing edge and then using the neighbour’s g-value.

For u other than the goal, a simplified definition is:

rhs(u) = min over successors v of [ cost(u,v) + g(v) ]

The goal is special: rhs(goal) = 0.

This pair is the heart of the algorithm. D* Lite does not need every state to be perfect at every instant. It needs to know where stored information disagrees with what the neighbouring information currently implies.

4. Local Consistency Is the Main Invariant

A state is locally consistent when g(u) = rhs(u). If g(u) > rhs(u), the stored value is too pessimistic relative to the current one-step evidence. If g(u) < rhs(u), the stored value is too optimistic—often because an edge became more expensive or disappeared.

Only inconsistent states need to be candidates for repair. This is why D* Lite can avoid revisiting the entire graph after a local change.

A powerful study technique here is to stop before code and make a three-column trace: state, g, rhs. Change one edge cost and circle only the rows where equality breaks. That visualises exactly what the priority queue is managing.

5. Why the Priority Key Has Two Parts

D* Lite places inconsistent states into a priority queue with a lexicographic key. A common form is:

m = min(g(u), rhs(u))
key1 = m + h(start, u) + km
key2 = m

The first component uses the heuristic to favour states relevant to the current start. The second component breaks ties with the best currently supported goal-distance estimate. Keys are compared lexicographically: compare key1 first, then key2.

The heuristic should satisfy the assumptions required by the algorithm, typically consistency. On a four-neighbour grid with unit edge costs, Manhattan distance is a natural example.

6. The Repair Loop

The core search repeatedly processes the most urgent inconsistent state until the start no longer needs repair. A simplified learning version is:

while queue.topKey < calculateKey(start)
      or rhs(start) != g(start):
    u = queue.pop()

    if oldKey < calculateKey(u):
        reinsert u with its new key

    else if g(u) > rhs(u):
        g(u) = rhs(u)
        update predecessors of u

    else:
        g(u) = infinity
        update u and predecessors of u

This is intentionally a teaching sketch, not copied publication pseudocode. The conceptual split matters: when g is too large, accept the better rhs value; when g is too small, invalidate the stale optimistic value and allow the affected region to be recomputed.

7. What UpdateVertex Really Does

An update operation normally recomputes rhs(u) from its successors, removes any stale queue entry for u, and reinserts u only if g(u) and rhs(u) differ. That gives the queue a precise contract: it stores the frontier of local inconsistency.

This is much easier to debug than treating the queue as a mysterious collection of “promising nodes.” Every queued state should have a reason to be there.

8. What Happens When the Robot Moves

After a path is available, the robot usually chooses a successor that minimizes:

cost(current, next) + g(next)

Then it moves, senses new information, and updates changed edge costs. D* Lite also maintains a key modifier often written km. When the start moves from the previous location to the new one, km is increased by the heuristic distance between those two starts. This allows old queue keys to remain useful without explicitly rebuilding the whole queue after every movement.

That is a subtle but important optimization: instead of eagerly changing many stored priorities, adjust the comparison framework.

9. Trace One Obstacle Change by Hand

Use a 5×5 grid. Place S in the lower-left corner and G in the upper-right. First compute a route with no obstacles. Then raise the cost of one edge on that route to infinity. Do not rerun everything. Recompute rhs only where the changed edge matters, add newly inconsistent states to the queue, and follow the propagation until the start becomes consistent again.

A learner should be able to answer four questions after every queue operation: Which state changed? Why did g and rhs disagree? Which predecessors can inherit the effect? What condition tells us we can stop repairing?

10. D* Lite Is Not a Dynamic-Obstacle Predictor

A common misunderstanding is to treat D* Lite as a complete autonomous-navigation system. It is not. It repairs shortest paths when graph costs change. If an obstacle is moving, a separate perception or prediction system may be needed to estimate where that obstacle will be. Real robots often combine a global planner with local collision avoidance, trajectory optimization, mapping and control.

The algorithm’s job should remain clean: given an updated graph and edge costs, repair the route efficiently.

11. When D* Lite Helps—and When It May Not

D* Lite is attractive when the graph is large, changes are local, the goal remains fixed, and many replans are required. But incremental search has overhead. On easy instances, tiny graphs or situations where almost everything changes at once, repeated A* can be competitive or faster. Algorithm engineering means measuring the workload rather than assuming an incremental method must win.

Useful professional comparisons include repeated A*, Lifelong Planning A*, D* Lite, and domain-specific planners on the same changing-map traces.

12. Correctness Comes Before Speed

Test the implementation on tiny graphs where the exact shortest path can be checked independently. After every repair, compare the cost returned by D* Lite with a fresh reference Dijkstra or A* computation. Randomly increase and decrease edge costs, move the start, and verify that unreachable cases are handled correctly.

One historical erratum in widely circulated D* Lite pseudocode is especially useful for students: the no-path check concerns rhs(start) being infinite. Small details around infinity, stale queue entries and key comparison can quietly break an otherwise convincing implementation.

Common Failure States

  • Thinking g and rhs are two interchangeable distance estimates rather than a stored value and a one-step lookahead consistency check.
  • Forgetting that D* Lite normally propagates information backward from the goal.
  • Using a heuristic that violates the assumptions required for the chosen graph.
  • Updating an edge cost without updating the vertices whose rhs values depend on it.
  • Comparing two-part keys incorrectly or ignoring stale queue keys.
  • Rebuilding the whole queue after every movement instead of understanding the purpose of km.
  • Assuming incremental search is automatically faster on every workload.
  • Confusing route repair with moving-obstacle prediction or low-level robot control.

Practice Ladder

  • Beginner: run A* on a small grid, then block one edge and explain what information became obsolete.
  • Foundation: calculate g and rhs values by hand and identify locally consistent and inconsistent states.
  • Intermediate: implement UpdateVertex and the two-component priority key, then trace one cost increase and one cost decrease.
  • Advanced: implement the complete repair loop, moving start and km, and compare against repeated A*.
  • Professional: benchmark replanning time, node expansions, queue operations and memory across different change rates and map structures.
  • Verification: after randomized edge updates, compare every returned path cost with a fresh trusted shortest-path computation.

Learning Hall Boundary

This article owns the learning job of D* Lite incremental shortest-path repair: g/rhs consistency, priority keys, changed-edge propagation, km and replanning. It does not replace the existing canonical teaching jobs for A*, shortest paths, priority queues, graph foundations, robotics perception, MindOS, Bolt or the Student/Studying Interface.

Evidence Boundary

D* Lite was introduced by Sven Koenig and Maxim Likhachev in the early 2000s and is closely related to Lifelong Planning A*. The official Carnegie Mellon Robotics Institute publication record and AAAI archive remain primary references. Current robotics literature continues to use and adapt incremental heuristic search, while also emphasizing workload-dependent performance and the need to integrate global replanning with perception and local motion planning.

Professional rule: you understand D* Lite when you can point to any queued state and explain exactly which local shortest-path equation is inconsistent, why that inconsistency matters to the current start, and what evidence will make the state consistent again.