5.1.9 · D5Reinforcement Learning Foundations

Question bank — Dynamic programming (value - policy iteration)

1,642 words7 min readBack to topic

This is a conceptual stress-test for dynamic programming. No heavy arithmetic here — every item targets a place where intuition quietly goes wrong: a sign, a max-vs-average, a "does this need a model?", a degenerate MDP. Cover the reasoning, not just the label.

Before you start, three words we will lean on constantly, defined in plain language:

Keep the Bellman equations and the contraction mapping idea in mind — most traps below are really about one of those two.


True or false — justify

Value iteration needs the transition probabilities to run.
True. Both DP algorithms are model-based: the sum literally requires knowing where each action lands you. Dropping the model is exactly what pushes you toward Q-learning and TD learning.
Policy iteration always takes more total computation than value iteration.
False. Policy iteration needs fewer outer iterations (it converges in a finite number of policy changes), but each one runs a full policy evaluation to convergence — so cost per iteration is higher. Which wins depends on the MDP; neither dominates universally.
If , the Bellman update is still guaranteed to converge.
False in general. The convergence guarantee comes from the update being a -contraction; at the contraction factor is 1, so it may not shrink errors. It can still work if the MDP is episodic (guaranteed to reach a terminal state), which caps the return.
Value iteration is just policy iteration with the policy-evaluation step cut down to a single sweep.
True. Value iteration = "improve after one backup instead of after full convergence." That single sweep with a inside is a truncated evaluation fused with improvement.
Once policy iteration returns a policy that doesn't change, that policy might still be suboptimal.
False. If after greedy improvement, then is greedy w.r.t. its own value function, which is exactly the Bellman optimality condition — so is optimal.
Two different optimal policies must have different optimal value functions.
False. is unique, but many policies can achieve it (e.g. two actions tied for best in a state). Different arrows, same goodness scores.
The Bellman optimality equation is linear in .
False. The makes it non-linear (piecewise). The Bellman expectation equation (fixed policy, no max) is linear and can be solved directly by matrix inversion.
Adding a constant to every reward leaves the optimal policy unchanged.
True for the policy, false for the values. Every state's value shifts by (a state-independent constant), so the ranking of actions — and hence the argmax — is untouched.

Spot the error

"."
Error: there is an extra that doesn't belong. is already a maximised value; the only is the outer one over the current action . The inner term is just .
"Policy improvement uses , so it needs the optimal ."
Error: it uses of the current policy, not . Being greedy w.r.t. the current (imperfect) values is enough to guarantee a not-worse policy — that's the whole point of the improvement theorem.
"" — expectation equation with a max in it.
Error: the expectation equation averages over actions with weights ; there is no . Mixing in a turns it into the optimality equation for a different (greedy) policy.
"Since rewards are per step, values must be negative, so is fine."
Error: with per-step reward and no positive reward anywhere, every non-terminal value is negative. A positive value is impossible; should be around , not .
"We can extract the greedy policy from without the model, since we already have ."
Error: turning into a policy needs — that one-step look-ahead uses . alone isn't enough; that's why model-free methods learn instead.
"In value iteration we must keep an explicit policy updated every sweep."
Error: value iteration keeps no explicit policy during iteration. The implicitly picks the best action; you only extract once, at the end.
"The discount is there to make rewards smaller for no real reason."
Error: does two real jobs — it models preference for sooner rewards, and it guarantees the return is a finite number and the Bellman operator is a contraction, which is what makes DP converge at all.

Why questions

Why does the Bellman expectation update converge to a unique answer?
Because the update is a -contraction: each sweep multiplies the worst-case error by , so errors shrink geometrically toward a single fixed point .
Why does value iteration use where policy evaluation uses ?
Value iteration is chasing , and an optimal agent always picks the single best action — so we maximise. Policy evaluation is scoring a given (possibly stochastic) policy, so we average with that policy's own probabilities.
Why is DP called "dynamic programming" if there's nothing dynamic about the code?
"Programming" here means tabular planning (Bellman's 1950s usage), and "dynamic" refers to the sequential, multi-stage structure — solving small subproblems (one step from the goal) and reusing them for larger ones.
Why does policy iteration converge in finitely many steps but value iteration only in the limit?
Policy iteration walks through a finite set of deterministic policies, each strictly better than the last, so it must stop. Value iteration refines a continuous-valued by a factor each sweep, which approaches but reaches it exactly only as sweeps .
Why do we discount future rewards by and not by a fixed subtraction?
A multiplicative keeps the infinite sum finite (geometric series) and makes the "value tomorrow" telescope cleanly into the recursion; a fixed subtraction would let the sum diverge and would break the one-step recursion.
Why can policy improvement never make the policy worse?
The policy improvement theorem: acting greedily for one step and then following the old policy already scores everywhere; iterating that guarantee across all states shows pointwise.
Why does understanding DP matter if it needs a perfect model we rarely have?
DP is the definition of correct that model-free methods approximate — Q-learning, SARSA, and policy gradients are all "DP without the model," so its equations tell you what those samplers are secretly estimating.

Edge cases

What is at a terminal state?
Zero (by convention): no future rewards can be collected from a terminal state, so its backup contributes nothing and it anchors the recursion for every other state.
What happens if two actions have exactly equal -values in a state?
Any tie-breaking rule is valid — both are optimal. This is why can be non-unique even though is unique; pick either arrow.
What does value iteration do in a state where every action leads back to the same state with the same reward (a self-loop trap)?
The backup becomes , giving — a well-defined value only because ; at it would blow up (or stay undefined) for negative .
What if the initial value function is chosen adversarially, say huge and wrong?
It still converges. The contraction shrinks any starting error by per sweep, so the fixed point is reached regardless of — a bad start only costs extra sweeps.
What if a policy assigns zero probability to the optimal action in some state?
Policy evaluation faithfully scores that suboptimal policy (its is genuinely lower there), and the very next improvement step will shift probability onto the better action — that's the mechanism that escapes bad policies.
What happens in an MDP with unreachable states?
Their values are still computed and are internally consistent, but they never influence the reachable part of the world; the optimal policy over reachable states is unaffected by them.
If , what does the optimal policy become?
Purely greedy on immediate reward: with the backup is just , so the agent ignores all future consequences and grabs the best one-step reward — myopic but still well-defined.
Recall Quick self-check

The extra in the optimality equation belongs to which action? ::: The current action only; is already maximised. DP needs which piece of information that model-free RL does without? ::: The transition/reward model . What single property guarantees DP converges? ::: The Bellman operator is a -contraction.