Simple Algorithm
Reinforcement Learning · Fixed Point · 26 min

Error Bounds & Stopping Rules

From the size of the last update to a guarantee on the greedy policy.

Value iteration's values converge only in the limit, yet you act with a policy, and you have to stop somewhere. Everything computable while sweeping, the last change, the smallest and the largest change, turns into a guarantee. This lesson proves the classic ones: a Bellman-residual bound that is tight to the constant, MacQueen's monotone bounds that certify an optimal policy in the two-state world after 4 backups, while the standard rule needs 36 just to guarantee a loss below 1, a test that discards actions for good, and how many sweeps pass before the greedy policy is exactly optimal.

What you’ll learn

  • Prove that a policy greedy for any VV loses at most 2γε/(1−γ)2\gamma\varepsilon/(1-\gamma), where ε\varepsilon is the Bellman residual of VV, and show that the constant cannot be improved.
  • Derive MacQueen's lower and upper bounds on V⋆V^\star from two successive iterates, and the span-based stopping rule they give.
  • Use the bounds to eliminate suboptimal actions permanently.
  • Bound the number of sweeps until the greedy policy is exactly optimal through the action gap, and state what is known about the complexity of value iteration.

What the Bellman residual guarantees

Three distances matter: the error of the values, ∥V−V⋆∥∞\norm{V-V^\star}_\infty; the loss of the policy you act with, ∥V⋆−Vπ∥∞\norm{V^\star-V^\pi}_\infty; and the Bellman residual ∥T⋆V−V∥∞\norm{\mathcal T^\star V-V}_\infty. Only the last can be computed without knowing V⋆V^\star, and value iteration gets it for free: the residual of VkV_k is the last change, δk=∥Vk+1−Vk∥∞\delta_k=\norm{V_{k+1}-V_k}_\infty. The theorem turns it into a guarantee about the greedy policy.

DerivationProof of the residual bound
  1. ∥V⋆−V∥∞≤γ∥V⋆−V∥∞+ε,∥Vπ−V∥∞≤γ∥Vπ−V∥∞+ε⟹both≤ε1−γ\norm{V^\star-V}_\infty\le\gamma\norm{V^\star-V}_\infty+\varepsilon,\qquad\norm{V^\pi-V}_\infty\le\gamma\norm{V^\pi-V}_\infty+\varepsilon\quad\Longrightarrow\quad\text{both}\le\frac{\varepsilon}{1-\gamma}

    Both value functions are near VV. Write V⋆−V=(T⋆V⋆−T⋆V)+(T⋆V−V)V^\star-V=(\mathcal T^\star V^\star-\mathcal T^\star V)+(\mathcal T^\star V-V) and Vπ−V=(TπVπ−TπV)+(TπV−V)V^\pi-V=(\mathcal T^\pi V^\pi-\mathcal T^\pi V)+(\mathcal T^\pi V-V), where TπV−V=T⋆V−V\mathcal T^\pi V-V=\mathcal T^\star V-V by greediness. Each first term is at most γ\gamma times the distance being bounded:

  2. V⋆−Vπ=Tπ⋆V⋆−Tπ⋆V⏟γPπ⋆(V⋆−V)+Tπ⋆V−TπV⏟≤ 0 (greedy)+TπV−TπVπ⏟γPπ(V−Vπ)V^\star-V^\pi=\underbrace{\mathcal T^{\pi^\star}V^\star-\mathcal T^{\pi^\star}V}_{\gamma P^{\pi^\star}(V^\star-V)}+\underbrace{\mathcal T^{\pi^\star}V-\mathcal T^\pi V}_{\le\,0\ \text{(greedy)}}+\underbrace{\mathcal T^\pi V-\mathcal T^\pi V^\pi}_{\gamma P^\pi(V-V^\pi)}

    Split the loss with one-step operators. The triangle inequality alone would give 2ε/(1−γ)2\varepsilon/(1-\gamma). To earn the factor γ\gamma, use V⋆=Tπ⋆V⋆V^\star=\mathcal T^{\pi^\star}V^\star for an optimal π⋆\pi^\star and Vπ=TπVπV^\pi=\mathcal T^\pi V^\pi, and add and subtract Tπ⋆V\mathcal T^{\pi^\star}V and TπV\mathcal T^\pi V:

  3. 0≤V⋆−Vπ≤γε1−γ+γε1−γ=2γε1−γ0\le V^\star-V^\pi\le\frac{\gamma\varepsilon}{1-\gamma}+\frac{\gamma\varepsilon}{1-\gamma}=\frac{2\gamma\varepsilon}{1-\gamma}

    The outer terms are γ\gamma times averages of vectors bounded in step 1, and the middle term is nonpositive because π\pi maximizes the lookahead under VV. Since V⋆≥VπV^\star\ge V^\pi:

