Infinite-horizon dynamic programming selects actions with a hard maximum. That operator is nondifferentiable at ties and produces a deterministic greedy choice. Can a modified control objective produce both a smooth Bellman operator and a stochastic optimal policy? Convex regularization supplies the link.
While the standard Bellman optimality equations use the max operator to determine the best action, an alternative formulation known as the smooth or soft Bellman optimality equations replaces it with a smooth approximation of the maximum. The history of these equations runs across two communities that rarely read each other. They appear in the work of the structural econometrician John Rust on the replacement of bus engines Rust (1987), together with an inverse problem and an algorithm to solve it. Ng & Russell (2000), who are usually credited with introducing inverse reinforcement learning, cite Rust, but the connection was then largely lost. Ziebart et al. (2008) rediscovered the same equations as maximum entropy inverse reinforcement learning, named after the maximum entropy principle. Haarnoja et al. (2017) built on Ziebart to obtain soft Q-learning, and soft actor-critic Haarnoja et al. (2018), one of the most widely used deep RL algorithms for continuous control, followed a year later.
In the infinite-horizon setting, the smooth Bellman optimality equations take the form:
We write for this smooth value function, to keep it apart from the optimal value of the hard Bellman equation.
Adopting an operator-theoretic perspective, we can define a nonlinear operator such that the smooth value function of an MDP is then the solution to the following fixed-point equation:
As , converges to the standard Bellman operator . Furthermore, it can be shown that the smooth Bellman operator is a contraction mapping in the supremum norm, and therefore has a unique fixed point. However, as opposed to the usual “hard” setting, the fixed point of is associated with the value function of an optimal stochastic policy defined by the softmax distribution:
The terminology is confusing: the “softmax” policy above is the smooth counterpart of the argmax in the original optimality equation, not of the max: it is a soft-argmax. The smooth counterpart of the max is the log-sum-exp. The same policy is also called a Boltzmann or Gibbs policy. As the temperature goes to zero, the softmax concentrates on the maximizing actions and we recover the greedy policy and the hard Bellman equation.
Stochastic Policies: Exploration and the Partition Function¶
Moving from the argmax to the softmax turns deterministic policies into stochastic ones, which is both useful and costly. It is useful because noise in the actions is a way to explore. In RL the agent usually gathers its own data, and if it always took the action it currently believes best it would never learn about the others. The problem is not specific to RL. An engineer identifying a model of a plant must also choose inputs that reveal the dynamics, and in system identification this is called exciting the system: a persistently exciting input is one rich enough for the parameters to be identifiable from the data.
It is costly when the action set is continuous. The softmax policy is then a density whose normalizing constant, the partition function , is an integral with no closed form in general. The log-sum-exp value has the same problem, since it is the logarithm of that integral. This is the intractable partition function familiar from energy-based models and probabilistic graphical models. Numerical quadrature is an option in low dimension but is rarely used. Haarnoja et al. (2017) sampled from the softmax policy over continuous actions with amortized Stein variational gradient descent, which proved expensive; soft actor-critic Haarnoja et al. (2018) instead fits a tractable parametric policy to the softmax, an idea we return to in the chapters on fitted value methods and policy learning. The notation for continuous actions, and what changes when sums become integrals, is in Continuous Action and State Spaces.
The smooth formulation has two advantages. First, a smooth operator is easier to optimize through. Unlike , we view as a hyperparameter of our algorithm, which we can control to achieve the desired level of accuracy.
Second, we presented the equations pragmatically, by replacing the max with the log-sum-exp (a smooth maximum) and the argmax with the softmax (a smooth argmax). The same equations come out of two other starting points, and this chapter follows all three routes:
Smoothing the operator. Replace every max by a log-sum-exp, as above. This is the route of the next subsection, and the justification is computational: a smooth operator has gradients everywhere.
Noise on the rewards. Keep the hard Bellman equation, but suppose that each action’s reward is perturbed by independent Gumbel noise that the decision maker sees and the modeler does not. Integrating the noise out gives the log-sum-exp (Gumbel Noise on the Rewards). This is how Rust (1987) motivated the equations, following the discrete choice models of econometrics.
Entropy regularization. Keep the rewards, but add a bonus proportional to the entropy of the policy in every state. The regularized Bellman equation is again the log-sum-exp equation (Regularized Markov Decision Processes). This is the reading behind maximum entropy RL and soft actor-critic.
Each route brings its own tools: smoothness gives differentiability, the noise model gives a likelihood for observed behavior, and the regularization view gives convex duality. A fourth reading, close to the third, starts from the energy-based models of supervised learning, where a softmax turns unnormalized scores into a distribution; this is essentially what Ziebart et al. (2008) did. It connects to probabilistic graphical models, where finding an optimal smooth policy becomes an inference problem. This is the idea of control as inference, whose converse, inference as control, is now used to derive samplers and amortized inference methods with RL Levine et al. (2018).
Smooth Value Iteration Algorithm¶
Before iterating , we should check that iterating it is the right thing to do, that is, that it is a contraction. It is, in the sup-norm and with the same factor as the hard Bellman operator. The proof uses the same three facts as for . The log-sum-exp is monotone, it commutes with adding a constant to all of its arguments, and maps a uniform shift of into a shift of . From we get , and exchanging and gives the contraction. A word of caution about the converse: failing to show that an operator is a contraction does not mean that its fixed point fails to exist or that no algorithm finds it. Contraction is a convenient sufficient condition, and other fixed-point theorems cover other cases.
Successive approximation applied to is smooth value iteration. It has the structure of value iteration, with a log-sum-exp wherever value iteration had a max and a softmax policy at the end where value iteration returned a greedy one.
Differences from standard value iteration:
Line 6 uses instead of
Line 10 extracts a stochastic policy using softmax instead of a deterministic argmax policy
As , the algorithm converges to standard value iteration
Lower values produce more stochastic policies with higher entropy
What the stopping rule guarantees. Because is a -contraction, the a posteriori bound of the Banach fixed-point theorem applies unchanged, and the stopping test of line 9 guarantees . The proof that value iteration returns an -optimal policy also carries over, with one change of meaning. The softmax policy satisfies for the entropy-regularized evaluation operator of Regularized Bellman Operators, with regularizer , just as a greedy policy satisfies . Repeating the proof of Proposition 2 with these operators shows that the returned policy is -optimal for the entropy-regularized objective. How far is that from optimal for the original rewards? Since , where is the largest number of actions in any state, the two fixed points satisfy
and the softmax policy returned by the algorithm loses at most against the optimal value of the unregularized MDP. The temperature therefore adds a bias that does not shrink with more iterations; it is the price of smoothness and of exploration.
Gumbel Noise on the Rewards¶
Why does adding independent Gumbel perturbations to action rewards produce a log-sum-exp value before the perturbation is observed?
We can obtain the smooth Bellman equation by considering a setting in which we have Gumbel noise added to the reward function. This derivation provides theoretical insight and also connects to practical modeling scenarios where rewards have random perturbations.
Step 1: Define the Augmented MDP with Gumbel Noise¶
At each time period and state , we draw an action-indexed shock vector:
These shocks are independent across time periods, states, and actions, and are independent of the MDP transition dynamics .
The Gumbel distribution with location parameter and scale parameter has probability density function:
To generate a Gumbel-distributed random variable, we can use inverse transform sampling: where is uniform on .
We now define an augmented MDP with:
Augmented state: where and
Augmented reward:
Augmented transition:
The transition factorizes because the next shock vector is drawn independently of the current state and action (conditional independence).
Step 2: The Hard Bellman Equation on the Augmented State Space¶
The Bellman optimality equation for the augmented MDP is:
Here the expectation is over the next augmented state , which includes both the next state and the next shock vector .
This is a perfectly well-defined Bellman equation, and an optimal stationary policy exists:
However, this equation is computationally intractable because:
The state space is continuous (uncountable), so is a function on a continuum
The shocks are fresh each period
We would need to solve for over an uncountable domain
We never solve this equation directly. Instead, we use it as a mathematical device to derive the smooth Bellman equation.
Step 3: Define the Ex-Ante (Inclusive) Value Function¶
The idea here is to consider the expected value before observing the current shocks. We define what some authors in econometrics call the inclusive value or ex-ante value:
This is the value of being in state before we observe the current-period shock vector .
Step 4: Separate the Deterministic and Random Components¶
Now we take the expectation of the augmented Bellman equation with respect to the current shocks only (everything that does not depend on the current can be pulled out).
First, note that by the law of iterated expectations and independence of shocks across time:
This follows from our definition of and the fact that the next shock is independent of everything else.
Now define the deterministic part of the right-hand side:
This is the expected return from taking action in state without the shock. Using this notation, the augmented Bellman equation becomes:
Taking the expectation over on both sides:
Step 5: Apply the Gumbel Random Utility Identity¶
We now invoke a result from extreme value theory:
Applying this identity to our problem (with mean-zero shocks):
Substituting the definition of :
We have arrived at the smooth Bellman equation.
The closed form is what singles out the Gumbel distribution. For other shock distributions, the expected maximum is still a smooth function of the , but it rarely has a closed form. With Gaussian shocks, for example, it has none beyond two actions, and computing it requires integrating over the continuous noise, which is the computation the construction was meant to avoid. The lemma also states the underlying reason: the maximum of independent Gumbel variables with a common scale is again Gumbel, so the family is closed under the operation that the Bellman equation applies at every step.
Step 6: Summary of the Derivation¶
To recap the logical flow:
We constructed an augmented MDP with state where shocks perturb rewards
We wrote the standard Bellman equation for this augmented MDP (hard max, but over an uncountable state space)
We defined the ex-ante value to eliminate the continuous shock component
We separated deterministic and random terms:
We applied the Gumbel identity to evaluate in closed form as a log-sum-exp
The augmented MDP with shocks exists only as a mathematical device. We never approximate , never discretize , and never enumerate the augmented state space. The only computational object we work with is on the original (finite) state space, which satisfies the smooth Bellman equation.
Deriving the Optimal Smooth Policy¶
Now that we have derived the smooth value function, we can also obtain the corresponding optimal policy. The question is: what policy should we follow in the original MDP (without explicitly conditioning on shocks)?
In the augmented MDP, the optimal policy is deterministic but depends on the shock realization:
However, we want a policy for the original state space (not the augmented state). We obtain this by marginalizing over the current shocks, essentially asking: “what is the probability that action is optimal when we average over all possible shock realizations?”
Define an indicator function:
where as before.
The ex-ante probability that action is optimal at state is:
This is the probability that action achieves the maximum when utilities are perturbed by Gumbel noise.
Applying this result to our problem:
This is the softmax policy or Gibbs/Boltzmann policy with inverse temperature .
Properties:
As : the policy becomes deterministic, concentrating on the action(s) with highest (recovers standard greedy policy)
As : the policy becomes uniform over all actions (maximum entropy)
For finite : the policy is stochastic, with probability mass proportional to exponentiated Q-values
This completes the derivation: the smooth Bellman equation yields a value function , and the corresponding optimal policy is the softmax over Q-values.
The Original and Augmented MDPs Side by Side¶
The derivation moves between two decision problems. The first is the original MDP solved with the smooth Bellman equation, or equivalently with an entropy bonus (Regularized Markov Decision Processes). The second is the augmented MDP, in which the decision maker solves a hard Bellman equation but sees a fresh shock on every action’s reward. The table puts them next to each other. We write , which is the of the derivation.
| Original MDP, smooth Bellman equation | Augmented MDP, Gumbel shocks | |
|---|---|---|
| State | ||
| Noise | only the transitions | the transitions, plus a fresh i.i.d. Gumbel vector each period |
| Reward of action | , plus the bonus | |
| Transition | , with the Gumbel density | |
| Bellman equation | , a log-sum-exp | , a hard max |
| Optimal policy | stochastic, | deterministic, |
| Value | , with | |
| Who sees what | the agent and the modeler both see | the agent sees and ; the modeler sees only |
Figure 1 draws both problems as graphical models, one time slice after another.
Figure 1:(a) The original MDP under the softmax policy. The action is a random child of with conditional distribution . (b) The augmented MDP. A shock vector (dashed) is drawn independently each period, and the augmented state is (dotted boxes). The action is a deterministic function of the augmented state (double circle). The shock has no arrow into or . Integrating out of each slice of (b) gives (a).
The figure shows why the construction works. In panel (b), has a single child, the action , and the action is a deterministic function of . Integrating the shock out of slice therefore changes only the conditional distribution of :
by Lemma 2. Doing this in every slice turns graph (b) into graph (a): the two models give the same distribution over state-action trajectories . The missing arrows matter. If also influenced , or if the shocks were correlated over time, integrating them out would leave a dependence on the past, and the marginal process would no longer be an MDP in . Rust (1987) states this as a conditional independence assumption, and his estimator relies on it.
The rewards are not equal path by path. The augmented agent collects , while the original MDP pays and the entropy bonus. They are equal on average. Conditional on which action wins, the winning value has the same distribution whatever the winner is, a property of the Gumbel distribution. Its mean is by Lemma 1, so
The shock that the agent collects on the action it picks is, on average, . Averaging over gives , the entropy bonus. The per-action penalty that appears later in the regularized formulation is this expected shock, with . A rarely chosen action is chosen only when its shock is large, and the entropy bonus is the average of those large shocks.
Checking the Equivalence Numerically¶
The augmented MDP is a device for theory: it explains where the log-sum-exp comes from and gives a likelihood for observed choices, but nobody solves it to compute a policy. On a small problem we can still solve it by brute force and check that it gives the same answer as the original MDP. The cell below draws a random MDP with 5 states and 3 actions, sets and , and computes the solution in three ways.
Original MDP. Smooth value iteration with the log-sum-exp, then the softmax policy.
Original MDP, regularized reading. The value of that softmax policy with its entropy bonus, from the linear system .
Augmented MDP. Value iteration with the hard max on the ex-ante value, , with the expectation replaced by an average over 50,000 Gumbel draws and no log-sum-exp anywhere. We then simulate 20,000 episodes in which the agent sees fresh shocks at every step, takes the deterministic action , and collects .
import numpy as np
rng = np.random.default_rng(0)
n_states, n_actions, gamma, beta = 5, 3, 0.9, 2.0
P = rng.dirichlet(0.5 * np.ones(n_states), size=(n_states, n_actions)) # P[s, a, j]
r = rng.normal(size=(n_states, n_actions))
loc, scale = -np.euler_gamma / beta, 1 / beta # mean-zero Gumbel shocks
def smooth_max(q):
"""(1/beta) log sum_a exp(beta q), computed stably along the last axis."""
m = q.max(axis=-1)
return m + np.log(np.exp(beta * (q - m[..., None])).sum(axis=-1)) / beta
# Original MDP: smooth value iteration, then the softmax policy.
v = np.zeros(n_states)
for _ in range(500):
v = smooth_max(r + gamma * P @ v)
q = r + gamma * P @ v
pi = np.exp(beta * (q - v[:, None]))
entropy = -(pi * np.log(pi)).sum(axis=1)
# Original MDP, regularized reading: evaluate pi with its entropy bonus,
# (I - gamma P_pi) v = r_pi + H_pi / beta.
P_pi = np.einsum("sa,saj->sj", pi, P)
v_reg = np.linalg.solve(np.eye(n_states) - gamma * P_pi, (pi * r).sum(axis=1) + entropy / beta)
# Augmented MDP: hard Bellman equation, ex-ante value. The expectation over the
# current shocks is an average over n_draws fixed Gumbel draws; no log-sum-exp.
n_draws = 50_000
shocks = rng.gumbel(loc, scale, size=(n_draws, n_states, n_actions))
v_aug = np.zeros(n_states)
for _ in range(150):
v_aug = (r + gamma * P @ v_aug + shocks).max(axis=2).mean(axis=0)
q_aug = r + gamma * P @ v_aug
# Simulate the augmented MDP: the agent sees fresh shocks every step and takes
# the deterministic action argmax_a q_aug(s, a) + eps(a).
n_episodes, horizon = 20_000, 150
s = np.zeros(n_episodes, dtype=int)
returns = np.zeros(n_episodes)
visits = np.zeros((n_states, n_actions))
shock_total = np.zeros((n_states, n_actions))
cdf = P.cumsum(axis=2)
for t in range(horizon):
eps = rng.gumbel(loc, scale, size=(n_episodes, n_actions))
a = (q_aug[s] + eps).argmax(axis=1)
eps_a = eps[np.arange(n_episodes), a]
returns += gamma**t * (r[s, a] + eps_a)
np.add.at(visits, (s, a), 1)
np.add.at(shock_total, (s, a), eps_a)
s = (rng.random(n_episodes)[:, None] > cdf[s, a]).sum(axis=1)
freq = visits / visits.sum(axis=1, keepdims=True)
mean_shock = shock_total / visits
fmt = lambda x: " ".join(f"{y:6.3f}" for y in x)
lines = [
"Values v(s)",
f" original, smooth value iteration {fmt(v)}",
f" original, entropy-regularized eval {fmt(v_reg)}",
f" augmented, hard max over Gumbel draws {fmt(v_aug)}",
f" augmented, simulated return from s=0 {returns.mean():6.3f} +/- {2 * returns.std() / np.sqrt(n_episodes):.3f}",
"",
"Policy: softmax pi(a|s) vs. action frequencies of the augmented agent",
" s | softmax pi(.|s) | frequency in augmented MDP",
]
lines += [f" {i} | {fmt(pi[i])} | {fmt(freq[i])}" for i in range(n_states)]
lines += [
"",
"Shocks: -log pi(a|s)/beta vs. mean shock eps(a) when a is chosen",
" s | -log pi(.|s)/beta | mean chosen shock",
]
lines += [f" {i} | {fmt(-np.log(pi[i]) / beta)} | {fmt(mean_shock[i])}" for i in range(n_states)]
lines += [
"",
f" entropy bonus H/beta per state {fmt(entropy / beta)}",
f" mean chosen shock per state {fmt(shock_total.sum(1) / visits.sum(1))}",
]
print("\n".join(lines))Values v(s)
original, smooth value iteration 10.098 11.741 11.022 10.392 11.100
original, entropy-regularized eval 10.098 11.741 11.022 10.392 11.100
augmented, hard max over Gumbel draws 10.094 11.735 11.015 10.390 11.095
augmented, simulated return from s=0 10.116 +/- 0.026
Policy: softmax pi(a|s) vs. action frequencies of the augmented agent
s | softmax pi(.|s) | frequency in augmented MDP
0 | 0.373 0.589 0.038 | 0.374 0.588 0.038
1 | 0.707 0.112 0.181 | 0.707 0.112 0.181
2 | 0.091 0.747 0.162 | 0.091 0.746 0.163
3 | 0.600 0.365 0.035 | 0.600 0.365 0.035
4 | 0.879 0.001 0.120 | 0.880 0.001 0.119
Shocks: -log pi(a|s)/beta vs. mean shock eps(a) when a is chosen
s | -log pi(.|s)/beta | mean chosen shock
0 | 0.493 0.265 1.636 | 0.492 0.266 1.629
1 | 0.173 1.095 0.856 | 0.173 1.097 0.853
2 | 1.196 0.146 0.911 | 1.195 0.147 0.912
3 | 0.256 0.504 1.669 | 0.257 0.507 1.674
4 | 0.064 3.508 1.061 | 0.065 3.529 1.060
entropy bonus H/beta per state 0.402 0.400 0.366 0.396 0.187
mean chosen shock per state 0.402 0.399 0.367 0.398 0.187
The three value functions agree up to Monte Carlo error, which stays below 0.01 on values near 10, and the simulated return of the augmented agent from state 0 matches within its confidence interval. The augmented agent never randomizes, yet the frequencies of its actions reproduce the softmax probabilities to the third decimal. The last two blocks check the shock identity: the mean shock on a chosen action matches , and its average per state matches the entropy bonus. The cost explains why the Gumbel route stays theoretical. One brute-force sweep evaluates maxima, where the log-sum-exp needs exponentials, and the brute-force answer is still off in the third digit.
Regularized Markov Decision Processes¶
Which convex penalty on action distributions generates a desired smooth maximum through conjugate duality?
Regularized MDPs Geist et al. (2019) provide another perspective on how the smooth Bellman equations come to be. This framework offers a more general approach in which we seek to find optimal policies under the infinite horizon criterion while also accounting for a regularizer that influences the kind of policies we try to obtain.
The framework does not fix the regularizer. Any strongly convex function on the probability simplex yields a regularized Bellman operator, a contraction argument and an optimal policy, in the same way that the L2 penalty is only one of many regularizers in supervised learning. Different choices give different smooth maxima. A Tsallis entropy, for instance, gives policies that assign zero probability to sufficiently poor actions Lee et al. (2018). In practice the negative Shannon entropy is by far the most common choice: its conjugate and its optimal policy have closed forms, and it coincides with the Gumbel model of the previous section.
Let’s set up some necessary notation. First, recall that the policy evaluation operator for a stationary policy with decision rule is defined as:
where is the expected reward vector under policy , is the discount factor, and is the state transition probability matrix under . A complementary object to the value function is the q-function (or Q-factor) representation:
The policy evaluation operator can then be written in terms of the q-function as:
Legendre-Fenchel Transform¶
The workhorse behind the theory of regularized MDPs is the Legendre-Fenchel transform, also known as the convex conjugate. For a strongly convex function , its Legendre-Fenchel transform is defined as:
An important property of this transform is that it has a unique maximizing argument, given by the gradient of :
The gradient is also Lipschitz: if is -strongly convex, a change of moves the maximizing policy by at most times as much. A more strongly convex regularizer therefore makes the policy less sensitive to errors in . An important example of a regularizer is the negative entropy, which gives rise to the smooth Bellman equations as we are about to see. Scaled by the temperature , it is -strongly convex, so the softmax policy moves by at most times the change in (measuring in the sup norm and policies in the norm).
Regularized Bellman Operators¶
How do the regularizer and its convex conjugate alter Bellman evaluation, policy improvement, and their contraction properties?
With these concepts in place, we can now define the regularized Bellman operators:
Regularized Policy Evaluation Operator :
Regularized Bellman Optimality Operator :
It can be shown that the addition of a regularizer in these regularized operators still preserves the contraction properties, and therefore the existence of a solution to the optimality equations and the convergence of successive approximation.
The regularized value function of a stationary policy with decision rule , denoted by , is the unique fixed point of the operator equation:
Under the usual assumptions on the discount factor and the boundedness of the reward, the value of a policy can also be found in closed form by solving for in the linear system of equations:
where is the vector of regularization terms at each state.
The associated state-action value function is given by:
The regularized optimal value function is then the unique fixed point of in the fixed point equation:
The associated state-action value function is given by:
An important result in the theory of regularized MDPs is that there exists a unique optimal regularized policy. Specifically, if is a conserving decision rule (i.e., ), then the randomized stationary policy is the unique optimal regularized policy.
In practice, once we have found , we can derive the optimal decision rule by taking the gradient of the convex conjugate evaluated at the optimal action-value function:
Recovering the Smooth Bellman Equations¶
Under this framework, we can recover the smooth Bellman equations by choosing to be the negative entropy scaled by the temperature , and obtain the softmax policy as the gradient of the convex conjugate. Let’s show this explicitly:
Using the scaled negative entropy regularizer:
The convex conjugate:
Now, let’s write out the regularized Bellman optimality equation:
Substituting the expressions for and :
This matches the form of the smooth Bellman equation we derived earlier, with the log-sum-exp operation replacing the max operation of the standard Bellman equation. With , the unscaled negative entropy gives the same equation at unit temperature.
Furthermore, the optimal policy is given by the gradient of :
This is the familiar softmax policy we encountered in the smooth MDP setting.
Smooth Policy Iteration Algorithm¶
One identity links the log-sum-exp to the regularized evaluation operator. Let be the softmax of . Then
which one checks by substituting into the entropy. Line 6 of Algorithm 1 can therefore be written as “form the softmax policy, then add its expected and its entropy bonus”. Algorithms stated that way are sometimes called entropy-regularized value iteration, but they are smooth value iteration with the log-sum-exp expanded. Policy iteration is different: it evaluates each policy completely before improving it.
Properties of smooth policy iteration:
Entropy-regularized evaluation. Line 3 is the linear system for the regularized value of Regularized Bellman Operators, with the entropy vector on the right-hand side. Replacing the exact solve by a few sweeps of gives the smooth version of Algorithm 4.
Stochastic improvement. Line 7 uses the softmax instead of the argmax. As the method recovers standard policy iteration, and lower gives policies with more entropy. As in the hard case, the improvement does not need to be applied in every state for the method to make progress. The policy-iteration loops hidden inside actor-critic methods make use of this.
What the stopping rule guarantees. The residual in line 5 is nonnegative, because is the regularized value of and the softmax maximizes the regularized one-step objective, so . For any , the triangle inequality and the contraction property give , so
This is the a posteriori bound of Theorem 3 written for one step of from . Since is the exact regularized value of the current , the test of line 6 guarantees that itself is within of the optimal regularized value in every state. A test on the change of the policy, such as , would give no such guarantee.
Convergence. The algorithm converges to the unique optimal regularized value function and policy. Unlike standard policy iteration, it does not terminate after finitely many iterations: the softmax policies form a continuum and the iterates approach the optimum without reaching it, which is why the loop stops on a tolerance. The convergence is fast, since each iteration is a Newton step (Smooth Policy Iteration Is Newton’s Method).
Smooth Policy Iteration Is Newton’s Method¶
The link between policy iteration and the Newton-Kantorovich method (Newton-Kantorovich and Policy Iteration) is easier to see here than in the hard case, because is differentiable everywhere and there are no ties to worry about. The derivative of the log-sum-exp with respect to its arguments is the softmax, so the Fréchet derivative of at is
the transition matrix of the softmax policy. A Newton step on solves
At the softmax policy the log-sum-exp equals the expected plus the entropy bonus, . The right-hand side is therefore , and the Newton step is exactly the entropy-regularized evaluation of the softmax policy. Smooth policy iteration is the Newton-Kantorovich method applied to the smooth Bellman equation, without the semismooth machinery that the hard max requires.
The contrast also has a history. Puterman & Brumelle (1979) established the correspondence between policy iteration and Newton’s method for the hard Bellman equation, whose operator has no derivative where actions tie, before generalized derivatives for nonsmooth operators had become standard tools. The semismooth reading of Newton-Kantorovich and Policy Iteration was worked out much later Gargiani et al. (2022). For the smooth operator, the classical Newton-Kantorovich theory applies as is.
Rust (1987) solved his smooth Bellman equation this way. He did not call it policy iteration. He recognized an operator equation, a root-finding problem in a function space, and applied Newton-Kantorovich to it, after a few rounds of successive approximation to get close enough for Newton’s method to converge quickly.
Equivalence Between Smooth Bellman Equations and Entropy-Regularized MDPs¶
We have now seen three ways to arrive at the smooth Bellman equation: as a smoothed maximum, from Gumbel noise on the rewards, and as the optimality equation of a regularized MDP. The third one can be written as an optimization problem over policies, the form used by maximum entropy RL. With entropy weight , the entropy-regularized MDP is
Since , the entropy bonus in state is the average of a per-action term, and the objective equals
Entropy regularization therefore amounts to paying for taking action , a cost that is high for actions the policy rarely takes. Unlike the Gumbel shocks of Rust’s model, this is a deterministic transformation of the reward. This is the form that sample-based methods such as soft actor-critic estimate, since it only needs the probability of the action that was taken.
The two forms are equal in expectation but give different estimators. The first computes the entropy of exactly at every visited state, a sum or an integral over all actions. The second evaluates only at the sampled action. It is unbiased and cheaper, but noisier, because the randomness of now enters the penalty as well as the reward. Replacing a sampled quantity by its conditional expectation given the state is a variance reduction technique known in the simulation literature as conditional Monte Carlo. In the augmented MDP of The Original and Augmented MDPs Side by Side, the same quantity is the expected shock on the chosen action.
The Bellman optimality equation of this problem maximizes, in each state, over the distribution :
The inner problem is the convex conjugate of the scaled negative entropy, which we computed in “Recovering the Smooth Bellman Equations”. That reading came later. In reinforcement learning, around 2017 Haarnoja et al. (2017)Nachum et al. (2017)Schulman et al. (2017), the maximizer was found by hand: maximize subject to with a Lagrange multiplier . Setting the derivative with respect to to zero gives , so , and normalizing gives the softmax policy and the log-sum-exp value. The framework of regularized MDPs Geist et al. (2019) gives the same result without computation once the conjugate of the entropy is known. A direct check is also short, and it shows where the softmax policy comes from. Let be the softmax policy of at temperature ,
which is the softmax of from the start of the chapter, since . Taking the logarithm and multiplying by expresses through :
Substituting this into the per-action term gives
The first term on the right does not depend on . Now average both sides over . The first term is unchanged, because the probabilities sum to one. The average of the second term is, by definition, the Kullback-Leibler (KL) divergence between and ,
with the convention that actions with contribute zero. The ratio is always defined, since for every action. For any distribution we therefore get
Only the KL term depends on , so maximizing the left side over is the same as making the KL divergence as small as possible. The KL divergence is never negative: by Jensen’s inequality applied to the concave , . Both inequalities are equalities only when . The maximum is therefore attained by the softmax policy , and its value is , the right-hand side of the smooth Bellman equation. So the value function that solves the smooth Bellman equation is the optimal value of the entropy-regularized MDP, and the softmax policy is its optimal policy. The two descriptions differ only in how they present the problem: as smoothing the Bellman operator, or as trading off reward against policy entropy. Maximum entropy RL algorithms such as soft actor-critic use both, the smooth operator for its differentiability and the regularized objective to explain why the policy should stay stochastic.
The KL form is also what makes soft actor-critic Haarnoja et al. (2018) work with continuous actions. Over a continuous action set, has an intractable normalizing constant, but that constant does not depend on , so minimizing over a tractable family, Gaussian policies for instance, needs only and samples from . This is variational inference, the same device used to train variational autoencoders: a simple distribution is fitted to one that can be evaluated only up to a constant.
Continuous Action and State Spaces¶
What changes in the smooth Bellman equation when the sums over actions become integrals?
So far the action sets were finite. In control problems the action is usually a vector , a torque, a dose, a flow rate, and the state is often continuous too. The smooth Bellman equation carries over once we fix a reference measure on the actions. For a finite set, is the counting measure and integrals against it are sums. For a box or another bounded subset of , it is usually the Lebesgue measure . It can also be a probability measure, a prior policy . Continuous states only need the transition kernel to be written as a measure, . The table translates the notation of this chapter.
| Object | Finite and | Continuous and |
|---|---|---|
| Expected next value | ||
| Decision rule | probability vector | density with respect to , |
| Policy average | ||
| Entropy | , of either sign | |
| Smooth maximum | ||
| Optimal decision rule | softmax over | Gibbs density |
| Bias against the hard max | between 0 and per step | at most , but possibly negative; see below |
With this notation, the smooth Bellman equation reads
and the optimal decision rule is the Gibbs density , which integrates to one against because is the log-normalizer. The contraction argument of the smooth value iteration section uses only monotonicity and the constant shift, and both hold for the integral. The operator is therefore a -contraction in the sup norm, provided the integral is finite. With bounded rewards, it is finite when , for example a box of actions under the Lebesgue measure or any prior policy.
The variational form. The regularized reading also carries over. For any density with respect to , write . Then
as one checks by substituting . The left side is the regularized objective of Regularized Bellman Operators with . Since the KL divergence is nonnegative and vanishes only at , the maximum over is the log-integral and the maximizer is the Gibbs density. This is the continuous version of the Legendre-Fenchel pair (negative entropy, log-sum-exp), and in statistical physics it is called the Gibbs variational principle.
The reference measure matters. With a finite action set, relabeling the actions changes nothing. With continuous actions, the entropy depends on , and that dependence shows up in three ways.
Prior policies give KL regularization. If is a probability measure, then and the problem is KL-regularized RL: the agent is penalized for moving away from . In the finite case, the uniform prior gives , so entropy and KL regularization differ by a constant per state and have the same optimal policy.
Differential entropy has no floor. Under the Lebesgue measure, is the differential entropy, which is negative for concentrated densities: a Gaussian with variance in one dimension has , negative once . It also depends on the units of the action. Rescaling in adds to . That only shifts all values by a constant and leaves the policy unchanged, but a nonlinear change of variables, say from a torque to its logarithm, changes the optimal policy.
Unbounded action sets need care. If with the Lebesgue measure and bounded rewards, the integral diverges and the smooth Bellman equation has no solution. The remedies are a bounded action set (soft actor-critic squashes its Gaussian samples through a into a box), a prior policy as reference measure, or rewards that decrease fast enough in , such as a quadratic action cost.
How far from the hard maximum. The finite-action bound keeps only its upper half: , which gives when for all . The lower bound fails, because a set of actions of small volume contributes little to the integral even if it contains the maximizer. The right tool is Laplace’s method. If is twice differentiable with a unique maximizer in the interior of , and is positive definite, then under the Lebesgue measure
The gap to the hard maximum shrinks like , slightly slower than the rate of the finite case, and the Gibbs density concentrates around like a Gaussian with covariance .
Quadratic and linear-quadratic control. If is exactly quadratic in with , Laplace’s formula is exact. The Gibbs policy is the Gaussian and . Linear-quadratic problems are of this kind. With dynamics and reward , a quadratic value makes quadratic in with , which does not depend on . The log-determinant term is then a constant, so solves the same discounted Riccati equation as without regularization. The entropy-regularized LQR policy is Gaussian, with mean the usual linear feedback and covariance . The regularization adds exploration noise around the LQR controller, more of it along the directions where the cost is flat, and does not change the gain.
Gumbel shocks over a continuum. The augmented-MDP construction needs one shock per action. Over a continuum of actions we cannot attach independent shocks to every point, since the supremum of uncountably many independent Gumbel variables is infinite. The replacement is a Gumbel process Maddison et al. (2014): a random function on such that, for every measurable set , the maximum is Gumbel with location and unit scale, independently over disjoint sets. For such a process, is Gumbel with location , and its argmax has the Gibbs density. With the derivation of Gumbel Noise on the Rewards goes through with a random function in place of a random vector, and Figure 1 still describes the model. It is even less a computational object than in the finite case. Maddison et al. (2014) use it to build an exact sampler, A* sampling, but the algorithms for continuous control, soft actor-critic among them, work with the Gibbs density directly and approximate it with a parametric policy.
Rust’s Bus Engines and Inverse Reinforcement Learning¶
What can we learn about a decision maker’s goals from records of what they did?
Rust’s 1987 paper is worth reading for three reasons: it contains the smooth Bellman equation, it poses what is now called inverse reinforcement learning, and it solves that problem with a bilevel method that relies on implicit differentiation, a tool that became popular in machine learning three decades later for hyperparameter optimization.
The problem. Harold Zurcher was the superintendent of maintenance at the Madison Metropolitan bus company. Rust had his maintenance records: for each bus, the odometer reading each month, and the months in which Zurcher replaced the engine. Replacing an engine is expensive, while keeping an old engine running costs more and more as the mileage grows. The question was how Zurcher decided when to replace. Rust is a structural econometrician. Structural econometrics does not stop at predicting behavior; it posits a mechanism that generates it, here a decision maker solving an MDP, and fits the parameters of that mechanism to data. The fitted mechanism can then answer questions the data alone cannot, such as how behavior would change if the price of an engine changed.
The model. The state is the mileage since the last replacement, discretized into bins. Each month there are two actions, keep () or replace (). Keeping costs , increasing in ; replacing costs a fixed amount and resets the mileage. With parameters collecting and those of , the reward is and , and the mileage transitions are estimated directly from the odometer data. The data contradict any deterministic policy: two buses with the same mileage are sometimes treated differently. Rust’s answer was the Gumbel model of Gumbel Noise on the Rewards. Zurcher sees, in addition to , a shock for each action that the econometrician does not see, and acts optimally given both. Integrating out the shocks gives the smooth Bellman equation and the softmax choice probabilities
This is the second, deeper reason Rust used these equations. Besides being smooth, they follow from the random-utility models of McFadden (1974), the standard statistical basis of discrete choice in econometrics, in the same way that least squares follows from assuming Gaussian noise. In machine learning terms, McFadden’s conditional logit is multiclass logistic regression with a structural interpretation.
The estimator. Given observed pairs , maximize the log-likelihood . Every evaluation of requires solving the smooth Bellman equation for the current , so the problem is bilevel: an outer maximization over around an inner fixed-point problem. Rust called his algorithm the nested fixed point (NFXP) algorithm. The gradient of needs , which the implicit function theorem provides without differentiating through the iterations of the inner solver. Differentiating and using the derivative of from Smooth Policy Iteration Is Newton’s Method,
The matrix to invert is the one of policy evaluation, already factored by the Newton steps of the inner solver. For rewards linear in the parameters, , this derivative is the vector of expected discounted feature counts under the softmax policy, the quantity that Ziebart et al. (2008) matches to the empirical feature counts. The score of one observation is then
A network that contains a Bellman equation. Compare the estimator with behavioral cloning, which fits a policy to the same pairs by maximum likelihood. With discrete actions, behavioral cloning is a classification problem: the state enters a network (an MLP, a transformer, any architecture), the network outputs a distribution over actions, and backpropagation minimizes the cross-entropy loss. Rust’s estimator has the same data and the same loss. Only the network differs. The parameters define the reward , the reward enters the smooth Bellman operator, the operator is applied until it reaches its fixed point , and the output is the softmax of the resulting . The hypothesis that the decision maker solves an MDP is built into the architecture as an inductive bias, in the way that convolutions build translation structure into an image model.
Figure 2 draws the two estimators side by side.
Figure 2:(a) Behavioral cloning fits a generic network to state-action pairs, and backpropagation runs through a fixed number of layers. (b) Rust’s estimator uses the same data and loss, but its network maps the reward parameters through the Bellman operator, applied until , to the softmax policy. The gradient can return to through every Bellman layer (dashed, unrolled) or in one step by the implicit function theorem (solid), which holds only at the fixed point.
Such a network has, in effect, infinitely many layers, one per application of the Bellman operator, and there are two ways to differentiate through it. The first truncates the inner solver after iterations and backpropagates through all of them, as backpropagation through time does for a recurrent network. This is called unrolled differentiation. Its memory grows with , and the gradient inherits the truncation error. The second uses only the condition that defines the fixed point. Write it as . If is invertible at a solution, the implicit function theorem gives a differentiable map near that solution, with
Here , which is invertible for , and , which gives the formula used by NFXP. The formula holds at the fixed point and nowhere else. This is why NFXP solves the inner problem to high accuracy at every outer step, so that each evaluation of the likelihood costs a full solve, and why Rust invested in a fast inner solver: successive approximation, which converges from any starting point, followed by Newton-Kantorovich steps, which converge quadratically once close to the solution.
The constrained formulation. The bilevel problem can also be written as a single constrained problem: maximize jointly over and , subject to . Su & Judd (2012) proposed this formulation, known as mathematical programming with equilibrium constraints (MPEC), as an alternative to NFXP. A general-purpose constrained solver handles the Bellman equations, which then need to hold only at convergence rather than at every outer step. The price is a larger optimization problem, with one unknown per state in addition to .
The setup rests on strong assumptions, and naming them explains why inverse RL is hard in general.
Rationality. The decision maker is assumed to solve the MDP exactly. People do not; the literature on bounded rationality studies how they fall short, and Rust himself has written skeptically about whether people follow Bellman’s principle of optimality. The assumption is still a useful starting point, in the same way a linear model is.
Observability. Rust observes the state and the action. In many applications one or both are missing. With logged prices, for instance, an unchanged price may be a decision to keep it or simply the absence of a decision, and the action itself must be inferred, which makes the problem partially observable.
Identifiability. Many reward functions explain the same behavior equally well. With hard maxima, a constant reward makes every policy optimal, and adding a shaping term to any reward leaves the optimal policies unchanged Ng et al. (1999). The map from rewards to behavior is many-to-one, so the data can at best single out a set of candidate rewards. Structural econometrics restores identification by restricting the reward to a parametric family, fixing the discount factor and the scale , and normalizing one action’s reward. Whether such restrictions are acceptable depends on the goal: predicting what Zurcher would do under new engine prices is a weaker demand than recovering what he “really” wanted.
Inverse RL after Rust. Ng & Russell (2000) introduced inverse RL to machine learning, with rewards linear in features and a characterization of the rewards under which an observed policy is optimal. Generative adversarial imitation learning (GAIL) Ho & Ermon (2016) matches the distribution of state-action pairs with the help of an adversarial discriminator. The discriminator is sometimes read as a reward, but nothing requires it to be consistent with a Bellman equation, and the method is closer to behavioral cloning than to Rust’s estimator. Upside-down RL Schmidhuber (2019) and decision transformers Chen et al. (2021) go further in that direction: a sequence model trained on trajectories is conditioned on a desired return and asked to produce actions that achieve it. These methods imitate behavior without recovering a reward. Behavioral cloning also matters in robotics, where demonstrations collected by moving the robot by hand provide an initialization that RL then fine-tunes.
Recovering a reward remains useful when the goal is to explain behavior rather than to reproduce it. Route choice in transportation is an example. The recursive logit model Fosgerau et al. (2013) applies the Gumbel construction to a traveler moving link by link through a road network, and the estimated reward tells a planner which features of a route people value besides travel time.
Summary and Outlook¶
Entropy regularization replaces hard action selection with a smooth conjugate operator and produces a stochastic optimal policy. Gumbel perturbations, log-sum-exp Bellman updates, and regularized policy iteration describe the same construction from probabilistic, variational, and algorithmic viewpoints. Drawn as graphical models, the original MDP and the Gumbel-augmented MDP differ by one shock node per time step, and integrating it out recovers the softmax policy; the expected shock on the chosen action is the entropy bonus. The same equations hold for continuous actions once a reference measure is fixed, with integrals in place of sums and a Gibbs density in place of the softmax, and the choice of that measure becomes part of the model. Smooth policy iteration is Newton’s method on the smooth Bellman equation, and Rust’s nested fixed-point estimator uses the same derivative to recover reward parameters from observed behavior.
The same log-sum-exp form appears over whole trajectories in continuous time. Path-integral stochastic control examines systems driven by Gaussian disturbances whose Hamilton--Jacobi--Bellman equation becomes linear under a logarithmic transformation, so that optimal feedback can be estimated from weighted trajectories.
Smoothness changes the operator but does not remove the need to represent its unknown value function. How can an infinite-dimensional functional equation be reduced to finitely many coefficients and test conditions? Parametric value functions develops the general approximation machinery.
Self-checks¶
Solution to Exercise 1
Its probability concentrates on the maximizing action, so the soft policy approaches the ordinary greedy deterministic policy.
Solution to Exercise 2
Log-sum-exp is differentiable and blends information from all actions. A hard maximum is nondifferentiable at ties and passes local gradient information only through selected maximizers.
Solution to Exercise 3
From the shocks on the actions it picks. Given that action wins, its shock has mean , which is large for actions that rarely win. Averaging over the winning action gives , the entropy bonus.
Solution to Exercise 4
Dividing the action by 1000 subtracts from the differential entropy of every density, so every value shifts by the constant and the policy, mapped back to newton-metres, is unchanged. A logarithmic change of variables is nonlinear: the Lebesgue measure in the new variable is a different measure on torques, so the regularizer and the optimal policy both change.
- Rust, J. (1987). Optimal Replacement of GMC Bus Engines: An Empirical Model of Harold Zurcher. Econometrica, 55(5), 999–1033.
- Ng, A. Y., & Russell, S. J. (2000). Algorithms for Inverse Reinforcement Learning. Proceedings of the 17th International Conference on Machine Learning, 663–670.
- Ziebart, B. D., Maas, A. L., Bagnell, J. A., & Dey, A. K. (2008). Maximum Entropy Inverse Reinforcement Learning. Proceedings of the 23rd AAAI Conference on Artificial Intelligence, 1433–1438.
- Haarnoja, T., Tang, H., Abbeel, P., & Levine, S. (2017). Reinforcement Learning with Deep Energy-Based Policies. Proceedings of the 34th International Conference on Machine Learning, 70, 1352–1361.
- Haarnoja, T., Zhou, A., Abbeel, P., & Levine, S. (2018). Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. Proceedings of the 35th International Conference on Machine Learning (ICML), 1861–1870.
- Levine, S., Kumar, A., Tucker, G., & Fu, J. (2018). Reinforcement Learning as a Framework for Control: A Survey. arXiv Preprint arXiv:1806.04222.
- Geist, M., Scherrer, B., & Pietquin, O. (2019). A Theory of Regularized Markov Decision Processes. In K. Chaudhuri & R. Salakhutdinov (Eds.), Proceedings of the 36th International Conference on Machine Learning (Vol. 97, pp. 2160–2169). PMLR. https://proceedings.mlr.press/v97/geist19a.html
- Lee, K., Choi, S., & Oh, S. (2018). Sparse Markov Decision Processes with Causal Sparse Tsallis Entropy Regularization for Reinforcement Learning. IEEE Robotics and Automation Letters, 3(3), 1466–1473.
- Puterman, M. L., & Brumelle, S. L. (1979). On the Convergence of Policy Iteration in Stationary Dynamic Programming. Mathematics of Operations Research, 4(1), 60–69.
- Gargiani, M., Zanelli, A., Liao-McPherson, D., Summers, T. H., & Lygeros, J. (2022). Dynamic Programming Through the Lens of Semismooth Newton-Type Methods. IEEE Control Systems Letters, 6, 2996–3001. 10.1109/LCSYS.2022.3181213
- Nachum, O., Norouzi, M., Xu, K., & Schuurmans, D. (2017). Bridging the Gap Between Value and Policy Based Reinforcement Learning. Advances in Neural Information Processing Systems, 30, 2775–2785.
- Schulman, J., Chen, X., & Abbeel, P. (2017). Equivalence Between Policy Gradients and Soft Q-Learning. arXiv Preprint arXiv:1704.06440.
- Geist, M., Scherrer, B., & Pietquin, O. (2019). A Theory of Regularized Markov Decision Processes. Proceedings of the 36th International Conference on Machine Learning, 97.
- Maddison, C. J., Tarlow, D., & Minka, T. (2014). A* Sampling. Advances in Neural Information Processing Systems 27.
- McFadden, D. (1974). Conditional Logit Analysis of Qualitative Choice Behavior. In P. Zarembka (Ed.), Frontiers in Econometrics (pp. 105–142). Academic Press.