Introduction to Robot Learning · Lecture 7 of 25 · CMU 16-831

RL Basics: Value & Policy Iteration

A robot stands in a gridworld. How good is each square, and what's the best move from each? Two questions, one recursive idea — the Bellman equation — and two clean algorithms that hand you the optimal policy with nothing but a spreadsheet of numbers.

Prerequisites: the MDP vocabulary (state, action, reward, transition, policy, discount) from Lecture 1 + a little Python. No prior RL assumed.
10
Chapters
4
Simulations
3
Code Labs

Chapter 0: How Good Is This Square?

Picture a robot dropped into a tiny gridworld. Off to the right is a charging dock — the goal. Every step the robot takes drains a little battery (a small cost), and parking on the dock ends the episode happily (no more cost). The robot can move left or right. Nothing about the world is hidden: it knows the layout, it knows the cost of a step, it knows exactly where each move lands it.

And yet there are two questions it cannot answer by staring at a single square:

The one idea of this lecture. The goodness of a square is not a local property — it is the cost-to-go folded over the entire future. The trick that makes it computable is that the goodness of a square equals the immediate reward plus the (discounted) goodness of wherever you land next. That single recursive sentence is the Bellman equation, and everything in this lecture is a way to solve it.

That recursion is the seed of two algorithms you will own by the end of this lesson. Policy iteration alternates between scoring a fixed plan and greedily improving it. Value iteration skips the bookkeeping and folds improvement directly into the scoring. Both terminate at the same answer — the optimal value of every square and the optimal action from every square — and the magic is that they are guaranteed to get there.

Let's watch it happen before we write a single symbol. The widget below runs value iteration on the corridor. Each press of Sweep updates every square's value once; arrows show the move the values currently recommend. Watch goodness propagate backward from the dock, one square per sweep, until the numbers freeze.

Gridworld value iteration — watch goodness flow back from the goal

A 4-square corridor: A·B·C cost −1 per step, D = dock (goal, value 0). Press Sweep to update all values once; the arrow under each square is the move those values now prefer. Press Run to convergence to fast-forward. Notice: it takes exactly as many sweeps as the corridor is long for the goal's "pull" to reach square A.

Sweep 0 — every square starts at value 0 (we know nothing yet).

Two things to carry forward. First, the values did not appear all at once — the goal's influence crept backward, one square per sweep, because each square can only see one step ahead per update. Second, once the numbers stopped changing, the arrows pointed the right way everywhere. The optimal policy fell out of the values for free. That is the whole game.

In the corridor above, why does it take three sweeps for square A (the far-left square) to reach its final value, while square C (next to the dock) is correct after one sweep?

Chapter 1: Return — Why the Future Gets Discounted

Before we can say how good a square is, we need a single number that scores an entire future. That number is the return: the total reward the robot will collect from now on. We met it in Lecture 1; here we sharpen it, because it is the thing every value is an average of.

Write the rewards the robot receives, step by step, as r at time 1, r at time 2, and so on. The naive return is just their sum. But for an infinite-horizon problem — a robot that lives forever — that sum can blow up to infinity, and "infinity vs. infinity" tells you nothing about which behavior is better. The fix is the discount factor γ (gamma), a number between 0 and 1:

Gt = rt+1 + γ rt+2 + γ² rt+3 + γ³ rt+4 + … = ∑k≥0 γk rt+k+1

Read it slowly. Gt is the return measured from time t. A reward one step away counts at full value; a reward two steps away is multiplied by γ; three steps away by γ²; and so on. The further into the future a reward sits, the more it shrinks.

Why discount at all? Two reasons, and you should hold both.

The one recursive fact that powers the whole lecture. Peel the first reward off the return and what remains is, term for term, γ times the return from the next step. So Gt = rt+1 + γ Gt+1. "This return = this reward + discounted next return." Memorize that line; it becomes the Bellman equation the moment we take an average over it.

Let's nail the recursion with a number. The corridor pays −1 per step and 0 at the dock. Starting at square A under "always go right," the rewards are −1, −1, −1, then 0 forever. With γ = 0.9:

G = −1 + 0.9(−1) + 0.9²(−1) + 0.9³(0) + …
G = −1 − 0.9 − 0.81 + 0 = −2.71

Hold onto that −2.71. It is the exact value of square A under the always-right policy, and we will rederive it three different ways in the chapters ahead — by the Bellman recursion, by iterative policy evaluation, and by value iteration — getting −2.71 every time. When three roads lead to the same number, you know you understand it.

