The previous chapter ended with function iteration, : value iteration with a fit after each backup. On the fishery it converged with one basis and diverged with another, and the explanation, that the fit must be a nonexpansion in the sup norm, was asserted without proof. This chapter supplies the proofs. It asks when the fit preserves the contraction of the Bellman operator, maximum included, how far from the iteration ends, and what is known when the contraction is lost. Throughout, the model is known and every expectation is computed exactly; the next chapter replaces both by data.
The object of study is the one the previous chapter left: the iteration , in which is applied exactly and is the approximation step chosen by the method. For collocation, interpolates the backups at the nodes; for Galerkin and least squares, it projects them onto the span of the basis in a weighted norm. We call the fit, and ask which properties of keep the iteration convergent.
The answers come in three kinds. Fits that only average their targets, the averagers, keep the iteration a contraction for the optimality equation; they include grid interpolation, state aggregation and fixed-partition trees. Least squares on a basis is not an averager, and it diverges on a two-state problem whose value function it represents exactly. For evaluating a fixed policy with linear features, least squares weighted by the stationary distribution of the policy is safe as well, a special case that explains LSTD and, in the next chapter, temporal-difference learning. Newton’s method, the other solver of the previous chapter, becomes approximate policy iteration. The chapter closes with what operations research, control, numerical analysis and economics know about approximate solutions of the optimality equation.
Function Iteration Can Diverge¶
Value iteration converges because is a -contraction in the sup norm (Proposition 2), and the fit can undo that. The fishery of A Motivating Example: Harvesting a Fishery Near a Tipping Point ran function iteration with collocation, once with hat functions and once with Chebyshev polynomials, and its sweep over showed the polynomial diverging for some . The cell below measures what happens to the fitted values at the nodes from one iteration to the next. The maximization over the escapement and the quadrature over the shock are done by the module that produced the figures of the previous chapter.
Source
import sys
from pathlib import Path
import numpy as np
code_directory = Path.cwd() / "code"
if str(code_directory) not in sys.path:
sys.path.insert(0, str(code_directory))
from fishery_tipping_point import Bellman, ChebyshevBasis, HatBasis, solve_exact
bellman = Bellman() # backups on a fine grid of escapements, 21 quadrature nodes
exact = solve_exact(bellman) # reference solution
def collocation(basis, max_iter=2000):
theta = np.zeros(basis.n)
steps = []
for k in range(max_iter):
v = basis.function(theta)
targets = bellman.apply(v, basis.nodes) # t_i = (L v_theta)(s_i)
new = basis.fit(targets) # solve Phi theta = t
steps.append(np.abs(basis.function(new)(basis.nodes) - v(basis.nodes)).max())
theta = new
if steps[-1] < 1e-10 or steps[-1] > 1e8:
break
return basis.function(theta), np.array(steps)
print(f"{'basis':<30}{'step 10':>10}{'step 100':>11}{'last step':>11}"
f"{'iterations':>12}{'rate':>7}{'max error':>11}")
for basis in (HatBasis(12), ChebyshevBasis(12), ChebyshevBasis(10)):
v, steps = collocation(basis)
rate = np.median(steps[50:150] / steps[49:149])
error = np.abs(v(bellman.x) - exact.v).max()
label = f"{basis.name}, n = {basis.n}"
print(f"{label:<30}{steps[9]:>10.2e}{steps[99]:>11.2e}{steps[-1]:>11.2e}"
f"{len(steps):>12}{rate:>7.3f}{error:>11.3g}")basis step 10 step 100 last step iterations rate max error
Piecewise linear, n = 12 9.59e-02 9.45e-04 9.96e-11 413 0.950 0.521
Chebyshev polynomial, n = 12 9.92e-02 8.59e-04 9.63e-11 412 0.950 1.66
Chebyshev polynomial, n = 10 1.07e-01 5.06e+00 1.05e+08 452 1.049 2.79e+09
With 12 coefficients, both bases converge, and the change per iteration shrinks by the factor , as in value iteration. They converge to different fixed points, with errors of about 0.5 and 1.7. With 10 Chebyshev coefficients, the change instead grows by about 5% per iteration, and the coefficients run off to infinity. The Bellman backup is still a -contraction in the sup norm, so the growth comes from the interpolation step: on these iterates it multiplies sup-norm distances by at least , so it is not a nonexpansion, and is not a contraction. A two-state example isolates the mechanism, and averagers are the fits that are always sup-norm nonexpansions.
A Two-State Control Problem Where Least-Squares Value Iteration Diverges¶
The following problem is small enough to solve by hand and shows the same failure with the maximum active. It extends an example of Tsitsiklis & Van Roy (1996). There are two states, and in each the agent chooses between two actions: move to state 1 or move to state 2. All rewards are zero, so whatever the policy. The value function is represented with a single feature, and , which contains at . Function iteration computes the targets at both states and fits them by least squares with equal weights. Both states have the same two successors, so both targets equal
The maximum is active: when the greedy action in both states moves to state 2, and when it moves to state 1. The fit minimizes for the common target , so , and
import numpy as np
phi = np.array([1.0, 2.0]) # v(1; theta) = theta, v(2; theta) = 2 theta
gamma = 0.9
def backup(theta):
v = phi * theta
# both states can move to state 1 or to state 2, with zero reward
return gamma * np.full(2, v.max())
def fit(targets):
return phi @ targets / (phi @ phi) # least squares, equal weights
for theta0 in (1.0, -1.0):
theta = theta0
path = [theta]
for _ in range(40):
theta = fit(backup(theta))
path.append(theta)
print(f"theta_0 = {theta0:+.0f}: theta_10 = {path[10]:+.3g}, theta_40 = {path[40]:+.3g}")theta_0 = +1: theta_10 = +2.16, theta_40 = +21.7
theta_0 = -1: theta_10 = -0.00211, theta_40 = -1.98e-11
For the iterates diverge from every ; with they grow by 8% per iteration, while from they converge to zero. On the diverging branch the Bellman operator multiplies the sup-norm distance between and by , and the fit then multiplies it by , so the fit is not a nonexpansion: the target is the constant , and the best line through the origin overshoots it at state 2, where it predicts . The fit error grows in proportion to , so no bound that assumes a fixed accuracy per iteration can help here. Boyan & Moore (1995) observed the same failure with polynomial regression and neural networks on small control problems, at a time when TD-Gammon had made neural value functions look easy.
On that branch the greedy policy always moves to state 2, and . The iteration is then the projected evaluation of , which is the original example of Tsitsiklis & Van Roy (1996): one action per state, state 1 moves to state 2 and state 2 stays put. With a single action the maximum is trivial and the optimality operator is the evaluation operator, so that one-action problem is already an instance of value iteration with the optimality operator, and one instance is all a counterexample needs. The second action shows that the maximum does not prevent the divergence. The sections on policy evaluation below return to the chain of .
Averagers Preserve the Sup-Norm Contraction¶
The composition keeps the sup-norm contraction of whenever is a nonexpansion in the sup norm, since then . The argument uses only the contraction, so it holds with the maximum in . Which fitting rules are sup-norm nonexpansions? The answer was found independently in computational economics Judd (1992)Judd (1996)McGrattan (1997)Santos & Vigo-Aguiar (1998), economic dynamics Stachurski (2009), and reinforcement learning Gordon (1995)Gordon (1999), and the communities arrived at the same condition under different names.
Definition and Convergence Theorem¶
Gordon (1995) introduced the term averager for such operators. The finite-state characterization follows because a linear map is monotone if and only if its matrix has nonnegative entries, and preserves constants if and only if its rows sum to one. An interpolation operator with cardinal functions is an averager if and only if, at every , the weights are nonnegative and sum to one. For an interpolation scheme that reproduces constants, so that the weights already sum to one, this holds if and only if the Lebesgue constant is , the condition of the finite-horizon chapter and the property that separated the hat functions from the polynomial in the fishery.
Is an averager the same thing as collocation? In one direction, yes: collocation with a nodal basis whose cardinal functions are nonnegative and sum to one, such as the hat functions or multilinear interpolation on a grid, is an averager, and its is a projection. The converse fails, because an averager need not reproduce its targets at the nodes. A kernel smoother with a nonnegative kernel, or -nearest neighbors, assigns to a node a weighted average of the targets at nearby nodes, not the target at that node, so . The averager condition therefore covers collocation with a monotone interpolant and also a class of smoothers that are not projections at all. What all of them share is that at every state is a convex combination of the values of , with weights that depend on the states and not on .
An averager acts like a weighted average: it respects order and is a nonexpansion in the sup norm. The converse fails: is a sup-norm nonexpansion but is not monotone. For a linear that preserves constants, the two properties are equivalent, because a row that sums to one has absolute sum at most one if and only if its entries are nonnegative. The least-squares fit of the counterexample is not one. It maps the constant function to , so it does not preserve constants, and it does not respect order either. Polynomial interpolation at Chebyshev nodes preserves constants but is not monotone: its cardinal functions dip below zero between the nodes, and its Lebesgue constant is about 2.4 for ten nodes. That is how the ten-coefficient polynomial of the fishery in Function Iteration Can Diverge could make fail to be a contraction, while the hat functions, whose cardinal functions are nonnegative, could not.
Theorem 1 combines results from two literatures. Gordon (1995) defined averagers, in a slightly more general form in which fixed constants may enter the average, proved that every averager is a sup-norm nonexpansion and that function iteration with one therefore converges at rate , and bounded the error of the limit by , where is the distance from to the nearest fixed point of the averager. Santos & Vigo-Aguiar (1998) proved that value iteration with piecewise-linear interpolation on a triangulation, the averager used for growth models in economics, converges, with an error that goes to zero linearly in the mesh size. The bound in the form stated here, through , follows from the same contraction argument, and the proof of Proposition 1 follows Stachurski (2009). The fixed-point error is the best-approximation error multiplied by . For an averager the per-iteration error stays bounded, which is the condition that the error bound for arbitrary fits, in the chapter on fitted value methods, requires.
The stochastic matrix gives the averaging a Markov-chain reading: is an expected value after one random transition, and expectations preserve order. The finite-horizon chapter made the same observation about linear interpolation, which replaces a deterministic successor by a random grid node with the interpolation weights as probabilities. Composing that chain with the model’s own transitions makes the Bellman operator of a finite-state MDP, which is why it contracts.
Which Common Fits Are Averagers¶
The same condition appears under several names in the literature on continuous-state control, often without reference to Gordon. Kushner & Dupuis (2001) build their Markov chain approximations of controlled diffusions from interpolation weights that are transition probabilities, the Markov-chain reading above used as a design principle. Rust (1997) solves value iteration on uniformly drawn states, with the transition density at those states, normalized to sum to one, as the averaging weights. The random grid is an averager, and for a finite set of actions the number of draws needed for a given accuracy grows only polynomially with the dimension of the state. The kernel-based reinforcement learning of Ormoneit & Sen (2002) applies the same normalized-kernel averaging to sampled transitions, without a model, and proves consistency as the number of samples grows and the bandwidth shrinks. Munos & Moore (2002) refine a triangulation of the state space where the value function or the policy varies most, and interpolate within each simplex with barycentric weights, again an averager.
Which regressors are averagers? State aggregation, -nearest neighbors, kernel smoothing with nonnegative kernels normalized to sum to one, and multilinear interpolation on a grid all predict a convex combination of training targets whose weights depend only on the states. So does a regression tree, which predicts the average of the targets in a leaf, as long as its partition of the state space does not depend on the targets. Ernst et al. (2005) used this to give tree-based fitted Q-iteration a convergence guarantee. Their extremely randomized trees choose splits with the help of the targets, and freezing the tree structure after some iterations restores the guarantee. Linear least squares, high-order polynomial interpolation, and neural networks are not averagers. The table lists the common fits, with a paper that used each one for value functions.
| Method | Averager? | Notes | Used for value functions in |
|---|---|---|---|
| Piecewise linear interpolation | Yes | Barycentric weights are nonnegative and sum to one | Munos & Moore (2002) |
| Multilinear interpolation (grid) | Yes | Weights are products of one-dimensional hat functions | Johnson et al. (1993) |
| Variation-diminishing splines (Schoenberg) | Yes | B-spline weights are nonnegative and sum to one | Stachurski (2008) |
| Shape-preserving splines (Schumaker, rational Hermite) | Not linear | Preserve monotonicity and concavity of the data, not covered by the averager theorem | Cai & Judd (2012) |
| State aggregation | Yes | Equal weights within a group | Tsitsiklis & Van Roy (1996), Whitt (1978) |
| -nearest neighbors | Yes | Equal weights within a neighborhood | Shah & Xie (2018) |
| Kernel smoothing (nonnegative kernels) | Yes | If the weights are normalized to sum to one | Ormoneit & Sen (2002), Rust (1997) |
| Tile coding (CMAC) | Depends on the fit | Averaging the tilings’ separate fits is an averager; the joint least-squares fit is not in two or more dimensions (Tile Coding: Between Aggregation and Galerkin) | Sutton (1996) |
| Regression trees and forests, fixed partition | Yes | Leaf averages; guarantee lost if splits depend on the targets | Ernst et al. (2005) |
| High-order polynomial interpolation | No | Negative weights (Runge phenomenon) | Bellman et al. (1963) |
| Least squares on an arbitrary basis | No | The counterexample above | Tsitsiklis & Van Roy (1996) |
| Neural networks | No | No sign or normalization constraint on the fit | Tesauro (1995), Riedmiller (2005) |
The table places the fits of the two chapters. Collocation with piecewise-linear interpolation is an averager, so the folk wisdom that linear interpolation is safe for value iteration is a theorem. Collocation with a high-order polynomial is not, and its convergence in the fishery, when it happened, was not guaranteed. Galerkin projection and least squares are not averagers. Tree ensembles sit on the boundary, as the eight-dimensional example of the next chapter shows, and networks are outside. The solver matters too: Newton’s method never iterates , so it does not need the contraction, which is why the hybrid strategy of Step 4: Solve the Equations starts with a monotone, low-order fit and switches to Newton with the accurate one.
Averagers pay for their stability in accuracy. The error bound of Theorem 1 is the best-approximation error , and an averager can only represent functions that are smooth on the scale of its weights. That error is the error of a local method, and in high dimension it decreases slowly with the number of nodes.
Exercises: Divergence and Averagers
The counterexample with an averager. Replace the least-squares fit in the two-state example by state aggregation into a single group. Write as a matrix, check that it is an averager, and show that fitted value iteration converges for every . What is its fixed point?
A non-monotone example. Using Lagrange interpolation with 4 equally spaced nodes on , compute the interpolation weights for the state . Show that some weights are negative.
Verifying monotonicity. Consider piecewise linear interpolation on a 5-point grid. Write out the interpolation weights for a point between grid points 2 and 3. Verify that all weights are nonnegative and sum to one.
Trees. Show that a regression tree with a fixed partition is an averager. Explain why a tree that chooses its splits by the targets can change its partition from one iteration to the next, and which step of the proof of Theorem 1 this breaks.
Tile Coding: Between Aggregation and Galerkin¶
Tile coding is the linear representation that Sutton (1996) used to make early reinforcement learning work, and it descends from the cerebellar model articulation controller (CMAC) of Albus (1975). It gets no simple yes or no in the averager column of the table above, and the figure below shows why.
Each row of the top panel of Figure 1 is one tiling: a grid that cuts into cells of width , called tiles. There are tilings, and tiling is shifted by an offset , so the rows are staggered. The vertical line is a state . It lies in exactly one tile of each row, shaded in orange. Each tile carries one weight, and the value at is the sum of the weights of the orange tiles. In vector form, the feature vector has one binary entry per tile, with exactly ones, and .
For example, take tilings of width , the second shifted by . The first tiling has two tiles, and , and the second has three, , and , so there are five features, one per tile, listed tiling by tiling. The state lies in the second tile of both tilings, and lies in the second tile of the first tiling and the third tile of the second, so
where is the weight of tile of tiling . The two states share one of their two tiles, so their values share the weight . The middle panel of the figure writes out in the same way, one group of boxes per tiling, and lists the weights that add up to as moves.
Set with the slider and a single row remains: that is state aggregation, which sits in both columns of the two-norm table. With the tiles overlap, and whether the fit is an averager depends on how the weights are fitted. Two questions settle it, and the top and bottom panels of the figure answer them: which functions the features can represent, and how an update at one state changes the value at another.
Figure 1:Top: tilings of with tiles of width , the tiles that contain (orange), and the fine cells where all the tilings agree. Middle: the feature vector , one box per tile, grouped by tiling, and the weights whose sum is . Bottom: the fraction of tiles that shares with each , against the hat . Drag or press play. With random offsets, play redraws the offsets again and again and averages the kernels.
What tile coding represents. Move inside one cell of the bottom row of the top panel, labeled “fine”: the orange tiles do not change. Two states in the same fine cell lie in the same tile of every tiling, so they have the same features, and every is constant on the fine cells. With offsets spaced apart, the edges of the tilings interleave and the fine cells have width . In one dimension the code below finds that the feature matrix has rank equal to the number of fine cells, so the span of the tile features is exactly the set of functions that are constant on the fine cells. In one dimension, then, tilings of width represent the same functions as one tiling of width , with about the same number of weights: the text under the figure reports 16 fine cells and 19 weights for . The saving appears in higher dimension. In dimensions there are about fine cells when the offsets are spaced apart in each coordinate, but only about weights, so tile coding resolves the fine grid with roughly times fewer parameters than a fine tiling would need. The price is that its span is now a strict subspace of the functions that are constant on the fine cells. For and in the plane, the code below finds 91 weights, a rank of 88, and 256 fine cells.
How tile coding generalizes. The bottom panel answers the second question. Sutton used tile coding with incremental updates of the form , which move each of the orange weights by the same amount. The value at any other state then changes by
where is the fraction of tiles that and share, the blue staircase in the bottom panel. The update at spreads to its neighbors in proportion to .
Compare the staircase with the dashed orange curve in the same panel. That curve is the hat function centered at ,
a triangle of height one and half-width : it equals 1 at , decreases linearly with the distance , and is 0 once is a full tile width away from . It is the hat function of piecewise-linear interpolation, centered at , with the tile width as its half-width.
The top panel shows why the staircase follows the hat. A state shares the tile of row with unless an edge of row falls between them, so . Each row has one edge every , so when at most one edge of each row lies between the two states, and when every row has one. When the offsets are spaced apart, the edges of the rows interleave evenly, one every , so an interval of length contains edges, rounded up or down. Hence is up to one step of :
The staircase therefore stays within one step of the hat, and the steps shrink as grows. Switch to random offsets and press play: for each draw the staircase is irregular, but a row with a random offset puts an edge between two states at distance with probability , so the expected fraction of shared tiles is exactly the hat, and the running average, in green, converges to it.
This answers the question of what kind of function approximator tile coding is. As a function of the displacement , the hat is the box of width convolved with itself and divided by , which is the linear (degree-one) B-spline. The two questions of this subsection have different answers. What tile coding fits is piecewise constant: each feature is the indicator of one tile, a box, which is a degree-zero B-spline, and every tile is a union of fine cells, so every combination is constant on each fine cell. How tile coding generalizes is piecewise linear: an update at changes the value at in proportion to , which is the hat up to , a degree-one B-spline. The CMAC literature drew the same conclusion and generalized it: Lane et al. (1992) replace the box receptive fields by B-splines of higher order, which makes the fitted function itself a smooth spline whose derivatives can be learned, and Brown & Harris (1994) treat the CMAC and B-spline networks as members of one family of lattice-based networks that are linear in their weights. Kernel methods reached tile coding from the other direction. The random binning features of Rahimi & Recht (2007) are tile coding with random offsets: they compute that two points fall in the same bin with probability given by the hat, and that drawing the tile width at random as well, with density , turns the expected kernel into a kernel of the distance, for any whose second derivative is nonnegative, and into products of such kernels over the coordinates in several dimensions. The Laplacian kernel , for example, comes from a tile width with a Gamma distribution. Because the expected fraction of shared tiles is a kernel, a linear fit on random tilings is kernel regression with that kernel estimated from random draws: tile coding with random offsets is a finite random-feature approximation of kernel regression.
Two dimensions and hashing. In the plane, each tiling is a grid of squares, and Figure 2 shades around a point , with the squares that contain outlined. With offsets spaced along the diagonal, every tiling moves along the line , and the shading is stretched along that line: states displaced along the diagonal share more tiles than states displaced across it. With random offsets drawn independently in each coordinate, the expected kernel is the product of one-dimensional hats, a tensor-product linear B-spline. The displacement comes close to that symmetric shape with evenly spaced offsets, which is why Sutton & Barto (2018) recommend displacement vectors made of the first odd integers.
Figure 2:The shared-tile kernel in the plane for tilings of squares, , with diagonal, asymmetric or random offsets. The hash buttons send all the tiles into a table of 256, 64 or 16 weights, and the shading then shows the false similarity that collisions add far from . Drag the point or press play.
When weights are too many, tile coding implementations map the tiles into a table of weights with a hash function Sutton & Barto (2018). Press “64 weights” in the figure: speckles appear far from . Within one tiling, hashing only merges tiles into groups, so a hashed tiling is still a partition of the state space, into groups of cells that need not be adjacent. Across tilings, two tiles of different tilings can share a weight, and two distant states then share weights by accident. For a hash that sends each tile to a bucket uniformly and independently, the expected inner product of the hashed features is the number of shared tiles plus , a bias toward false similarity that grows as the table shrinks. Feature hashing in machine learning Weinberger et al. (2009) removes this bias by multiplying each hashed feature by a random sign. The inner product is then unbiased, but the features are no longer nonnegative.
Where tile coding sits. The answer depends on how the weights are fitted, and the three common ways give three different operators.
Fit each tiling separately and average. Each tiling alone is aggregation, whose projection is a stochastic matrix. The average is a convex combination of stochastic matrices, hence stochastic, so it is an averager and Theorem 1 applies. With uniform weighting and away from the boundary, row of is , so this fit is the kernel smoother of the table, with the staircase of Figure 1 as its kernel. It is not a projection, since . A hashed tiling is still a partition, so hashing within each tiling keeps this fit an averager; a signed hash does not.
Fit all the weights jointly by least squares. This is the Galerkin projection onto the span of the tile features. In one dimension, with every fine cell weighted, the span is that of the fine tiling, so the projection is aggregation onto the fine cells and is again an averager. In two dimensions it is not: for and , the projection has negative entries and its sup-norm operator norm exceeds 4. The averager condition needs nonnegative entries, so it fails, and only the -norm results of the next subsection remain.
Fit the weights incrementally by TD, as Sutton did. The sample-based update is a stochastic approximation of the joint fit, and its limit is the solution of the projected Bellman equation with the Galerkin projection of item 2. Each step spreads the correction with the nonnegative kernel , but this does not make the fixed point an averager. On-policy, the convergence result of Tsitsiklis & Van Roy (1997) applies, as it does to any linear features.
Source
import sys
from pathlib import Path
sys.path.insert(0, str(Path.cwd() / "code"))
import tile_coding as tc
z = lambda x: 0.0 if abs(x) < 1e-9 else x
k = tc.kernel_report_1d(m=8, h=0.25)
print("Shared-tile kernel, K = 8, h = 0.25")
for key, val in k.items():
print(f" {key:<42}{val:8.4f}")
a = tc.kernel_2d_anisotropy(m=8, h=0.25, r=0.1)
print("\nTwo dimensions, shared fraction at distance 0.1")
for key, (along, across) in a.items():
print(f" {key:<20} along the diagonal {along:.3f}, across it {across:.3f}")
print("\nProjections (K = 4, h = 0.25, uniform weighting on a grid of states)")
print(f" {'':<4}{'states':>7}{'weights':>8}{'rank':>6}{'fine':>6}"
f"{'joint min':>11}{'joint sup':>10}{'avg min':>9}{'avg sup':>9}")
for d, n in ((1, 64), (2, 32)):
r = tc.projection_report(m=4, h=0.25, n=n, d=d)
print(f" {d}D {r['states']:>7}{r['weights']:>8}{r['rank']:>6}{r['fine cells']:>6}"
f"{z(r['joint LS: min entry']):>11.3f}{r['joint LS: sup norm']:>10.3f}"
f"{r['averaged: min entry']:>9.3f}{r['averaged: sup norm']:>9.3f}")
print(f" averaged smoother vs normalized shared-tile kernel (interior rows): "
f"{tc.smoother_matches_kernel():.1e}")
hs = tc.hashing_report(m=8, h=0.25, M=64)
print("\nHashing 8 tilings into M = 64 weights")
for key, val in hs.items():
print(f" {key:<42}{val:8.3f}")
curves = tc.learning_curves()
print("\nRMSE after 30 / 100 / 300 / 1000 / 3000 samples (K = 8, h = 0.2, alpha = 0.1)")
for name, c in curves.items():
print(f" {name:<36}" + "".join(f"{e:8.3f}" for e in c))Shared-tile kernel, K = 8, h = 0.25
uniform: max |k - hat| 0.1236
random (mean of 4000 draws): max |k - hat| 0.0054
1/K 0.1250
Two dimensions, shared fraction at distance 0.1
diagonal (1, 1) along the diagonal 0.750, across it 0.375
asymmetric (1, 3) along the diagonal 0.500, across it 0.500
Projections (K = 4, h = 0.25, uniform weighting on a grid of states)
states weights rank fine joint min joint sup avg min avg sup
1D 64 19 16 16 0.000 1.000 0.000 1.000
2D 1024 91 88 256 -0.054 4.436 0.000 1.000
averaged smoother vs normalized shared-tile kernel (interior rows): 6.9e-18
Hashing 8 tilings into M = 64 weights
mean shared tiles 3.417
unsigned hash: mean inner product 4.363
predicted shared + (K^2 - shared)/M 4.364
signed hash: mean inner product 3.435
RMSE after 30 / 100 / 300 / 1000 / 3000 samples (K = 8, h = 0.2, alpha = 0.1)
coarse, 1 tiling of width h 0.374 0.276 0.262 0.267 0.263
fine, 1 tiling of width h/K 0.508 0.434 0.276 0.094 0.076
tile coding, K tilings of width h 0.353 0.178 0.115 0.103 0.084
The first block confirms the staircase bound, , and shows the random-offset average within 0.006 of the hat after 4000 draws. In the plane, diagonal offsets let states share three quarters of their tiles along the diagonal but only three eighths across it, and the displacement makes the two equal. In the projection table, the joint least-squares fit is an averager in one dimension (smallest entry 0, sup norm 1) and not in two (smallest entry -0.054, sup norm 4.44), while the averaged single-tiling fits are averagers in both and coincide with the normalized shared-tile kernel. The hashing block matches the collision bias and shows the random sign removing it.
The last block is the reason tile coding was popular, and Figure 3 animates it. Three learners receive the same noisy samples of a function with a jump. One coarse tiling of width , in blue, generalizes broadly and learns fast, but its error stops at 0.26, the error of its best approximation. One fine tiling of width , in purple, can represent the function well, but each sample teaches it about one narrow cell, so after 100 samples its error is still 0.43. Tile coding, in orange, generalizes like the coarse tiling, with error 0.18 after 100 samples, and represents like the fine one, with error 0.08 after 3000. Watch the shaded bumps: each is the change made by the last sample, a wide box for the coarse tiling, a narrow box for the fine one, and the staircase hat of Figure 1 for tile coding. Overlapping tilings buy fast generalization at fine resolution, and in several dimensions they also buy memory.
Figure 3:A coarse tiling, a fine tiling and tilings learn from the same stream of noisy samples of , with step size . The shaded bump under each fit is the change made by the last sample, magnified eight times. Bottom: root-mean-square error against the number of samples.
Linear Policy Evaluation: Convergence in the Stationary-Distribution Norm¶
Least squares is not an averager, yet linear features fitted by least squares are the setting of temporal-difference learning and LSTD, which converge when they evaluate a fixed policy. The reason is a second norm in which a stability proof can be carried out. This section develops it for the case where it applies, a fixed policy and linear features, and ends with why it does not extend to the maximum. The neural algorithms of the chapters ahead are outside this case, but the classical convergence results for temporal-difference learning come from it.
One Projection Matrix for Every Weighted-Residual Method¶
The two-state counterexample is an instance of the projected Bellman equation (14) of the previous chapter, . The Bellman operator in it is fixed by the problem; the projection is chosen by the method. Both families of stability results, averagers and on-policy weighting, are conditions under which remains a contraction. On a finite state space , a function is a vector of , the features are the columns of an matrix with rows , and the test functions of Step 3 of the previous chapter are the columns of an matrix . With a weighting over the states and , the conditions with say that , where
This matrix satisfies and returns every element of the span of the features unchanged, so it is a projection onto that span. What it discards is the part of a function that the tests do not see. The methods of the previous chapter differ only in . Galerkin takes , and is the -orthogonal projection, the weighted least-squares fit. Collocation replaces the row vectors by the rows of the identity that select the nodes, so that is interpolation through the nodes; for a nodal basis such as the hat functions, entry of is the cardinal function . Other tests give oblique projections. Bellman residual minimization, for instance, uses the tests , which depend on the operator Scherrer (2010). The counterexample above is Galerkin with uniform weights, and its projection is the matrix .
Whether the iteration converges is a question about norms. The composition is a -contraction in a norm whenever is a -contraction in that norm and is a nonexpansion in the same norm, since then . Two norms make this argument work, and each gives one family of stability results.
The first is the sup norm, in which is a -contraction for every MDP, with or without the maximum. The sup-norm operator norm of a matrix is its largest absolute row sum. When the constant function is in the span of the features, as it is for hat functions, polynomials and aggregation, , so every row of sums to one. A row that sums to one has absolute sum at least one, with equality if and only if its entries are nonnegative, so is a sup-norm nonexpansion if and only if all its entries are nonnegative. The projection is then a stochastic matrix. This is the averager condition of Averagers Preserve the Sup-Norm Contraction. For collocation it is a condition on the cardinal functions, which must be nonnegative, and it holds for hat functions and fails for polynomials. For Galerkin it is a condition on the entries of , which fails for the counterexample, whose projection maps to and to . Its rows sum to and , so its sup-norm operator norm is , the factor by which the fit multiplied the sup-norm distance to in the iteration above.
The second is the -weighted norm , in which every Galerkin projection with weighting is nonexpansive, whatever the features, because it is an orthogonal projection for the inner product that defines the norm. The difficulty moves to the operator, because the Bellman operator need not contract in . On-Policy Weighting Makes Projected Evaluation a Contraction shows that the evaluation operator contracts when is the stationary distribution of the policy, and that the optimality operator does not.
| Sup norm | -weighted norm | |
|---|---|---|
| Projection | Stochastic matrix (averager) | -orthogonal (Galerkin) |
| Features | Nonnegative cardinal functions, local | Any |
| Operator | or | only |
| Data | Any weighting | stationary for (on-policy) |
| Typical methods | Collocation with hats, aggregation, nearest neighbors, kernel averaging | TD(0), TD(), LSTD |
| Main references | Gordon (1995), Tsitsiklis & Van Roy (1996) | Tsitsiklis & Van Roy (1997), Bertsekas & Tsitsiklis (1996) |
The two columns trade restrictions on the fit for restrictions on the problem. The sup-norm route accepts the maximum and any data distribution, and asks for fits that only average their targets. The -norm route accepts any linear features, and asks that the operator be the evaluation operator of the policy that generated the data. Neither covers deep reinforcement learning, where a network is fitted from off-policy data to targets that contain the maximum.
State aggregation sits in both columns. Its features are the indicators of groups of states, and the Galerkin projection with any weighting replaces each value by the -weighted average over its group, , where is the group of . The entries are nonnegative and the rows sum to one, so this Galerkin projection is also an averager, for every weighting. This is why aggregation was among the first approximation schemes with convergence proofs for function iteration Whitt (1978)Tsitsiklis & Van Roy (1996), and why Van Roy (2006) could bound the loss of its greedy policy with the optimality operator in place.
On-Policy Weighting Makes Projected Evaluation a Contraction¶
The -norm route keeps the Galerkin projection, which is nonexpansive in for any features, and asks when the Bellman operator contracts in the same norm. The counterexample shows which weighting works. The chain moves from state 1 to state 2 and stays there, so its stationary distribution puts all its mass on state 2. If the fit weights each state by that distribution, it minimizes alone, and converges. The equal weighting was the problem: it gives the state that the process leaves at once the same weight as the state where it stays.
For policy evaluation this observation is a theorem, which Tsitsiklis & Van Roy (1997) proved to explain why TD(0) converges with linear features. With the notation of One Projection Matrix for Every Weighted-Residual Method, the -weighted inner product, the norm, and the Galerkin projection () are
Fitted policy evaluation is with . In reinforcement learning the weighting is not a free choice: the states in the data are those the process visits, and if the chain under is ergodic their distribution approaches the stationary distribution with . Suppose the fit is weighted by this stationary distribution. We show that is nonexpansive and is a -contraction, both in , so that
Throughout, for every state, so that is a norm.
Orthogonal projection is nonexpansive. For any vector , the projection is the fit that minimizes over . Setting the gradient with respect to to zero gives the normal equations , whose solution is the matrix in (12). They say that the residual is -orthogonal to every column of , hence to every vector of their span, and in particular to itself: . Decompose and expand the square of its norm. The cross term is this inner product, so it vanishes, and
This is the Pythagorean theorem for the -weighted inner product. Since is linear, applying it to gives , so is a nonexpansion in .
No sign condition on the entries of was needed. The sup-norm argument fails for this projection, while the -norm argument does not depend on the signs of its entries.
contracts in . Since , it suffices to show for every .
Before reading on, try to show this yourself. Hint: what property of relates it to ?
Fix a state . The row of is a probability distribution over next states, so the -th component is an average of the values with these probabilities as weights. Since is convex, Jensen’s inequality with the same weights gives, for each separately,
Multiply each of these inequalities by and add them over . The left side becomes . On the right, exchange the two finite sums so that is factored out. The inner sum that remains, , is the -th entry of the row vector , and stationarity, , replaces it by :
Stationarity is used only in the third line, and it is the only property of that the argument needs. Taking square roots, , and with ,
so is a contraction with modulus in .
The two inequalities chain. Applying the nonexpansion of to the vectors and , then the contraction of ,
So is a contraction with modulus in , and by Theorem 3 fitted policy evaluation converges from any start to the unique solution of the projected Bellman equation
Its solution is the fixed point to which TD(0) with linear features converges. The argument of Theorem 1 bounds its distance to by , and the inner-product structure improves the constant to Tsitsiklis & Van Roy (1997).
Convergence came from matching the weighting to the operator, not from any property of the fit beyond orthogonality: must be the stationary distribution of the very that appears in . When the data are collected by following , this holds automatically, which is on-policy learning. When they come from another behavior policy, as in the counterexample’s equal weighting, the Jensen step fails, need not be nonexpansive in , and may not contract. Baird’s counterexample Baird (1995) is the classical demonstration.
Exercises: The On-Policy Condition
Weighting the counterexample. In the two-state example, fit with weights . Show that and find the set of weightings for which the iteration converges for every .
Non-expansiveness fails off-policy. For the 3-state chain of Solving the Galerkin System Directly: LSTD below and the weighting , find a vector such that .
Losing the argument is not losing convergence. Implement fitted policy evaluation for the same chain, with features and weighting . It still converges: compute the spectral radius of and check that it equals for this feature set whatever the weighting. Then keep only the feature and find a weighting concentrated on state 1 under which the spectral radius exceeds one.
The Galerkin Linear System Is Positive Definite On-Policy¶
The projected Bellman equation (19) is the Galerkin method of the previous chapter, with the stationary distribution as weight. Its conditions form the linear system
Fitted policy evaluation solves it by function iteration, , and the LSTD method of the next subsection solves it directly. Temporal-difference learning, TD(0), solves the same system from single sampled transitions; the next chapter treats it as one more case of replacing expectations by samples. Whatever the solver, the system has to be well posed, and on-policy the inequality that made a contraction also makes positive definite. This is the step at the center of the convergence proof of TD by Tsitsiklis & Van Roy (1997).
A matrix with for every need not be symmetric, but each of its eigenvalues has a positive real part: if with , the real part of is the quadratic form of the symmetric part of at the real and imaginary parts of , which is positive. In particular is invertible, so on-policy the Galerkin system has exactly one solution for any independent features.
When the weighting is not stationary for , which is the situation of evaluating one policy from the data of another, the Jensen step fails, and Proposition 2 fails with it. The projection is still orthogonal, but can be singular or have eigenvalues in the left half plane, and the solution, when there is one, can be far from : Kolter (2011) shows that its error can be arbitrarily large relative to , and describes a convex set of weightings, close to the behavior distribution, for which a bound of the on-policy form still holds. What off-policy weighting does to the sample-based solvers, and how importance sampling, gradient TD and emphatic TD repair it, is taken up in the next chapter.
Solving the Galerkin System Directly: LSTD¶
Function iteration on (20) needs many sweeps, but the system has only unknowns and can be solved directly. Written out, its conditions say that the residual is -orthogonal to every feature:
Solving it is the LSTD (least-squares temporal difference) method of Bradtke & Barto (1996), and the system is the Galerkin counterpart of the collocation step (32). Temporal-difference learning with linear features, TD(0), converges to the same fixed point Tsitsiklis & Van Roy (1997), so TD and LSTD are two solvers of one Galerkin equation, the first by stochastic approximation and the second by solving the linear system. Neither was designed that way; the reading as projected equations is due to Bertsekas Bertsekas & Tsitsiklis (1996)Bertsekas (2011), and the Galerkin method itself is standard in computational economics Judd (1998). Because the system is linear in the unknown, and can also be estimated from sampled transitions, which the next chapter does. On a 3-state chain under a fixed policy, with , , features and uniform weights:
Source
import numpy as np
P_pi = np.array([[0.7, 0.2, 0.1], [0.3, 0.4, 0.3], [0.1, 0.3, 0.6]])
r_pi = np.array([1.0, 2.0, 0.0])
gamma = 0.9
# Feature matrix: phi_1(s) = 1, phi_2(s) = s
states = np.array([1, 2, 3])
Phi = np.column_stack([np.ones(3), states])
# Uniform weighting
xi = np.ones(3) / 3
Xi = np.diag(xi)
# LSTD matrices
A = Phi.T @ Xi @ (Phi - gamma * P_pi @ Phi)
b = Phi.T @ Xi @ r_pi
theta_lstd = np.linalg.solve(A, b)
v_lstd = Phi @ theta_lstd
v_exact = np.linalg.solve(np.eye(3) - gamma * P_pi, r_pi)
print(f"LSTD solution: theta = ({theta_lstd[0]:.4f}, {theta_lstd[1]:.4f})")
print(f"\n{'State':<8} {'Exact':<12} {'LSTD':<12} {'Error':<12}")
print("-" * 44)
for s in range(3):
print(f"{s+1:<8} {v_exact[s]:<12.4f} {v_lstd[s]:<12.4f} {v_lstd[s] - v_exact[s]:<12.4f}")
# Verify orthogonality
residual = r_pi + gamma * P_pi @ v_lstd - v_lstd
print(f"\nGalerkin orthogonality: <residual, phi_1> = {np.sum(xi * residual * Phi[:,0]):.6f}")LSTD solution: theta = (12.2772, -0.9901)
State Exact LSTD Error
--------------------------------------------
1 10.0207 11.2871 1.2664
2 10.8717 10.2970 -0.5746
3 8.3418 9.3069 0.9652
Galerkin orthogonality: <residual, phi_1> = 0.000000
Exercises: LSTD
Computing the stationary distribution. For the 3-state chain above, compute the stationary distribution satisfying .
LSTD with stationary weighting. Recompute the LSTD solution using the stationary distribution instead of uniform weighting. Compare the approximation error.
Comparing the Two Conditions on One Chain¶
The two families of results certify different projections. To see them side by side, the next cell takes the policy-evaluation chain of the third tab of Figure 3, discretizes it on 201 grid points, and adds a restart to a uniform state with probability 0.2 at each step (without it the chain never returns below , and its stationary distribution ignores the low states). For six projections with , it reports the sup-norm and -norm operator norms of , with stationary, the smallest entry of , the spectral radius of , the smallest real part of an eigenvalue of for the Galerkin methods, and the sup-norm error of the fixed point.
Source
import sys
from pathlib import Path
sys.path.insert(0, str(Path.cwd() / "code"))
import projection_stability as ps
rows = ps.chain_table(n=6)
cols = ("sup |P|", "xi |P|", "min entry", "rho(gamma P L)", "min Re eig A", "sup error")
print(f"{'projection':<34}" + "".join(f"{c:>15}" for c in cols))
for row in rows:
print(f"{row['method']:<34}" + "".join(f"{row[c]:>15.3f}" for c in cols))projection sup |P| xi |P| min entry rho(gamma P L) min Re eig A sup error
collocation, hats 1.000 7.314 -0.000 0.900 nan 0.366
collocation, polynomial 1.952 8.871 -0.348 0.900 nan 1.051
Galerkin, hats, uniform 1.955 1.159 -0.022 0.900 0.019 0.133
Galerkin, hats, stationary 2.410 1.000 -0.045 0.900 0.011 0.138
Galerkin, polynomial, stationary 4.442 1.000 -0.067 0.900 0.035 0.303
aggregation, uniform 1.000 1.159 0.000 0.900 0.017 0.605
Two rows have sup-norm operator norm one: the averagers, collocation with hats and aggregation, whose smallest entry is zero. Two rows have -norm one: the Galerkin projections with the stationary weighting. Each certificate holds where the theory says it should, and nowhere else. The Galerkin projections have sup-norm operator norm above one, since their smallest entries are negative, and the averagers have -norm operator norm above one. The spectral radius is 0.9 in every row, so on this chain the iteration converges even for polynomial collocation, whose sup-norm operator norm is about 2. The certificates are sufficient conditions, not necessary ones. A norm above one signals a risk, and the spectral radius decides whether the iteration diverges; the fishery showed that the same polynomial can make it diverge on another problem. Every Galerkin row, including the one with uniform weights, has with eigenvalues in the right half plane. The errors differ more than the stability does: Galerkin with hats is about three times more accurate than collocation with the same hats, and aggregation, the most stable fit, is the least accurate one.
Exercises: Projections and Norms
Aggregation is an averager. With indicator features of groups and any weighting , compute the Galerkin projection (11) entry by entry and show that is the -weighted average of over the group of . Conclude that fitted Q-iteration with aggregation converges for any sampling distribution.
Residual minimization as an oblique projection. Show that the tests turn the conditions into the normal equations of . Is the resulting of (11) fixed in advance, as it is for Galerkin and collocation?
One feature, one condition. In the two-state counterexample with weights , compute and show that the fitted factor equals , so that fitted evaluation converges if and only if .
Why the Maximum Breaks the Weighted Argument¶
The weighted argument does not extend to the optimality operator , and the obstacle is the Jensen step. For the optimality operator we would need to bound , and a maximum of averages is not an average. Nor is there a single stationary distribution to match, since the greedy policy, and with it the state distribution, changes from iteration to iteration. The failure goes beyond the proof: Farias & Van Roy (2000) give examples in which the projected optimality equation with a -weighted Galerkin projection has no solution at all, so that no algorithm can converge to one.
Optimal stopping is the exception that confirms the diagnosis. With a stopping reward and a continuation chain that the decision does not affect, the operator is , the maximum taken state by state. A maximum with a fixed function is a nonexpansion, , so the Jensen step goes through with the stationary distribution of , and is a -contraction in . Tsitsiklis & Van Roy (1999) use this to prove that a TD method with linear features converges for optimal stopping, with the pricing of high-dimensional financial derivatives as their application. The eight-dimensional problem of the next chapter (Example: A Stopping Problem in Eight Dimensions) has this structure: the coordinates move the same way whether the agent stops or not.
The table collects what this chapter proves or cites for function iteration , by operator and by fit. With an averager the weighting of the data plays no role.
| Operator | Averager | Linear features, on-policy weighting | Linear features, other weighting |
|---|---|---|---|
| Evaluation | Sup-norm contraction, converges Gordon (1995) | -norm contraction, converges Tsitsiklis & Van Roy (1997) | No guarantee, can diverge Baird (1995) |
| Optimal stopping | Sup-norm contraction, converges | -norm contraction, converges Tsitsiklis & Van Roy (1999) | No guarantee |
| Optimality | Sup-norm contraction, converges Gordon (1995) | No guarantee, the projected equation may have no solution Farias & Van Roy (2000) | No guarantee |
A nonlinear fit such as a neural network is not covered by any column: the guarantees left to it are the error bounds that assume each fit is accurate.
Approximate Policy Iteration¶
In the exact setting, Newton’s method on the Bellman equation is policy iteration (Newton-Kantorovich and Policy Iteration): by the envelope theorem the Jacobian at involves the transition matrix of the greedy policy , and the Newton step solves the evaluation equation of . The previous chapter showed the same for collocation, where the Newton step (32) is the evaluation equation of imposed at the nodes and solved within the span of the basis. With an arbitrary parametric value function the pattern is the same, except that the evaluation is done within the function class by whatever means are available. The algorithm alternates approximate evaluation, finding with , and greedy improvement. This is approximate policy iteration. Its guarantee is an error bound rather than a contraction: if every evaluation is accurate to in the sup norm, the policies are eventually within of optimal Bertsekas & Tsitsiklis (1996). Unlike exact policy iteration, the sequence of policies need not improve monotonically, and it can cycle among a few policies. With the smooth Bellman operator, the Jacobian is for the softmax policy, with no ties to resolve (Smooth Policy Iteration Is Newton’s Method).
When the evaluation has no closed form, as with a neural network, the natural replacement is a few sweeps of fitted policy evaluation, , which is what the critic of NFQCA does.
Convergence Results for the Optimality Equation Across Fields¶
Reinforcement learning came late to this question. Operations researchers, control theorists, numerical analysts and economists solved Bellman optimality equations on continuous state spaces long before fitted Q-iteration, and each community proved convergence results for approximate solutions. Read side by side, they agree on one point. The guarantees that hold with the maximum are sup-norm guarantees for monotone approximations, as in Averagers Preserve the Sup-Norm Contraction; the others are special cases, or error bounds that assume the approximation is accurate.
Discretized dynamic programs. The oldest results replace a continuous-state problem by one on a finite grid and ask whether the solution converges as the grid is refined. Fox (1973) gave conditions for convergence on compact state spaces, and Bertsekas (1975) proved convergence of discretized value functions and policies under Lipschitz-type continuity conditions. Whitt (1978) bounded the error of replacing a problem by a smaller one built on a partition of the states and actions: the value of the small problem, extended to the original states, is within of in the sup norm, where measures how much the rewards and transitions vary within a cell. This is the bound of Theorem 1 for the averager that aggregation is. Chow & Tsitsiklis (1991) showed that refining the grid from coarse to fine, a one-way multigrid method, reaches a given accuracy with an amount of work that matches the complexity of the problem up to constants. For aggregation, Van Roy (2006) bounds the loss of the greedy policy by the variation of within each group, and Bertsekas (2011) points out that approximate policy iteration with aggregation evaluates each policy exactly on an aggregate MDP, so its policies do not oscillate.
Monotone schemes for Hamilton–Jacobi–Bellman equations. In continuous time the Bellman equation is a partial differential equation, and its finite-difference and semi-Lagrangian discretizations are again fixed-point equations with a maximum. The Markov chain approximation method of Kushner & Dupuis (2001) builds the discretization as a controlled Markov chain on the grid. Its transition probabilities are the weights of the scheme, nonnegative and summing to one, so the scheme is an averager by construction, and value iteration on it converges. Falcone (1987) analyzed a grid-based discrete-time approximation of a discounted deterministic control problem, in which the value at a node is computed by interpolating the current values at the successor point, and proved that it converges to the value function as the time step and the mesh go to zero. Barles & Souganidis (1991) gave the general principle: a scheme that is monotone, stable and consistent converges to the viscosity solution whenever the limiting equation satisfies a comparison principle. Their monotonicity is the monotonicity in the definition of an averager: the computed value at a node must not decrease when a neighboring value increases. Munos & Moore (2002) brought these variable-resolution triangulations into reinforcement learning.
Numerical dynamic programming in economics. Economists met the same question when solving growth and investment models Rust (1996). Santos & Vigo-Aguiar (1998) proved that value iteration with piecewise-linear interpolation converges and bounded its error in terms of the mesh size, a special case of Theorem 1. Stachurski (2008) extended the argument to any nonexpansive approximation on a continuous state space, which covers kernel averagers and variation-diminishing splines. On the Newton side, Santos & Rust (2004) proved that policy iteration with piecewise-linear interpolation converges quadratically under regularity conditions, and superlinearly under weaker ones. Projection methods with global bases, Chebyshev collocation and Galerkin Judd (1992), are accurate and fast when they work, and they come with no convergence guarantee for the iteration, which is the fishery’s experience. The response of this literature was shape preservation: interpolants that keep the monotonicity and concavity of the data Cai & Judd (2012). They are nonlinear in the data and not covered by the averager theorem, but they remove the oscillations that give polynomial interpolation a Lebesgue constant above one.
Policy evaluation and optimal stopping. The weighted route of Linear Policy Evaluation: Convergence in the Stationary-Distribution Norm gives a contraction for the evaluation operator of the policy whose stationary distribution weights the fit, and for optimal stopping Tsitsiklis & Van Roy (1999). It gives none for the general optimality operator, where the projected equation may have no solution Farias & Van Roy (2000).
| Approach | Covers the maximum? | Assumption | Conclusion |
|---|---|---|---|
| Monotone discretization, averagers | Yes | Nonnegative weights that sum to one | Contraction, unique fixed point, convergence as the grid is refined |
| Aggregation and partition bounds | Yes | Small variation of the data within each cell | Error bound |
| Policy iteration on a monotone discretization | Yes | Regularity of the model | Quadratic or superlinear convergence |
| Global bases (Chebyshev, Galerkin) | Only special cases | Policy evaluation on-policy, optimal stopping | No general guarantee for the iteration |
| Error propagation | Yes | Each fit accurate | Error bound, no convergence claim |
Function iteration can therefore rely on two kinds of guarantee. A monotone fit inherits the contraction. Any other fit has only error bounds, which hold for any fit but assume that each fit is accurate; the chapter on fitted value methods states them for an arbitrary regressor.
Exercises¶
These exercises complement the shorter ones inside the sections and follow the order of the chapter.
Solution to Exercise 1
Yes: weights on the five nearest training states, zero elsewhere.
Yes: the weights are positive and normalized to sum to one, and they depend only on the states.
No. The prediction at is with , which is negative for training states on the far side of the mean when is far from . The weights do sum to one, so constants are preserved, but monotonicity fails.
Yes, from the iteration at which the splits are frozen: each prediction is the average of the targets in a fixed leaf.
No. The prediction is not a fixed linear function of the targets at all, and nothing constrains its sign or normalization.
Solution to Exercise 2
For : , then greedy for . With each sweep uses the operator of the policy that is greedy for the current values, which is fitted value iteration; is approximate policy iteration with fitted policy evaluation as the evaluation step.
: NFQCA is the fitted value iteration end of the range, with the maximization in the target done by the actor.
Every fit adds an error, and for a nonlinear fit nothing guarantees that repeated fitted evaluation of a fixed policy converges; with off-policy data it can diverge, as the next chapter shows. Many sweeps on a policy that is about to change also spend computation on accuracy that the next improvement discards.
Summary and Outlook¶
Function iteration on the Bellman optimality equation, , is value iteration with a fit after each backup, and the fit can make the composition fail to be a contraction. It did so on the fishery with ten Chebyshev coefficients, and on a two-state problem whose value function the features represent exactly. Fits that only average their targets cannot: grid interpolation with hat functions, aggregation, nearest neighbors, normalized kernels and fixed-partition trees keep the iteration a contraction, with the maximum and from any set of states. For policy evaluation with linear features, least squares weighted by the stationary distribution of the policy is also safe, and LSTD solves the resulting Galerkin system directly, but that argument breaks with the maximum. Newton’s method becomes approximate policy iteration. The older literatures on discretized dynamic programs, monotone schemes for Hamilton–Jacobi–Bellman equations and numerical dynamic programming in economics reach the same conclusion: with the maximum, the guarantees are for monotone approximations, and the rest are special cases or error bounds that assume each fit accurate.
Every result of this chapter assumed a known model, exact expectations and states chosen by the designer. Fitted value methods drops all three: the expectations become sample averages, the states become the data at hand, and action values remove the model from decision time. The fit, meanwhile, becomes any regressor, and its error is controlled by bounds that ask only that each fit be accurate.
- Tsitsiklis, J. N., & Van Roy, B. (1996). Feature-based methods for large scale dynamic programming. Machine Learning, 22(1–3), 59–94.
- Boyan, J. A., & Moore, A. W. (1995). Generalization in reinforcement learning: Safely approximating the value function. Advances in Neural Information Processing Systems 7, 369–376.
- Judd, K. L. (1992). Projection methods for solving aggregate growth models. Journal of Economic Theory, 58(2), 410–452.
- Judd, K. L. (1996). Approximation, perturbation, and projection methods in economic analysis. In H. M. Amman, D. A. Kendrick, & J. Rust (Eds.), Handbook of Computational Economics (Vol. 1, pp. 509–585). Elsevier.
- McGrattan, E. R. (1997). Application of Weighted Residual Methods to Dynamic Economic Models.
- Santos, M. S., & Vigo-Aguiar, J. (1998). Analysis of a numerical dynamic programming algorithm applied to economic models. Econometrica, 66(2), 409–426.
- Stachurski, J. (2009). Economic Dynamics: Theory and Computation. MIT Press.
- Gordon, G. J. (1995). Stable function approximation in dynamic programming. Proceedings of the Twelfth International Conference on International Conference on Machine Learning, 261–268.
- Gordon, G. J. (1999). Approximate Solutions to Markov Decision Problems [Phdthesis]. Carnegie Mellon University.
- Kushner, H. J., & Dupuis, P. (2001). Numerical Methods for Stochastic Control Problems in Continuous Time (2nd ed., Vol. 24). Springer.
- Rust, J. (1997). Using Randomization to Break the Curse of Dimensionality. Econometrica, 65(3), 487–516.
- Ormoneit, D., & Sen, Ś. (2002). Kernel-Based Reinforcement Learning. Machine Learning, 49(2/3), 161–178. 10.1023/a:1017928328829
- Munos, R., & Moore, A. (2002). Variable Resolution Discretization in Optimal Control. Machine Learning, 49(2–3), 291–323.
- Ernst, D., Geurts, P., & Wehenkel, L. (2005). Tree-Based Batch Mode Reinforcement Learning. Journal of Machine Learning Research, 6, 503–556.
- Johnson, S. A., Stedinger, J. R., Shoemaker, C. A., Li, Y., & Tejada-Guibert, J. A. (1993). Numerical Solution of Continuous-State Dynamic Programs Using Linear and Spline Interpolation. Operations Research, 41(3), 484–500.