Average-Reward Dynamic Programming
Gain, bias and relative value iteration for tasks that never end.
A data center, a traffic light and an inventory system never stop, and nothing makes a reward next year worth less than one today. Push toward 1 and discounted values blow up like . What survives the limit is the gain , the average reward per step, and a finite bias that says which states are better places to start. This lesson rebuilds dynamic programming on those two objects.
What you’ll learn
- Define the gain and bias of a policy, tell unichain from multichain models, and solve the average-reward evaluation equations.
- Derive the Laurent expansion and use it to explain Blackwell optimality.
- Prove that the span seminorm contracts under an ergodicity condition, run relative value iteration, and repair periodic chains with the aperiodicity transformation.
- Bound the optimal gain from any iterate, and connect R-learning and differential Q-learning to these planning methods.
Gain and bias
The two-state world shows all the cases (in , stay pays 1, go pays 0 and moves to ; in , stay pays 2, go pays 0 and moves to ):
- (go, stay): is transient and absorbing, a unichain policy with . With and for , only the term of the bias survives: . Starting in costs the 2 you miss on the first step.
- (stay, stay): two absorbing states, two recurrent classes, . This policy makes the MDP multichain.
- (go, go): a deterministic 2-cycle, which is periodic.
The MDP is still communicating, because from each state some policy reaches the other, and in such MDPs the optimal gain is the same everywhere: here .
geometrically fast for a finite aperiodic chain, so the bias series converges. Apply term by term; since , each term is , and the sum telescopes:
That is with . Multiplying any solution by (which satisfies ) gives , so is forced. Two solutions for differ by a vector with , and in a chain with one recurrent class such are constant:
The Laurent series and Blackwell optimality
Split each into its limit and the rest, using :
The last sum tends to . Its distance from is , and while decays geometrically, so the remainder is . For periodic chains the same statement holds with Cesàro limits (Puterman, 1994, ch. 8).
Two exact examples. Under (go, stay), , with no remainder at all. For a deterministic 2-cycle that pays 2 and then 0, : gain 1, bias , and a remainder .
Since every policy's values are dominated by as , a policy that is optimal for all close to 1 must maximize the gain first and then the bias. Blackwell proved that such a policy exists.
Option A pays 1 at every step forever. Option B pays 0 for the first 10 steps, then 1.1 at every step forever. B has the higher gain. Above which discount factor does a discounted planner also prefer B?
Show the answer
0.99
A is worth and B is worth , so B wins when , that is . With a 100-step delay the threshold moves to about 0.99905. The Blackwell threshold can sit arbitrarily close to 1, so a fixed such as 0.99 is no guarantee of gain-optimal behavior.
Relative value iteration
In a unichain MDP, and more generally in a weakly communicating one such as the two-state world, the optimal gain is the same in every state, and with an optimal bias it solves the optimality equation
and any policy attaining the maximum is gain-optimal. In the two-state world, and solve it (normalized at ), and the maximizing policy is (go, stay). Multichain models with a state-dependent optimal gain need a nested pair of equations (Puterman, 1994, ch. 9).
Undiscounted value iteration , with , grows like . Relative value iteration (White, 1963) subtracts the value at a reference state after every step, which keeps the iterates bounded:
Subtracting constants never changes a greedy action, so RVI computes the same policies as undiscounted value iteration.
Two rows. For probability vectors let . Its positive and negative parts each have mass , because sums to zero. So for any vector :
The max operator. Let be greedy for at and greedy for at . Bounding each maximum by the action that attains the other gives, with :
Subtract and apply the two-row bound to the rows of and . Taking the maximum over gives the contraction. RVI's iterates differ from undiscounted value iteration's only by constants, which the span ignores, so they converge in span to , and since for , .
Periodicity breaks it. On the 2-cycle that pays 2 and then 0, the two rows of share no state, so . From with reference , RVI produces and gain estimate 0, then and estimate 2, then and 0 again: it oscillates forever around the true gain 1.
The aperiodicity transformation repairs this. Replace by and by for some . If , then , so the bias is unchanged, every gain is multiplied by , and the gain-optimal policies are the same. Every state now has a self-loop, so no chain is periodic. With the 2-cycle's rows both become , , and RVI settles at once: (normalized at ) after the first step, and the gain estimate from the second, so .
On the 2-cycle that pays 2 and then 0, RVI's gain estimates alternate 0, 2, 0, 2, … What is the correct diagnosis?
- The chain is periodic, so the span does not contract; adding self-loops with the aperiodicity transformation fixes it
- The reference state was badly chosen; using instead would converge
- The MDP is multichain, so the gain is not constant
- RVI needs a discount factor below 1 to converge
Show the answer
A. The chain is periodic, so the span does not contract; adding self-loops with the aperiodicity transformation fixes it
The two rows of , and , share no state, so and nothing forces the iterates together. Replacing by and by keeps the bias and halves the gain, and RVI then converges at once to , so .
From planning to learning
Replacing the expectation in RVI by a sampled transition gives average-reward TD methods. R-learning (Schwartz, 1993) learns action values together with an estimate of the gain, updating on greedy steps. RVI Q-learning (Abounadi, Bertsekas & Borkar, 2001) subtracts a reference quantity such as , mirroring RVI, and comes with a convergence proof. Differential Q-learning (Wan, Naik & Sutton, 2021) removes the reference state: it updates the gain estimate with the TD error itself, and is proven convergent in the tabular case, off-policy.
def differential_q_step(Q, r_bar, s, a, reward, s_next, alpha=0.1, eta=1.0):
"""One update of differential Q-learning (Wan, Naik & Sutton, 2021).
Q: S x A array of differential action values; r_bar: average-reward estimate."""
delta = reward - r_bar + Q[s_next].max() - Q[s, a] # no discount anywhere
Q[s, a] += alpha * delta
r_bar += eta * alpha * delta # the gain moves with the TD error
return r_barCompare with RVI: plays the role of , and the TD error is a sampled version of . Average-reward forms of the policy gradient theorem appear in The Policy Gradient Theorem in Depth.
Key takeaways
- The gain is the long-run reward per step and the bias the total excess over it. For unichain policies they solve , with unique and unique up to a constant.
- : discounting for near 1 ranks policies by gain, then bias. A Blackwell-optimal policy exists, but its threshold can be arbitrarily close to 1.
- Relative value iteration subtracts a reference value each step. It converges geometrically when the span contracts, ; periodic chains need the aperiodicity transformation, which keeps the bias and scales the gain.
- For any iterate, , which gives a stopping rule; R-learning, RVI Q-learning and differential Q-learning are the sampled versions.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
In the two-state world, the policy (stay, stay) keeps each state absorbing, with rewards 1 and 2. Which description is right?
- Unichain, with gain 1.5 everywhere
- Multichain, with gain 1 in and 2 in
- Periodic, with gain 1.5
- Unichain, with gain 2, because is the better state
Show the answer
B. Multichain, with gain 1 in and 2 in
Each absorbing state is its own recurrent class, so the chain has two classes and the gain depends on where you start: . One such policy is enough to make the MDP multichain.
A unichain policy has gain 1.5 and bias at state . About how large is its discounted value at for ?
- 150
- 153
- 1.5
- 147
Show the answer
D. 147
. The gain sets the scale and the bias the offset between states.
During relative value iteration in a unichain MDP, ranges from 1.9 to 2.1 across states. What can you conclude?
- exactly
- , and a policy greedy for has gain at least 1.9
- Nothing until the span reaches 0
- , since value iteration underestimates
Show the answer
B. , and a policy greedy for has gain at least 1.9
For any , the minimum and maximum of bracket both the optimal gain and the gain of a greedy policy. The width of the bracket, the span, is the stopping criterion.
Which statement about a Blackwell-optimal policy is true?
- It is optimal for every discount factor
- It maximizes the bias among all policies
- It is optimal for all in some interval , is gain-optimal, and has the largest bias among gain-optimal policies
- It exists only in unichain MDPs
Show the answer
C. It is optimal for all in some interval , is gain-optimal, and has the largest bias among gain-optimal policies
Blackwell's theorem gives a single deterministic policy that is optimal for all near 1, and the Laurent expansion forces it to maximize the gain first and then the bias. In the two-state world, (go, stay) is Blackwell-optimal with ; below 0.5, stay is better in .
Further reading
- M. L. Puterman, Markov Decision Processes: Discrete Stochastic Dynamic Programming, ch. 8–9 (Wiley, 1994).
- D. Blackwell, "Discrete dynamic programming," Annals of Mathematical Statistics 33(2), 719–726 (1962).
- A. Schwartz, "A reinforcement learning method for maximizing undiscounted rewards," ICML (1993).
- J. Abounadi, D. P. Bertsekas & V. S. Borkar, "Learning algorithms for Markov decision processes with average cost," SIAM Journal on Control and Optimization 40(3), 681–698 (2001).
- Y. Wan, A. Naik & R. S. Sutton, "Learning and planning in average-reward Markov decision processes," ICML (2021).