Discount-factor explorer — how γ reshapes what matters

The bars are the discount weights γk for steps 0, 1, 2, … — how much a reward k steps away counts now. Slide γ: near 1 the future stays loud (a far-sighted robot); near 0 only the next step survives (a myopic one). The label shows the return of the corridor under "always right" at this γ.

Discount γ0.90
A robot uses γ = 0.5. A reward of +8 arrives 3 steps from now. How much does it contribute to today's return?

Chapter 2: Two Value Functions — V and Q

The return is a property of a single rolled-out future. But futures are random — the world transitions stochastically, the policy may pick actions stochastically. What we want is the expected return: the average over all the futures a given starting point could produce. That average has a name, two of them in fact, and the difference between them is one of the most useful distinctions in all of RL.

The state-value function V

The state-value function, written Vπ(s), is the expected return if you start in state s and then follow policy π forever. In words: "how good is it to be in this square, assuming I'll behave according to this plan from here on?" It is a single number per state — in our corridor, one number for each of A, B, C, D.

Vπ(s) = Eπ[ G0 | s0 = s ]

E means expected value (the average); the subscript π reminds us the average is taken over trajectories generated by following π. The bar reads "given that we start in s." So Vπ(s) is the average cost-to-go of square s under plan π.

The action-value function Q

The action-value function, written Qπ(s, a), asks a slightly richer question: "how good is it to be in state s, take the specific action a right now, and only then follow π forever after?" It scores a state paired with a first move.

Qπ(s, a) = Eπ[ G0 | s0 = s, a0 = a ]

Q carries strictly more information than V. From the same square you can imagine taking each possible action and see which first move pays off best — that is exactly what V cannot tell you, because V has already averaged the first action away under the policy.

Why we keep both. They are tied by a simple identity: the value of a state is the average of its action-values under the policy, Vπ(s) = ∑a π(a|s) Qπ(s, a). When Qπ(s, a) is greater than Vπ(s), it means action a is better than what the policy usually does here — a clue that we could improve the policy by switching to a. That single observation is the engine of policy improvement (Chapter 6). Hold it.

The optimal versions — and why Q* is the prize

Among all policies there is a best one, π*. Its value functions get a star: V*(s) is the most return any policy can squeeze out of state s, and Q*(s, a) is the most return achievable from s if you commit to first action a. They are linked the same way as before, but now with a max instead of an average over actions:

V*(s) = maxa Q*(s, a)     π*(s) = argmaxa Q*(s, a)

