Last chapter's Bellman optimality equation was checked using values that were simply recognized — borrowed from a policy already known to be optimal. Real problems don't offer that shortcut. What if all that's known up front is the MDP itself, and every state's value starts out just... wrong?
Start every state's value at exactly — a deliberately bad guess. Then, sweep by sweep, replace every state's value with the Bellman optimality backup computed from the previous sweep's numbers. Step forward and watch a wrong guess turn into the exact right answer, purely from applying the same equation over and over.
Value iteration turns the Bellman optimality equation into an update rule, applied to every state on each pass:
- — the current estimate of state 's value, after sweeps.
- — the updated estimate, computed from a one-step lookahead using .
- Every state updates from the same snapshot
A sweep computes for every state using — the previous sweep's values, not values already updated earlier in the same sweep. This is exactly why "sweep 1" and "sweep 2" are meaningful checkpoints: within a sweep, nothing has propagated yet.
- Why not just solve it directly, like last chapter did?
Last chapter reused from a policy already known to reach the goal by the shortest route — that only worked because moving away from the goal was provably never better. In general an MDP can have cycles (bouncing between states is possible here too, via repeated "left" moves), so there's no safe order to compute states in just once. Iterating to a fixed point sidesteps the ordering problem entirely.
- Policy iteration is the other half of dynamic programming
Instead of iterating on values directly, policy iteration alternates two steps: fully evaluate the current policy's (sweeping the fixed-policy Bellman equation, no , to its own fixed point), then improve the policy by acting greedily on that . Repeat until the policy stops changing. Both algorithms provably converge to the same and .
Every state starts at a flatly wrong . Five sweeps later, the values are — exactly the from the previous chapter, recovered without ever being told the optimal policy in advance.
With , starting from for every state:
- Sweep 1 — only the immediate reward is visible
— the goal's reward reaches state 2 immediately. For states 0 and 1, both the left and right moves land on a neighbor whose is still , so both branches of the max collapse to the same number: and — neither has a neighbor with useful value yet, so both just reflect the cost of a single step.
- Sweep 2 — the goal's value takes one more step back
Using : — now that exists, state 1 can see it. still can't see past state 1's old value: .
- Sweep 3 — every state has settled
. Checking sweep 4 against sweep 3 changes nothing at all — the fixed point has been reached in exactly 3 sweeps, and it's the exact from the previous chapter.
Sweep forward until a sweep changes nothing — the value function has hit its fixed point.
Value iteration finds from nothing but the MDP's own definition — no policy needs to be guessed correctly in advance, and no special ordering of states is required, because repeated sweeps converge to the same fixed point regardless of where they started. The catch is what this chapter assumed throughout: and had to be fully known to compute every backup. The next chapter drops that assumption entirely — learning from nothing but experienced transitions, without ever being handed the transition model itself.