This Reinforcement Learning concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.
Reinforcement Learning
Policy Iteration
Policy iteration alternates fixed-policy value evaluation with greedy policy improvement until the policy stops changing.
Concept Structure
Policy Iteration
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learner Contract
What this page should let you do.
1 prerequisite listed; refresh them before leaning on the math or code.
Explain the mechanism, trace the main notation, and test one prediction in the live demo.
Read the intuition before the notation; the math should name a mechanism you already felt.
Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.
Claim/source review status
Substantive review recorded
1/1 claims have bounded review metadata; still check caveats and source scope.Metadata-derived; review may be AI-assisted. Not a human certification.01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
Value iteration asks, "What if every state greedily improves its value estimate on every sweep?"
Policy iteration slows that down on purpose. It asks:
- If we commit to this policy, what is it actually worth?
- After seeing those values, which actions would a one-step lookahead choose instead?
That separation is the whole idea. During policy evaluation, the policy is frozen. We do not ask whether another action is better yet. We only compute the value function for the policy we already have.
During policy improvement, the values are frozen. We compare all available action rows using as the future-value table, then replace the policy by a greedy one.
This is why policy iteration is such a clean control algorithm. It turns control into a loop of prediction and improvement:
In a finite discounted tabular MDP, this loop cannot keep producing strictly new deterministic policies forever. When the greedy improvement step leaves the policy unchanged, the Bellman optimality condition has been reached.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Let be a finite discounted MDP with known transition model , reward , and .
For a fixed policy , policy evaluation computes the state-value function
For a deterministic policy, this reduces to the action chosen by the policy:
Once has been evaluated, define the one-step lookahead action value
Policy improvement chooses a greedy action with respect to that evaluated value function:
The policy improvement theorem says that the greedy policy is at least as good as the policy it was built from. If the greedy policy equals the old policy in every state, then the policy already satisfies the Bellman optimality equation:
So policy iteration is not "value iteration with a different name." Value iteration repeatedly applies the Bellman optimality backup to values. Policy iteration alternates an evaluation problem for a fixed policy with a greedy improvement problem for the policy.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
states = ["Start", "Practice", "Confused", "Mastered"]
gamma = 0.90
P = {
"Start": {"drill": [("Practice", .62, 1.0), ("Confused", .23, -.5), ("Mastered", .15, 3.0)],
"skim": [("Start", .30, .1), ("Practice", .45, .5), ("Confused", .25, -.2)]},
"Practice": {"repeat": [("Mastered", .55, 2.0), ("Practice", .30, .4), ("Confused", .15, -.6)],
"reflect": [("Mastered", .35, 1.2), ("Practice", .55, .5), ("Start", .10, 0.0)]},
"Confused": {"ask": [("Practice", .65, .7), ("Confused", .25, -.4), ("Start", .10, 0.0)],
"guess": [("Mastered", .20, 1.6), ("Confused", .50, -.8), ("Start", .30, -.1)]},
"Mastered": {"done": [("Mastered", 1.0, 0.0)]},
}
def q_value(V, s, a):
return sum(p * (r + gamma * V[sp]) for sp, p, r in P[s][a])
def evaluate(pi, theta=1e-10):
V = dict.fromkeys(states, 0.0)
while True:
old = V.copy()
for s in states:
V[s] = q_value(old, s, pi[s])
if max(abs(V[s] - old[s]) for s in states) < theta:
return V
pi = {"Start": "drill", "Practice": "reflect", "Confused": "guess", "Mastered": "done"}
for i in range(3):
V = evaluate(pi)
improved = {s: max(P[s], key=lambda a: q_value(V, s, a)) for s in states}
print(i, {s: round(V[s], 3) for s in states}, "changes", [s for s in states if pi[s] != improved[s]])
if improved == pi:
break
pi = improved
The policy is fixed inside evaluate. Only after evaluation do we compute the greedy action rows and decide whether the policy changes.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Use the Policy Iteration Improvement Lab to predict a greedy improvement step.
Choose an iteration, inspect the current fixed policy, then predict what changes after evaluating that policy and improving greedily with respect to . After reveal, compare the evaluated values, the old action row, the best action row, and the policy-stability verdict.
Before reveal, the evaluated values and greedy actions stay locked. That is the learning move: keep evaluation and improvement mentally separate before the table gives away the answer.
Live Concept Demo
Explore Policy Iteration
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Commit to what Policy Iteration should make visible before reading the result.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
Mechanism Storyboard
See the idea move before the page explains it
Policy iteration alternates fixed-policy value evaluation with greedy policy improvement until the policy stops changing.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Policy Iteration should make visible.
Visual Inquiry
Make the image answer a mathematical question
Policy iteration alternates fixed-policy value evaluation with greedy policy improvement until the policy stops changing.
Which visible object should carry the first intuition?
Pick the cue that should make Policy Iteration easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
Canonical source for policy evaluation, policy improvement, the policy improvement theorem, and finite-MDP policy iteration.
Open sourceGraduate RL source for iterative policy evaluation, policy improvement from Q^pi, and the policy-iteration loop.
Open sourceOpen textbook source for policy-evaluation updates in tabular reinforcement learning.
Open sourceClaim Review
Policy iteration alternates fixed-policy value evaluation with greedy policy improvement until the policy stops changing.
Claims without a substantive review badge still need exact source-support review.
sutton-barto-2018-rl, stanford-cs234-policy-iteration, d2l-policy-evaluation
Use equations, runnable code, and demos to check whether the source support is operational.
The sources support the evaluate-then-improve decomposition: compute V^pi for the current fixed policy, compute Q^pi(s,a) by one-step lookahead through the known model, set the next policy greedily with respect to those Q values, and stop when the policy is unchanged.
Sources: Reinforcement Learning: An Introduction, Second Edition, Stanford CS234: Lecture 2, Making Sequences of Good Decisions Given a Model of the World, Dive into Deep Learning: Value IterationFinite discounted tabular teaching MDP only; excludes modified policy iteration, approximate evaluation, generalized policy iteration under function approximation, continuous state/action spaces, exploration, and sample-based learning.A bounded review summary is present; still check caveats and exact reference scope.Checked Sutton/Barto Chapter 4 for policy evaluation, the policy improvement theorem, policy iteration, and finite-MDP convergence; checked Stanford CS234 Lecture 2 for iterative policy evaluation, the policy-iteration loop, and greedy improvement from Q^pi; checked D2L for the fixed-policy evaluation update. GPT Pro publication critique remains pending because 127.0.0.1:51672 is unavailable.
Reviewer: codex-local-source-review; reviewed 2026-07-03Source support candidates
book 2018Reinforcement Learning: An Introduction, Second EditionCanonical source for policy evaluation, policy improvement, the policy improvement theorem, and finite-MDP policy iteration.
course-notes 2026Stanford CS234: Lecture 2, Making Sequences of Good Decisions Given a Model of the WorldGraduate RL source for iterative policy evaluation, policy improvement from Q^pi, and the policy-iteration loop.
book 2026Dive into Deep Learning: Value IterationOpen textbook source for policy-evaluation updates in tabular reinforcement learning.
Practice Loop
Try the idea before it explains itself
Policy iteration alternates fixed-policy value evaluation with greedy policy improvement until the policy stops changing.
Before touching the demo, predict one visible change that should happen in Policy Iteration.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
Research Room
Attach the question to a claim, equation, code, or demo
Pick the concept, equation, source, runnable code, claim, misconception, or demo state before asking for help. The handoff keeps that page item in context.Open the draft below to save one note and next action in this browser.
Policy Iteration
What is the smallest example that makes Policy Iteration click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays in this browser, attached to the selected learning item.
- References to inspect: attached references on this page.
- Definition, prerequisite, and contrast concept links
- The equation or runnable code that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - Policy Iteration Selected item key: recorded for copy. Context: Reinforcement Learning Page anchor: recorded for copy. Open question: What is the smallest example that makes Policy Iteration click without losing the math? Evidence to inspect: - References to inspect: attached references on this page. - Definition, prerequisite, and contrast concept links - The equation or runnable code that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.
concept/concept-notebook/reinforcement-learning/policy-iteration
concept:reinforcement-learning/policy-iteration