Which policy does value iteration certify? Apply the theorem to two tables. The actions used by backup k+1k+1 are greedy for VkV_k, whose residual is δk\delta_k, so they lose at most 2γδk/(1−γ)2\gamma\delta_k/(1-\gamma). The greedy policy for Vk+1V_{k+1} does better: the residual of Vk+1V_{k+1} is ∥T⋆Vk+1−T⋆Vk∥∞≤γδk\norm{\mathcal T^\star V_{k+1}-\mathcal T^\star V_k}_\infty\le\gamma\delta_k, so it loses at most 2γ2δk/(1−γ)2\gamma^2\delta_k/(1-\gamma). The classic rule δk<ε(1−γ)/(2γ)\delta_k<\varepsilon(1-\gamma)/(2\gamma) therefore certifies both policies, the newer one with loss below γε\gamma\varepsilon.

Check your understanding

Value iteration with γ=0.9\gamma=0.9 reports a last change δk=0.05\delta_k=0.05. What is guaranteed about the policy greedy for VkV_k, the one the last backup used?

  1. It loses at most 0.05
  2. It loses at most 0.45
  3. It loses at most 0.9
  4. It loses at most 0.81
Show the answer

C. It loses at most 0.9

Its residual is δk=0.05\delta_k=0.05, so its loss is at most 2γδk/(1−γ)=2×0.9×0.05/0.1=0.92\gamma\delta_k/(1-\gamma)=2\times0.9\times0.05/0.1=0.9. The policy greedy for the newer table Vk+1V_{k+1} has residual at most γδk\gamma\delta_k, hence the smaller bound 0.810.81.

Monotone bounds from two iterates

The residual bound uses only the largest change. MacQueen (1966) noticed that the smallest change carries information too. Let mk=min⁡s(Vk+1−Vk)(s)m_k=\min_s(V_{k+1}-V_k)(s) and Mk=max⁡s(Vk+1−Vk)(s)M_k=\max_s(V_{k+1}-V_k)(s), and write sp⁡(x)=max⁡sx(s)−min⁡sx(s)\operatorname{sp}(x)=\max_sx(s)-\min_sx(s) for the span of a vector.