Read that second equation carefully, because it is the payoff of the whole distinction. If you know Q*, the optimal policy is free — just take the action with the largest Q* in each state. No model of the world needed; no looking ahead. That is why so much of RL chases Q directly (you'll see it in Lecture 8, Q-learning).

The asymmetry you must remember. Q* hands you the policy for nothing. V* does not — to act greedily from V* you must look one step ahead through the transition model: try each action, see where it lands, read off V* there, and pick the best. V* needs the dynamics to extract a policy; Q* does not. This is exactly why model-free methods prefer Q.

Let's make V and Q concrete on the exact slide example. In the corridor with no discount and a −1 step cost, the optimal values count the steps to the dock: V*(A)=−3, V*(B)=−2, V*(C)=−1, V*(D)=0. Now compare two action-values from A: Q*(A, right) = −1 + V*(B) = −3 (one step, then optimal from B), while Q*(A, stay) = −1 + V*(A) = −4 (waste a step, end up where you started). Since −3 > −4, π*(A) = right. The numbers decide the move.

V vs. Q on the corridor — click a square, compare its action-values

Optimal values (no discount, −1/step). Click a square to see V*(s) and the two action-values Q*(s, left), Q*(s, right). The winning action (larger Q) is highlighted — that's π*(s). Notice V*(s) always equals the max of its Q* values.

Click a square to inspect its V* and Q* values.
Why does knowing Q*(s, a) give you the optimal policy "for free," while knowing only V*(s) does not?

Chapter 3: The Bellman Equation, Derived

We have a recursive fact about returns (Chapter 1) and a definition of value as expected return (Chapter 2). Snap them together and you get the equation that organizes all of reinforcement learning. We'll derive it line by line — no step skipped.

Start from the definition of state-value and substitute the one-step recursion for the return:

Vπ(s) = Eπ[ G0 | s0 = s ] = Eπ[ r1 + γ G1 | s0 = s ]

The expected value of a sum is the sum of expected values, so we split it into "expected immediate reward" plus "γ times expected next return." Now we make the two random choices explicit. First the policy picks an action a with probability π(a|s); then the world transitions to s′ with probability p(s′|s, a). Averaging over both:

Vπ(s) = ∑a π(a|s) ∑s′ p(s′|s, a) [ r(s, a) + γ Vπ(s′) ]

This is the Bellman expectation equation. Decode each piece:

The crucial feature is the Vπ on both sides: the value of s is defined in terms of the values of its successors. It is the recursion "this value = this reward + discounted next value," now written out as a precise average. Because our gridworld is deterministic and the reward depends only on the state, the equation collapses to the friendly form we'll actually compute with:

Vπ(s) = r(s) + γ Vπ( next(s) )

where next(s) is the single square the policy sends you to. Let's check it against Chapter 1's number. Under "always right," V(C) = −1 + 0.9·V(D) = −1 + 0 = −1. Then V(B) = −1 + 0.9·V(C) = −1 − 0.9 = −1.9. Then V(A) = −1 + 0.9·V(B) = −1 + 0.9(−1.9) = −2.71. The same −2.71 as before — this time straight from the Bellman recursion.

The Q-version too. The same derivation for action-value gives Qπ(s, a) = ∑s′ p(s′|s, a) [ r(s, a) + γ Vπ(s′) ]. Read it as "the reward for taking a now, plus the discounted value of where a lands me, then following π." V and Q are two faces of the same recursion.

The optimality version — replace the average with a max

The Bellman expectation equation evaluates a fixed policy. To describe the best policy we make one surgical change: instead of averaging over the policy's actions, we take the action that maximizes. This gives the Bellman optimality equation:

V*(s) = maxas′ p(s′|s, a) [ r(s, a) + γ V*(s′) ]
Q*(s, a) = ∑s′ p(s′|s, a) [ r(s, a) + γ maxa′ Q*(s′, a′) ]

The principle behind the max has a name — the principle of optimality: an optimal policy, from any state it reaches, must still be optimal for the rest of the journey. There is no "I'll be sloppy now and brilliant later." Optimal behavior is optimal all the way down, which is exactly why the recursion is allowed to call itself with a max at every step.

Linear vs. nonlinear — the difference that splits the lecture in two. The expectation equation is linear in V (it's a weighted average), so for a fixed policy you can solve it exactly, even with a matrix inverse. The optimality equation has a max, which is nonlinear — no clean inverse exists. That single max is why we need iterative algorithms (value iteration, policy iteration) instead of one-shot algebra. Keep this fork in mind: average → solvable, max → iterate.

Backup diagram — one step of the Bellman recursion

Toggle between the expectation backup (average over the policy's actions) and the optimality backup (pick the best action). Watch how the value of the top node is assembled from its successors' values — this single picture is the Bellman equation.

Expectation: value = average of action-values under π.
What is the single structural difference between the Bellman expectation equation and the Bellman optimality equation, and why does it matter?

Chapter 4: Policy Evaluation — Scoring a Fixed Plan

Here is the first concrete algorithm. Policy evaluation answers exactly one question: given a fixed policy π (which may be terrible), what is Vπ(s) for every state? In words — how good is this plan, square by square?

We have two routes to the answer, and seeing both is worth it.

Route 1 — solve the linear system exactly

For a tabular MDP, the Bellman expectation equation is one linear equation per state, all coupled. Stack the values into a vector and the equation becomes a single matrix line:

Vπ = r + γ Tπ Vπ

Here Vπ is the vector of state-values, r is the vector of rewards, and Tπ is the transition matrix under the policy — entry (j, k) is the probability of going from state j to state k when you act according to π. Solve algebraically:

Vπ = (I − γ Tπ)−1 r

This is exact and beautiful, but inverting a matrix is expensive when there are many states, and it only works because the equation is linear (no max). So in practice we usually take the second route.

Route 2 — iterate the recursion until it stops moving

Treat the Bellman equation as an update rule. Start from any guess (zeros are fine), and repeatedly replace each value with the right-hand side computed from the current values:

Vk+1(s) ← r(s) + γ Vk( next(s) )   for every state s

One pass over all states is a sweep. Keep sweeping; the values march toward Vπ and freeze. Chapter 5 explains why this is guaranteed. First, let's grind a full example by hand so the mechanics are concrete.

A worked policy-evaluation sweep, by hand

Corridor A·B·C·D, γ = 0.9, reward −1 per non-goal square and 0 at the dock D. The policy under evaluation is "always go right", so next(A)=B, next(B)=C, next(C)=D, and D is absorbing. We initialize every value to 0.

SweepV(A)V(B)V(C)V(D)
0 (init)0000
1−1.00−1.00−1.000
2−1.90−1.90−1.000
3−2.71−1.90−1.000
4 — frozen−2.71−1.90−1.000

Let's verify the arithmetic of sweep 2, square A: V2(A) = r(A) + γ·V1(B) = −1 + 0.9×(−1) = −1.90. And sweep 3, square A: V3(A) = −1 + 0.9×V2(B) = −1 + 0.9×(−1.90) = −1 − 1.71 = −2.71. There it is a third time — the same −2.71 we got from the geometric series and from the closed-form recursion. The values stop changing after sweep 3 because the corridor is only three squares deep, so the goal's pull needs exactly three sweeps to reach A.

Notice the wavefront. Square C is correct after one sweep (it touches the dock), B after two, A after three. Information about the goal propagates backward exactly one square per sweep — the same "creep" you watched in Chapter 0's animation. That is the signature of a one-step backup.

Now let's build the iteration in code. You'll supply the single line that is the whole Bellman update — the matrix form V ← r + γTV — and prove the result satisfies the Bellman equation to machine precision.

In the starter code, the placeholder sets Vnew = r instead of r + gamma*(P@V). What goes wrong, and why?

Chapter 5: Why It Converges — The Contraction

We have been iterating a recursion and trusting it to settle. Why should it? Why is (I − γ Tπ) even invertible? The answer is a single, gorgeous idea that underwrites every dynamic-programming method in this lecture: the Bellman update is a contraction.

An operator F — a rule that takes a value vector and returns a new one — is a γ-contraction if applying it to any two vectors shrinks the gap between them by at least a factor γ:

∥ F(x) − F(y) ∥ ≤ γ ∥ x − y ∥   for all x, y

The double bars are the max-norm — the largest absolute difference across all the entries. The statement says: whatever the biggest disagreement between two value guesses is, one Bellman update multiplies it by at most γ.

Why is the Bellman operator Fπ(V) = r + γ Tπ V a contraction? Take two guesses x and y. Subtract: F(x) − F(y) = γ Tπ(x − y) — the rewards cancel. Tπ is a stochastic matrix (its rows are probabilities that sum to 1), and averaging can never amplify the largest entry. So the new gap is at most γ times the old gap. The γ out front is the entire reason it shrinks.

The Banach fixed-point theorem, in one breath. If an operator shrinks all distances by a constant factor < 1, then (1) it has exactly one fixed point, and (2) iterating it from any starting guess converges to that fixed point — at a geometric rate γk. So policy evaluation has a unique answer Vπ, and our sweeps are guaranteed to find it, fast. The error after k sweeps is at most γk times the initial error.

"Geometric rate γk" is worth feeling. With γ = 0.9, every ten sweeps cut the error by roughly a factor of e (since 0.910 ≈ 0.35); with γ = 0.99 it's far slower. The discount factor that makes the robot far-sighted is the same factor that decides how quickly our algorithms converge — a tax on patience.

And this is why (I − γ Tπ) is invertible: a contraction's fixed-point equation V = r + γ Tπ V has a unique solution, so the matrix can't be singular. The same single fact — contraction — guarantees the linear solve, the iterative sweep, and (with the max swapped in) value iteration too.

Contraction in action — two guesses pulled together

Two different starting value-guesses (warm and blue) for square A, both iterated with the Bellman backup. Watch them collapse onto the same fixed point — and onto each other. Slide γ: smaller γ pulls them together faster (steeper geometric decay).

Discount γ0.90
Two guesses, same fixed point.
The Bellman operator is a γ-contraction in the max-norm. What does this guarantee about iterative policy evaluation?

Chapter 6: Policy Improvement — Acting Greedily

Policy evaluation tells us how good a plan is. But we want a better plan. Here is the move that improves it, and it is almost embarrassingly simple.

Suppose we have evaluated policy π and know its action-values Qπ(s, a). Define a new policy π′ that, in each state, picks the action with the highest Qπ — it acts greedily with respect to the old policy's Q:

π′(s) = argmaxa Qπ(s, a)

In words: "for one step, do the thing that looked best according to the old plan's own scoring; then revert to the old plan." It seems too cheap to work. Does it?

The policy improvement theorem. If π′ is greedy with respect to Qπ, then Vπ′(s) ≥ Vπ(s) for every state s. The greedy policy is never worse, and usually strictly better, than the one it was built from. A one-step look at "what's best by my current estimate" provably raises the whole value function.

The intuition behind the proof: at the first step, π′ takes an action whose Qπ is at least as high as what π would have done — so the value of that first step doesn't drop. But after that step we're following π again, and the same argument applies recursively at the next state, and the next. Each step is at least as good, so the whole trajectory is at least as good. The improvements stack down the chain.

A worked improvement step, by hand

Take a deliberately bad starting policy on the corridor: π₀ = "always go left." Under always-left, square A loops on itself forever (left from A stays at A), paying −1 every step. We evaluate it (Chapter 4) and find every transient square is a trap worth Vπ₀ = −10 — that's the geometric sum −1/(1 − 0.9) of paying −1 forever with γ = 0.9.

Now improve. At square C, compare the two action-values using Vπ₀:

Q(C, right) = −1 + 0.9·Vπ₀(D) = −1 + 0.9·0 = −1
Q(C, left) = −1 + 0.9·Vπ₀(B) = −1 + 0.9·(−10) = −10

Since −1 > −10, the greedy policy flips C to right. The same comparison flips B and A to right as well, because reaching the dock (value 0) beats wandering deeper into the −10 trap. One improvement step turns the worst policy into the best one. That is the leverage greedy improvement gives you.

When does improvement stop?

Improvement keeps producing strictly better policies — until it can't. The moment greedy gives you back the same policy you started with (the argmax doesn't change anything), you have a policy that is greedy with respect to its own value. Stare at that condition and you'll see it is the Bellman optimality equation: Vπ(s) = maxa Qπ(s, a) for all s. A fixed point of improvement is exactly an optimal policy.

The hinge of the whole lecture. "Greedy policy = same policy"  ⇔  "Bellman optimality holds"  ⇔  "policy is optimal." Three statements, one truth. This equivalence is why alternating evaluate-and-improve must terminate at π* — the only place it can stop is the optimum.

Greedy improvement — click a square, watch the arrow flip

The corridor under the bad policy "always left" (its values Vπ₀ are shown). Click a square to compute Q(s, left) vs Q(s, right) from those values; the greedy choice (larger Q) is highlighted, and the policy arrow flips to it. Every square wants to flip toward the dock.

Click a square to see greedy improvement decide its action.
When does greedy policy improvement stop producing a different (better) policy?

Chapter 7: Policy Iteration — Evaluate, Improve, Repeat

We now have both halves. Policy iteration simply alternates them until the policy stops changing:

Start
Pick any policy π₀ (random is fine).
Policy Evaluation
Compute Vπ for the current policy (Chapter 4) — "how good is this plan?"
Policy Improvement
Set π ← greedy w.r.t. Qπ (Chapter 6) — "do the best move by current estimate."
↻ if the policy changed, go evaluate again; if not, STOP — it's π*

Each loop produces a policy that is provably at least as good as the last (improvement theorem), and there are only finitely many deterministic policies in a tabular MDP, so the sequence cannot improve forever — it must hit a policy that no longer changes. That fixed point is, by Chapter 6's equivalence, the optimal policy. Policy iteration is therefore guaranteed to terminate at π*, usually in remarkably few iterations.

General policy iteration. You don't have to evaluate to convergence before improving — any interleaving of partial evaluation and improvement still climbs to the optimum. Sutton & Barto call this generalized policy iteration, and they make a striking claim: essentially every RL method — Q-learning, actor-critic, the lot — is some flavor of "make the value consistent with the policy, make the policy greedy w.r.t. the value, repeat." You are looking at the skeleton of the whole field.

A full policy-iteration run, by hand

On a 3-square corridor A·B·C (C = dock, γ = 0.9), start from the worst policy π₀ = "always left":

From the worst possible plan to the optimum in a single improvement step. Now build the loop and prove it lands on the same optimum value iteration would — and in just a handful of iterations.

Why is policy iteration guaranteed to terminate at the optimal policy?

Chapter 8: Value Iteration — Fold Improvement Into the Backup

Policy iteration has a hidden cost: every round runs a full policy evaluation to convergence before it improves even once. That's a lot of sweeps just to score a policy we're about to throw away. Value iteration asks: can we skip the inner loop entirely?

Yes. The insight is to apply the Bellman optimality backup directly — the one with the max baked in — instead of evaluating then improving as separate phases. One update per state, with the max folded in:

Vk+1(s) ← maxas′ p(s′|s, a) [ r(s, a) + γ Vk(s′) ]

Compare it to policy evaluation's backup from Chapter 4. The only change is the maxa out front: instead of following a fixed policy's action, each sweep picks the best action on the fly. Improvement and evaluation have merged into a single line. You never store a policy during the loop — only values. When the values stop changing they equal V*, and the optimal policy falls out by one greedy read at the end.

Same destination, different road. Policy iteration and value iteration both converge to the same fixed point V* — they solve the same Bellman optimality equation. Policy iteration takes big steps (full evaluation, then a leap of improvement); value iteration takes many small steps (one greedy backup at a time). The optimality backup is itself a γ-contraction, so value iteration converges for exactly the same reason policy evaluation did (Chapter 5).

A worked value-iteration sweep, by hand

Corridor A·B·C·D, γ = 0.9, two actions. Start all values at 0. Here is the optimality backup at each square for the first two sweeps. Recall right sends A→B, B→C, C→D; left sends A→A, B→A, C→B.

Sweep 1 (all V₀ = 0, so both actions tie at the reward):

V1(C) = max( −1 + 0.9·0, −1 + 0.9·0 ) = −1

Same for A and B — sweep 1 gives V1 = (−1, −1, −1, 0).

Sweep 2 (now the future is non-zero, so the max starts to matter):

V2(A) = max( −1 + 0.9·V1(B),   −1 + 0.9·V1(A) ) = max(−1.9, −1.9) = −1.9
V2(C) = max( −1 + 0.9·V1(D),   −1 + 0.9·V1(B) ) = max(−1, −1.9) = −1

By sweep 3 the wavefront reaches A and it settles at −2.71 — the fourth time we've landed on that number. The full table:

SweepV(A)V(B)V(C)V(D)
00000
1−1.00−1.00−1.000
2−1.90−1.90−1.000
3 — frozen−2.71−1.90−1.000

Greedy read-out at the end: at C, Q(right) = −1 > Q(left) = −2.71, so π*(C) = right; the same holds at B and A. The optimal policy is "always right," exactly as policy iteration found — same answer, fewer phases. Now implement the backup and extract the policy.

Policy iterationValue iteration
Inner loopFull policy evaluation each roundNone — one max-backup per sweep
Per round costExpensive (many sweeps to evaluate)Cheap (single sweep)
Rounds to convergeFew (big improvement leaps)More (small steps)
Stores a policy mid-run?YesNo — only values; policy read off at the end
Fixed point reachedV*, π*V*, π* (same!)
What is the single difference between the value-iteration backup and the policy-evaluation backup?

Chapter 9: Connections — Where This Spine Goes Next

You now own the recursive heart of reinforcement learning. Every state has a value; that value is its reward plus the discounted value of where you land; solving that recursion — by averaging for a fixed policy, by maxing for the optimum — hands you the best behavior. Two algorithms realize it, and both are guaranteed to converge because the Bellman backup is a contraction.

Cheat sheet — the vocabulary you now own.
  • Return Gt = discounted sum of future rewards; Gt = rt+1 + γ Gt+1 — the recursion that starts everything.
  • Vπ(s) = expected return from s under π. Qπ(s, a) = same, but commit to action a first. Q gives the policy for free; V needs the model to look ahead.
  • Bellman expectation: Vπ(s) = average over actions of [reward + γ·next value]. Linear → solvable.
  • Bellman optimality: V*(s) = max over actions of [reward + γ·next value]. Nonlinear → iterate.
  • Policy evaluation = iterate the expectation backup until Vπ freezes. Policy improvement = act greedy w.r.t. Qπ; provably never worse.
  • Policy iteration = evaluate ↔ improve until the policy stops changing. Value iteration = the optimality backup, improvement folded into the update.
  • Contraction = each backup shrinks the error by γ: unique fixed point, geometric convergence γk. Same answer V*, π* from both algorithms.

The honest caveats

Everything here assumed two luxuries the rest of the course spends its time removing:

Where to go next on this site

This lesson is the foundation of the model-free RL strand of 16-831. Continue and deepen:

The test of this lesson. Open the original Lecture 7 slides. You should now be able to derive, from memory: the Bellman expectation equation from the return recursion; the optimality equation by swapping the average for a max; why the operator is a contraction and therefore converges; and a full hand-worked policy-evaluation sweep, value-iteration sweep, and policy-iteration run on a corridor — all landing on −2.71. If you can, you're ready for Q-learning.

"The value of a state is the reward you get now, plus the discounted value of where you'll be next. Everything else is bookkeeping."