Core idea: reinforcement learning is sequential decision-making, but many of its algorithms can be understood as optimization methods. Bellman equations are fixed-point optimization conditions, policy gradients are stochastic optimization algorithms, entropy-regularized methods use convex duality, and occupancy-measure formulations turn finite discounted MDPs into linear programs. This chapter organizes reinforcement learning through the language of optimization, geometry, and statistical approximation.
28.1 Learning goals
After reading this chapter, students should be able to:
explain how value-based, policy-based, and model-based reinforcement learning are optimization problems;
derive Bellman optimality equations from one-step optimization;
formulate finite discounted MDPs as linear programs;
derive the dual occupancy-measure formulation;
connect policy gradients with stochastic gradient ascent;
explain mirror descent, KL geometry, and entropy regularization on the policy simplex;
derive the natural policy gradient from a local KL-constrained optimization problem;
compare Euclidean gradients, mirror descent, and natural gradients;
recognize the role of nonconvexity, sampling noise, and distribution shift in modern RL optimization;
use AI tools responsibly to check derivations, dimensions, and assumptions.
28.2 25.1 Why optimization is central to reinforcement learning
In supervised learning, a common mathematical template is
Reinforcement learning is more subtle because the data distribution depends on the policy being optimized. A policy changes the future states that will be observed, so the objective is not merely a loss over a fixed dataset.
For a discounted MDP, a parameterized policy \(\pi_\theta\) has objective
More precisely, since \(T\) is a \(\gamma\)-contraction in the sup norm, the iteration
\[
V_{k+1}=TV_k
\]
converges to \(V^*\) for any initial vector \(V_0\).
This is optimization without gradients. The maximization over actions is local, and the fixed-point iteration propagates this local optimization through time.
28.3.1 Interactive: optimization landscape for a one-state policy
A one-state, two-action discounted MDP already gives a policy objective as a function of the action probability \(p=\pi(a_1)\). The shape may be simple, but the example helps students see that a policy is an optimization variable.
28.4 25.3 Exact finite MDP example
Consider a two-state MDP with two actions. We can evaluate every deterministic stationary policy and compare the resulting values.
This example uses brute-force optimization over deterministic policies. Brute force is not practical for large state spaces because the number of deterministic stationary policies is
\[
|A|^{|S|}.
\]
The combinatorial growth motivates dynamic programming and gradient-based methods.
28.5 25.4 Policy gradient as stochastic optimization
Let \(\pi_\theta\) be a differentiable policy. The policy-gradient theorem states that, under standard regularity assumptions,
The baseline does not change the expected gradient if it does not depend on \(A_t\).
28.5.1 Interactive: gradient ascent paths
This figure compares small and large step sizes for gradient ascent on a simple policy objective. The purpose is not to claim that RL objectives are always one-dimensional, but to visualize the optimization tradeoff between slow learning and unstable steps.
28.6 25.5 Geometry of the policy simplex
For a finite action space, a randomized policy at a state is a probability vector
When \(\psi(p)=\sum_a p(a)\log p(a)\), the induced Bregman divergence is KL divergence. Thus entropy geometry gives multiplicative policy updates.
Optimization lesson. Euclidean geometry is natural for unconstrained vectors. KL geometry is natural for probability distributions.
28.8 25.7 Natural policy gradients
The ordinary gradient depends on the parameterization. A small Euclidean parameter change may create a large policy change, or a large parameter change may create a small policy change.
Natural gradient methods measure policy change by KL divergence. Consider the local problem
28.9 25.8 Linear programming formulation of discounted MDPs
For a finite discounted MDP, the optimal value function is the solution of a linear program. The primal value-function formulation is
\[
\min_V \sum_s \mu(s)V(s)
\]
subject to the Bellman inequalities
\[
V(s)
\ge
r(s,a)+\gamma\sum_{s'}P(s'\mid s,a)V(s')
\quad
\text{for all }s,a.
\]
Here \(\mu\) is any probability distribution with positive mass on relevant states. At optimum, \(V=V^*\).
Why does this work? The inequalities say
\[
V\ge TV.
\]
The optimal value function \(V^*\) is the smallest vector satisfying these inequalities. Minimizing a positive weighted sum selects this smallest feasible upper bound.
28.9.1 Interactive: Bellman inequalities as feasible half-spaces
For a tiny MDP, the Bellman inequalities form a feasible region in value space. The optimal value is the smallest feasible vector in the appropriate partial order.
28.10 25.9 Occupancy measures and the dual linear program
The dual viewpoint optimizes over discounted state-action visitation measures. For a policy \(\pi\), define the discounted occupancy measure
As the temperature increases, the policy becomes more random. As it decreases, the policy approaches a greedy action.
28.12 25.11 Constrained reinforcement learning
Many applied problems require constraints. Examples include safety, budget, fairness, risk, or resource constraints. A constrained discounted MDP can be written as
This is mirror descent with negative entropy. It is mathematically close to entropy-regularized policy improvement.
The online-learning viewpoint helps explain exploration bonuses, optimism, posterior sampling, and adversarial robustness.
28.14 25.13 Nonconvexity and modern RL optimization
Tabular discounted MDPs have strong structure. The value-function LP is convex, and dynamic programming has global convergence. However, modern deep RL is usually nonconvex because policies and value functions are represented by neural networks.
Several difficulties arise:
Difficulty
Optimization issue
nonlinear function approximation
nonconvex loss surfaces
bootstrapping
moving targets
off-policy data
distribution mismatch
max operator
overestimation bias
exploration
objective is not fully observed
long horizon
high-variance gradients
A useful habit is to distinguish three kinds of error:
Optimization error comes from not solving the chosen empirical problem exactly. Statistical error comes from finite data. Approximation error comes from the fact that the chosen function class may not contain the true value function or optimal policy.
28.15 25.14 Python example: projected policy gradient on a bandit
The following example compares Euclidean projected gradient ascent with exponentiated-gradient ascent for a three-action bandit.
final projected-gradient policy: [1. 0. 0.]
final mirror-descent policy: [0.9154 0.0015 0.083 ]
best action: 0
The Euclidean projection quickly hits the boundary. Mirror descent approaches the best action multiplicatively and often gives smoother probability paths.
28.16 25.15 AI-assisted learning components
28.16.1 AI prompt: identify the optimization variable
Give an AI tool a paragraph describing an RL method and ask:
What is the optimization variable? Is the method optimizing over values, policies, model parameters, or occupancy measures? What constraints are present?
Then verify the answer yourself. Many RL descriptions hide the optimization variable behind algorithmic language.
28.16.2 AI prompt: check a Lagrangian derivation
Ask:
For the constrained problem \(\max_\pi J_r(\pi)\) subject to \(J_c(\pi)\le C\), derive the Lagrangian and the dual update. Check the sign of the multiplier update.
The sign is important. If the cost violates the constraint, the multiplier should increase.
28.16.3 AI prompt: compare Euclidean and KL geometry
Ask:
Explain why KL divergence is often more natural than Euclidean distance for policy optimization on the probability simplex. Give a two-action example.
Then check whether the response distinguishes parameter distance from distribution distance.
Derive the natural-gradient direction from the KL-constrained local optimization problem.
Show that the discounted occupancy measure satisfies the flow-conservation equations.
Derive the entropy-regularized maximizer \[
p^*(a)=\frac{\exp(q(a)/\alpha)}{\sum_b\exp(q(b)/\alpha)}.
\]
28.18.3 Computational exercises
Implement projected gradient ascent and mirror descent for a five-action bandit.
For a small MDP, compute \(V^*\) using value iteration and compare it with the solution of the Bellman inequality LP.
Estimate an occupancy measure from simulated trajectories and compare it with the matrix formula.
Implement natural policy gradient for a two-action logistic policy.
Simulate a constrained bandit and implement a primal-dual multiplier update.
28.18.4 AI-assisted exercises
Ask an AI tool to explain why entropy regularization produces a softmax policy. Then write your own derivation.
Give an AI tool a policy-gradient update and ask it to identify whether it is Euclidean, natural-gradient, or mirror-descent style.
Ask an AI tool to generate a small constrained MDP. Then verify whether the proposed constraints are mathematically well-defined.
Ask an AI tool to compare the primal and dual LP formulations for discounted MDPs. Check whether it correctly defines occupancy measures.
Ask an AI tool to debug a natural-gradient implementation where the Fisher matrix is singular. Propose a regularization fix.
28.19 Instructor notes
This chapter is a bridge between earlier algorithmic chapters and later statistical-learning/offline-RL chapters. For MA Applied Math students, emphasize fixed points, convex duality, Bregman divergence, and constrained optimization. For MS Statistics students, emphasize sampling noise, stochastic gradients, occupancy distributions, and finite-sample estimation. The chapter can be taught after policy-gradient and entropy-regularized RL, or earlier as a unifying perspective before advanced topics.