DerivationProof
  1. V⋆−Vk+1=∑j≥1(Vk+j+1−Vk+j)≤∑j≥1γjMk1=γMk1−γ1V^\star-V_{k+1}=\sum_{j\ge1}\big(V_{k+j+1}-V_{k+j}\big)\le\sum_{j\ge1}\gamma^jM_k\mathbf 1=\frac{\gamma M_k}{1-\gamma}\mathbf 1

    T⋆\mathcal T^\star is monotone (V≤UV\le U implies T⋆V≤T⋆U\mathcal T^\star V\le\mathcal T^\star U) and shifts constants, T⋆(V+c1)=T⋆V+γc1\mathcal T^\star(V+c\mathbf 1)=\mathcal T^\star V+\gamma c\mathbf 1. So Vk+1≤Vk+Mk1V_{k+1}\le V_k+M_k\mathbf 1 gives Vk+2≤Vk+1+γMk1V_{k+2}\le V_{k+1}+\gamma M_k\mathbf 1, and by induction each later change is at most γjMk\gamma^jM_k. Summing them:

  2. Vπk−Vk+1=∑j≥1((Tπk)j+1Vk−(Tπk)jVk)≥γmk1−γ1V^{\pi_k}-V_{k+1}=\sum_{j\ge1}\Big((\mathcal T^{\pi_k})^{j+1}V_k-(\mathcal T^{\pi_k})^{j}V_k\Big)\ge\frac{\gamma m_k}{1-\gamma}\mathbf 1

    For the lower bound, run the same argument with the policy's own operator. TπkVk=Vk+1\mathcal T^{\pi_k}V_k=V_{k+1}, and Tπk\mathcal T^{\pi_k} is monotone and shifts constants too, so its iterates from VkV_k, which converge to VπkV^{\pi_k}, change by at least γjmk\gamma^jm_k at step jj:

  3. ∥V⋆−Vπk∥∞≤γ (Mk−mk)1−γ=γ1−γsp⁡(Vk+1−Vk)≤2γ1−γ∥Vk+1−Vk∥∞\norm{V^\star-V^{\pi_k}}_\infty\le\frac{\gamma\,(M_k-m_k)}{1-\gamma}=\frac{\gamma}{1-\gamma}\operatorname{sp}(V_{k+1}-V_k)\le\frac{2\gamma}{1-\gamma}\norm{V_{k+1}-V_k}_\infty

    Subtract the outer bounds. Since the span never exceeds twice the max norm, the span rule is never worse than the residual rule, and it is far better when the changes are nearly uniform:

Backup kkChange Vk−Vk−1V_k-V_{k-1}SpanLower bound on V⋆V^\starUpper bound on V⋆V^\starLoss bound for the policy used
1(1, 2)(1,\ 2)1(10, 11)(10,\ 11)(19, 20)(19,\ 20)9
2(0.9, 1.8)(0.9,\ 1.8)0.9(10, 11.9)(10,\ 11.9)(18.1, 20)(18.1,\ 20)8.1
3(1.52, 1.62)(1.52,\ 1.62)0.1(17.1, 19.1)(17.1,\ 19.1)(18, 20)(18,\ 20)0.9
4(1.458, 1.458)(1.458,\ 1.458)0(18, 20)(18,\ 20)(18, 20)(18,\ 20)0
The two-state world from V0=(0,0)V_0=(0,0) with γ=0.9\gamma=0.9. After backup 4 the bounds meet: V⋆=(18,20)V^\star=(18,20) is known exactly, and the policy that backup used, (go, stay), is certified optimal. The residual rule with ε=1\varepsilon=1 waits until backup 36, and the values themselves need 73 backups to come within 0.01.

Why does the span collapse? Once the backups keep using one policy π\pi, the changes evolve linearly, Vk+1−Vk=γPπ(Vk−Vk−1)V_{k+1}-V_k=\gamma P^\pi(V_k-V_{k-1}), and averaging by a stochastic matrix shrinks the span by its ergodicity coefficient, sp⁡(Px)≤τ(P)sp⁡(x)\operatorname{sp}(Px)\le\tau(P)\operatorname{sp}(x) with τ(P)=1−min⁡s,s′∑jmin⁡(P(s,j),P(s′,j))\tau(P)=1-\min_{s,s'}\sum_j\min\big(P(s,j),P(s',j)\big). Under (go, stay) both states move to s2s_2, the two rows of PπP^\pi are equal, τ=0\tau=0, and one backup makes the change uniform. The max norm contracts by γ\gamma; the span contracts by γτ\gamma\tau. In an episodic task the change at a terminal state is always 0, so the span is at least the largest change and the monotone bounds add little: they pay off in continuing problems whose chains mix.

Predict before you look

Backup 3 changes the values by V3−V2=(1.52, 1.62)V_3-V_2=(1.52,\ 1.62). With mm and MM the smallest and largest entries of that change, how wide is MacQueen's bracket, γ1−γ(M−m)\frac{\gamma}{1-\gamma}(M-m), in each state?

Show the answer

0.9

γ1−γ(M−m)=9×0.1=0.9\frac{\gamma}{1-\gamma}(M-m)=9\times0.1=0.9. The bracket [17.1, 18]×[19.1, 20][17.1,\ 18]\times[19.1,\ 20] already contains V⋆=(18,20)V^\star=(18,20), while the a posteriori bound only says ∥V3−V⋆∥∞≤9×1.62=14.58\norm{V_3-V^\star}_\infty\le9\times1.62=14.58, which happens to be the true error.

Eliminating actions for good

Bounds on V⋆V^\star also expose actions that can never be optimal. Suppose L≤V⋆≤UL\le V^\star\le U componentwise. Since Q⋆(s,a)=r(s,a)+γ∑s′P(s′∣s,a)V⋆(s′)Q^\star(s,a)=r(s,a)+\gamma\sum_{s'}P(s'\mid s,a)V^\star(s') is at most the same expression with UU in place of V⋆V^\star, an action whose optimistic value falls below the pessimistic value of its state is beaten by some other action there, whatever later sweeps reveal.

In the two-state world, after backup 3 the bracket is L=(17.1, 19.1)L=(17.1,\ 19.1), U=(18, 20)U=(18,\ 20):

  • go in s2s_2: 0.9×U(s1)=16.2<19.1=L(s2)0.9\times U(s_1)=16.2<19.1=L(s_2), eliminated;
  • stay in s1s_1: 1+0.9×U(s1)=17.2≥17.1=L(s1)1+0.9\times U(s_1)=17.2\ge17.1=L(s_1), it survives for now.

After backup 4, L(s1)=18>17.2L(s_1)=18>17.2, and stay goes too. Only (go, stay) remains, so optimality is certified by elimination after 4 backups.

Each eliminated action makes every later sweep cheaper. In MacQueen's 1967 trial on Howard's automobile replacement problem, the test cut the computation of the dynamic programming routine by, conservatively, 75%. Puterman (1994, §6.7) combines elimination with modified policy iteration and a sharper stopping criterion.

How many sweeps until the policy is optimal?

Values converge only in the limit, but the greedy policy of value iteration becomes optimal after finitely many sweeps. The reason is a margin. The action gap of an MDP is the smallest amount by which a non-optimal action falls short of the best:

Δ=min⁡s min⁡a: Q⋆(s,a)<V⋆(s)(V⋆(s)−Q⋆(s,a))\Delta=\min_s\ \min_{a:\ Q^\star(s,a)<V^\star(s)}\big(V^\star(s)-Q^\star(s,a)\big)
In a finite MDP there are finitely many pairs, so Δ>0\Delta>0 unless every action is optimal everywhere. In the two-state world, Δ=min⁡(18−17.2, 20−16.2)=0.8\Delta=\min(18-17.2,\ 20-16.2)=0.8.
DerivationProof
  1. ∣Qk(s,a)−Q⋆(s,a)∣≤γ∥Vk−V⋆∥∞<Δ2\big|Q_k(s,a)-Q^\star(s,a)\big|\le\gamma\norm{V_k-V^\star}_\infty<\tfrac{\Delta}{2}

    Let Qk(s,a)=r(s,a)+γ∑s′P(s′∣s,a)Vk(s′)Q_k(s,a)=r(s,a)+\gamma\sum_{s'}P(s'\mid s,a)V_k(s') be the lookahead the greedy policy maximizes. It differs from Q⋆Q^\star by γ\gamma times an average of Vk−V⋆V_k-V^\star:

  2. Qk(s,a⋆)>V⋆(s)−Δ2 ≥ Q⋆(s,a)+Δ2>Qk(s,a)Q_k(s,a^\star)>V^\star(s)-\tfrac{\Delta}{2}\ \ge\ Q^\star(s,a)+\tfrac{\Delta}{2}>Q_k(s,a)

    An optimal action a⋆a^\star and a non-optimal action aa have true values at least Δ\Delta apart, so the lookaheads still rank them correctly. No non-optimal action can be greedy, and the sweep count follows from γk∥V0−V⋆∥∞<Δ/(2γ)\gamma^k\norm{V_0-V^\star}_\infty<\Delta/(2\gamma).

In the two-state world the bound gives ⌈ln⁡45/ln⁡(1/0.9)⌉=37\lceil\ln45/\ln(1/0.9)\rceil=37 sweeps; the truth is 2. More importantly, it depends on Δ\Delta, which can be arbitrarily small in MDPs of a fixed size: How Fast Is Policy Iteration? gives a two-state example in which value iteration needs as many sweeps as you like, and Feinberg and Huang (2014) proved that value iteration is not strongly polynomial, even for a fixed γ\gamma.

For data written with BB bits, though, the gap cannot be arbitrarily small. V⋆V^\star solves a linear program (Linear Programming for MDPs), so its entries are rationals of size polynomial in the input, and so is any nonzero gap. Tseng (1990) turned this into a bound: value iteration finds an optimal policy after a number of sweeps polynomial in SS, AA, BB and 1/(1−γ)1/(1-\gamma), so it runs in polynomial time for a fixed γ\gamma. Littman, Dean and Kaelbling (1995) explain the argument and give three-state MDPs on which value iteration needs on the order of 11−γlog⁡11−γ\frac{1}{1-\gamma}\log\frac{1}{1-\gamma} sweeps to find the optimal policy.

Key takeaways

  • A policy greedy for any VV loses at most 2γε/(1−γ)2\gamma\varepsilon/(1-\gamma), with ε\varepsilon the Bellman residual of VV (Williams & Baird); the bound is attained in the two-state world. Value error and QQ error give 2γε/(1−γ)2\gamma\varepsilon/(1-\gamma) and 2ε/(1−γ)2\varepsilon/(1-\gamma) (Singh & Yee).
  • The actions used by backup k+1k+1 lose at most 2γδk/(1−γ)2\gamma\delta_k/(1-\gamma); the policy greedy for Vk+1V_{k+1} at most 2γ2δk/(1−γ)2\gamma^2\delta_k/(1-\gamma).
  • MacQueen's bounds bracket V⋆V^\star between Vk+1+γ1−γmin⁡(change)V_{k+1}+\frac{\gamma}{1-\gamma}\min(\text{change}) and Vk+1+γ1−γmax⁡(change)V_{k+1}+\frac{\gamma}{1-\gamma}\max(\text{change}); the span of the change contracts by γτ(Pπ)\gamma\tau(P^\pi), so in mixing problems the bounds certify optimal policies very early, and they let suboptimal actions be eliminated for good.
  • The greedy policy is optimal once ∥Vk−V⋆∥∞<Δ/(2γ)\norm{V_k-V^\star}_\infty<\Delta/(2\gamma). With BB-bit data that takes a number of sweeps polynomial in SS, AA, BB and 1/(1−γ)1/(1-\gamma) (Tseng), but no bound in SS and AA alone exists.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

The residual bound ∥V⋆−Vπ∥∞≤2γε/(1−γ)\norm{V^\star-V^\pi}_\infty\le2\gamma\varepsilon/(1-\gamma) is called tight. What does that mean?

  1. Every greedy policy loses exactly 2γε/(1−γ)2\gamma\varepsilon/(1-\gamma)
  2. It holds with equality in the limit γ→1\gamma\to1 only
  3. No smaller constant works for all MDPs: some value function with residual ε\varepsilon has a greedy policy that loses arbitrarily close to that much
  4. It is the best bound in terms of ∥V−V⋆∥∞\norm{V-V^\star}_\infty
Show the answer

C. No smaller constant works for all MDPs: some value function with residual ε\varepsilon has a greedy policy that loses arbitrarily close to that much

Tightness is a worst-case statement. In the two-state world, V=(130/9, 140/9)V=(130/9,\ 140/9) has residual 4/94/9 and a greedy policy that loses 8=2γε/(1−γ)8=2\gamma\varepsilon/(1-\gamma). Many other value functions with the same residual have optimal greedy policies.

Question 2

Why can MacQueen's span-based rule stop much earlier than the max-norm rule?

  1. It uses a smaller tolerance
  2. Once the backups keep one policy, the changes are averaged by its transition matrix, which can make them uniform much faster than they shrink, so their span falls far below their maximum
  3. It needs fewer arithmetic operations per sweep
  4. It ignores the states whose values change most
Show the answer

B. Once the backups keep one policy, the changes are averaged by its transition matrix, which can make them uniform much faster than they shrink, so their span falls far below their maximum

The bounds depend on Mk−mkM_k-m_k, not on MkM_k. A uniform change, however large, is pure information: it says exactly how far the values still have to move. The span contracts by γτ(Pπ)\gamma\tau(P^\pi), the max norm only by γ\gamma; in the two-state world the span hits 0 at backup 4.

Question 3

MacQueen's test drops action aa in state ss when r(s,a)+γ∑s′P(s′∣s,a)U(s′)<L(s)r(s,a)+\gamma\sum_{s'}P(s'\mid s,a)U(s')<L(s), with L≤V⋆≤UL\le V^\star\le U. Why may it be dropped forever?

  1. Because the test chains Q⋆(s,a)≤r(s,a)+γ∑s′P(s′∣s,a)U(s′)<L(s)≤V⋆(s)Q^\star(s,a)\le r(s,a)+\gamma\sum_{s'}P(s'\mid s,a)U(s')<L(s)\le V^\star(s), so aa is strictly worse than optimal
  2. Because aa had the smallest lookahead in the last sweep
  3. Because LL and UU will not change again
  4. It may not: dropped actions must be rechecked every sweep
Show the answer

A. Because the test chains Q⋆(s,a)≤r(s,a)+γ∑s′P(s′∣s,a)U(s′)<L(s)≤V⋆(s)Q^\star(s,a)\le r(s,a)+\gamma\sum_{s'}P(s'\mid s,a)U(s')<L(s)\le V^\star(s), so aa is strictly worse than optimal

The test compares aa's most optimistic value with the state's most pessimistic one. If even the optimistic estimate loses, Q⋆(s,a)<V⋆(s)Q^\star(s,a)<V^\star(s) is proven, and later sweeps cannot change a fact about Q⋆Q^\star.

Question 4

Why does value iteration's greedy policy become exactly optimal after finitely many sweeps, although its values never reach V⋆V^\star?

  1. Because there are only finitely many policies, so the greedy policy must repeat
  2. Because a finite MDP has a positive action gap Δ\Delta, and once the value error is below Δ/(2γ)\Delta/(2\gamma) no non-optimal action can be greedy
  3. Because value iteration is policy iteration in disguise
  4. It does not: the greedy policy is only ε\varepsilon-optimal
Show the answer

B. Because a finite MDP has a positive action gap Δ\Delta, and once the value error is below Δ/(2γ)\Delta/(2\gamma) no non-optimal action can be greedy

Errors in the values shift the lookaheads by less than Δ/2\Delta/2 once ∥Vk−V⋆∥∞<Δ/(2γ)\norm{V_k-V^\star}_\infty<\Delta/(2\gamma), and that cannot reverse a ranking separated by at least Δ\Delta. The number of sweeps grows as Δ\Delta shrinks, which is why value iteration is not strongly polynomial.

Further reading

  • R. J. Williams & L. C. Baird, "Tight performance bounds on greedy policies based on imperfect value functions," Technical Report NU-CCS-93-14, Northeastern University (1993); also in Proceedings of the Tenth Yale Workshop on Adaptive and Learning Systems (1994).
  • S. P. Singh & R. C. Yee, "An upper bound on the loss from approximate optimal-value functions," Machine Learning 16(3), 227–233 (1994).
  • J. MacQueen, "A modified dynamic programming method for Markovian decision problems," Journal of Mathematical Analysis and Applications 14, 38–43 (1966); and "A test for suboptimal actions in Markovian decision problems," Operations Research 15(3), 559–561 (1967).
  • M. L. Puterman, Markov Decision Processes: Discrete Stochastic Dynamic Programming, §6.6–6.7 (Wiley, 1994).
  • M. L. Littman, T. L. Dean & L. P. Kaelbling, "On the complexity of solving Markov decision problems," Proceedings of UAI (1995).