8. CMDPs, Duality & Lagrangian Methods
Constrained MDPs, occupancy measures, zero duality gap, primal-dual algorithms, PID Lagrangians, risk and state augmentation
This module assumes:
- MDPs, stationary and history-dependent policies, and discounted returns (Primer E)
- Lagrangian duality, Slater's condition, KKT, and complementary slackness (Module 2)
- Value functions, advantages, and discounted occupancy distributions (Primer E)
- Convex sets, convex functions, and probability simplices (Primer B)
- Linear programs and the geometry of feasible sets (Primer B)
- Policy gradients, natural gradients, and trust regions (Primer E)
- Conditional expectation and averaging random trajectories (Primer C)
- KL divergence, entropy, total variation, and Pinsker's inequality (Primer C)
- Discrete-time linear stability and eigenvalue moduli (Primer D)
- Quantiles, CVaR, and chance constraints (Primer C)
First build the core calculation: the constrained problem, occupancy measures, the Lagrangian, the updates. Try the Easy practice as you go, then the Medium applications. Then read the controller interpretation, tail-risk constraints and state augmentation. The RLHF section is an application comparison after the main constrained-MDP argument.
The Hard practice checks proofs and assumptions. The original longer exercises remain for a deeper pass. If a calculation stalls, follow its prerequisite review link and return after practising that skill.
Can you sum a discounted constant, distinguish a probability from a cumulative return, and explain the sign of a Lagrange multiplier?
Show hint
Use the geometric series, then the convention “maximize reward, constrain cost from above”.
Show worked check
With discount $1/2$, a constant cost $1$ gives total cost $1+1/2+1/4+\cdots=2$, not $1$. A normalized occupancy is a probability distribution; cumulative cost therefore has an extra factor $1/(1-\gamma)$. For an upper cost budget, $L=J_r-\lambda(J_c-d)$ with $\lambda\ge0$: a violation lowers the policy’s penalized reward. Review geometric series, discounted returns, and duality if any step is unfamiliar.
Book contents · Apply this chapter to a real decision · Glossary
1. Constrained MDPs
Module 7 encoded safety as a set to stay in and asked how large a penalty makes the safe set attractive (Module 7). The constrained-RL tradition of Module 1 takes the other road: keep the reward and the safety signal as separate quantities, bound the expected cumulative safety cost by a budget, and let the algorithm find the trade-off.
First, Paternain et al., NeurIPS 2019 point out that a hand-tuned weight $w$ on a penalty has no transparent relation to the constraint value the final policy will achieve, so tuning $w$ can be as hard as solving the problem.
Second, and stronger, Calvo-Fullana et al., IEEE TAC 2024 exhibit constrained problems that no fixed weighted combination of rewards solves (see Sections 3 and 7 below). A budget is also what an engineer can specify: "at most 25 hazard contacts per episode" is a requirement, "weight 0.37 on hazard contacts" is not.
Background used in the definition: policies (stochastic or deterministic, stationary or history-dependent) and discounted returns are in Primer E, value functions, $Q$-functions and advantages in Primer E, expectations over random trajectories in Primer C, and $\sup$ versus $\max$ over infinite sets in Primer B.
We stick to one convention throughout the section: maximise reward, costs bounded from above, $\lambda\ge 0$ the Lagrange multiplier of a cost constraint, $\rho_\pi$ the occupancy measure. The literature does not. The table translates the papers cited on this page; the translation rule is that a "utility" constraint $V_g(\pi)\ge b$ is the cost constraint with $c=-g$ and $d=-b$, with the multiplier unchanged.
| Paper | Objective | Constraint | Notation to translate |
|---|---|---|---|
| Altman 1999 | minimise cost $C_\alpha(\beta,u)$ | $D^k_\alpha(\beta,u)\le V_k$ | discount $\alpha$, initial law $\beta$, policy $u$, occupation measure $f_\alpha(\beta,u)$ normalised to a probability, so that his costs $C_\alpha=\langle f_\alpha,c\rangle$ carry the factor $(1-\alpha)$; $K$ constraints |
| Paternain et al. 2019, Ding et al. 2020/2023 | maximise $V_0(\pi)$ or $V_r^\pi(\rho)$ | $V_i(\pi)\ge c_i$, $V_g^\pi(\rho)\ge b$ | "utility" constraints; $\rho$ is the initial distribution in Ding et al., not the occupancy measure; Ding et al. 2023 call the utility $u$ and set $g:=u-(1-\gamma)b$, so their constraint reads $V_g^\pi(\rho)\ge0$ |
| Montenegro et al. 2024 (C-PG) | minimise $J_0(\upsilon)$ | $J_i(\upsilon)\le b_i$ | cost-minimisation with the Lagrangian $J_0+\langle\lambda,J-b\rangle$ maximised over $\lambda$ |
| Stooke et al. 2020, Ray et al. 2019 | maximise $J(\pi_\theta)$ | $J_C(\pi_\theta)\le d$ | our convention |
| Sootla et al. 2022 (Sauté) | minimise task cost | safety budget $d-\sum_t\gamma_l^t l(s_t,a_t)\ge 0$ | two discounts: $\gamma_c$ (task) and $\gamma_l$ (safety) |
| Chow et al. 2018 | minimise cost $V^\theta(x^0)$ | $\mathrm{CVaR}_\alpha(\text{cum.\ constraint cost})\le\beta$ (CVaR: Primer C) | $\alpha\to 1$ is the extreme tail (Section 6) |
Discounted, average, episodic. The discounted formulation above is the default in deep safe RL. Altman also treats the total-cost problem (for transient or absorbing models, or under uniform Lyapunov conditions; his Chs. 7–9) and the expected-average-cost problem ($\lim_T \frac1T\mathbb E\sum_{t\lt T}c$; for finite MDPs under a unichain assumption, his Ch. 4), which is the setting of Calvo-Fullana et al.; finite-horizon episodic tasks (Safety Gym: $T_{\rm ep}=1000$, $d=25$) are the undiscounted case $\gamma=1$ with a terminal time. The occupancy, LP and duality results of Sections 2–3 have counterparts in these settings, but only under such extra assumptions (a finite horizon also needs time-indexed occupancy measures and non-stationary policies), and the convergence rates of Section 4 are proved for the discounted case; we write the discounted case throughout. Some authors normalise returns by $(1-\gamma)$ so that they live in $[0,1]$ when rewards do; we do not, and we say so wherever a factor $(1-\gamma)$ appears. The three criteria are compared in Primer E; the Markov-chain terms used here are explained in the box below.
A state is absorbing if, once reached, it is never left, whatever the action. A state is transient if its expected number of visits is finite; a recurrent class is a closed group of communicating states that the chain keeps revisiting. A model is unichain if every stationary policy induces a single recurrent class, possibly with transient states; this makes long-run averages independent of where the chain starts. Example: a "working" state that eventually moves to an absorbing "finished" state has finite total cost if only working costs money, but absorption with probability one does not by itself bound the expected finishing time. That is why the total-cost problem needs more than bounded one-step costs.
Fact (a drift bound). Take a countable MDP with an absorbing set $A$, reached at the random time $T_A$, and zero costs after absorption. Suppose functions $W\ge0$ and $w\ge0$ satisfy, for every $s\notin A$ and every action $a$, $\ \mathbb E[W(s_{t+1})\mid s_t=s,a_t=a]\le W(s)-w(s)$, and that $\mathbb E_\mu W(s_0)\lt\infty$ and $|c(s,a)|\le Kw(s)$. Then every policy, history-dependent or not, has $\mathbb E^\pi_\mu\sum_{t\lt T_A}w(s_t)\le\mathbb E_\mu W(s_0)$, so its expected total cost is at most $K\,\mathbb E_\mu W(s_0)$ in absolute value; if $w\ge1$ outside $A$ this also bounds $\mathbb E\,T_A$. Proof sketch: $W$ is an account that loses at least $w(s_t)$ per step in expectation. Summing the drift inequality up to time $n$ telescopes to $\mathbb E\sum_{t\lt\min(n,T_A)}w(s_t)\le\mathbb E W(s_0)-\mathbb E W(s_{\min(n,T_A)})\le\mathbb E W(s_0)$, and $n\to\infty$ is allowed because the terms are nonnegative. Because the inequality holds for every action, the bound holds for every policy. Altman's "uniform Lyapunov" conditions for the total-cost problem are drift conditions of this probabilistic kind (Altman 1999, Chs. 7–9), not the deterministic stability tests of Primer D. None of this is needed for the discounted derivations on this page.
Why the optimal policy is usually stochastic
An unconstrained discounted MDP with finitely many states and actions always has a deterministic optimal stationary policy (in general spaces an optimum need not even exist; see the definition above). A CMDP typically does not. Consider two states that alternate deterministically, $s_1\to s_2\to s_1\to\cdots$, whatever the action (two recurring phases of a task), $\mu=\delta_{s_1}$ (the point mass: start in $s_1$ with probability one; Primer C), $\gamma=\tfrac12$. In both states the agent chooses fast (reward 1) or slow (reward 0). Being fast costs $1$ in $s_1$ and $2$ in $s_2$ (the second phase is riskier), budget $d=1.2$. Write $p_1=\pi(\text{fast}\mid s_1)$, $p_2=\pi(\text{fast}\mid s_2)$. The discounted time spent in $s_1$ is $\sum_k\gamma^{2k}=\tfrac{1}{1-\gamma^2}=\tfrac43$ and in $s_2$ it is $\tfrac{\gamma}{1-\gamma^2}=\tfrac23$, so
The four deterministic policies give $(J_c,J_r)\in\{(0,0),\ (\tfrac43,\tfrac43),\ (\tfrac43,\tfrac23),\ (\tfrac83,2)\}$; only $(\text{slow},\text{slow})$ is feasible, with $J_r=0$. Randomising in $s_1$ with $p_1=0.9$, $p_2=0$ gives $J_c=1.2$ and $J_r=1.2$. The set of achievable $(J_c,J_r)$ pairs is the convex hull of the deterministic points, i.e. all their weighted averages (Primer B; Section 2 explains why), and the constrained optimum sits where the budget line cuts its upper boundary:
2. Occupancy Measures and the LP View
The CMDP problem is non-convex in the policy: $J_r(\pi)$ is a nonlinear function of the numbers $\pi(a\mid s)$ because they multiply along trajectories. The classical cure (Altman, Ch. 3) is to change variables to the occupancy measure, in which all returns become linear.
For nonnegative random variables $X_t$, Tonelli's rule gives $\mathbb E\sum_tX_t=\sum_t\mathbb E X_t$, allowing $+\infty$. For signed $X_t$, the same equality holds if $\mathbb E\sum_t|X_t|\lt\infty$ (absolute integrability). Here $|r_t|\le B$ implies $\sum_t\gamma^t|r_t|\le B/(1-\gamma)$, so the exchange is justified. For example, with $B=2$ and $\gamma=1/2$ the absolute sum is at most $4$. A finite bound prevents an undefined subtraction of two infinite sums.
The point is that $\rho_\pi$ is characterised by linear equations. Conservation of probability flow says: discounted mass at $s$ equals what starts there plus what flows in from the previous step.
Step 1 (Markov property). Conditioning on the state-action pair at time $t$, $$\mathbb P(s_{t+1}=s)=\sum_{s',a'}\mathbb P(s_t=s',a_t=a')\,P(s\mid s',a').$$ This uses only that the next state depends on the past through $(s_t,a_t)$; the policy can be history-dependent.
Step 2 (discount and sum). Multiply by $\gamma^{t+1}$ and sum over $t\ge0$; on the left the index shifts to $t\ge1$: $$\sum_{t\ge1}\gamma^t\,\mathbb P(s_t=s)=\gamma\sum_{s',a'}P(s\mid s',a')\sum_{t\ge0}\gamma^t\,\mathbb P(s_t=s',a_t=a').$$ Interchanging the two sums is legitimate because all terms are nonnegative.
Step 3 (add the start). The missing $t=0$ term on the left is $\mathbb P(s_0=s)=\mu(s)$, so $$\sum_{t\ge0}\gamma^t\,\mathbb P(s_t=s)=\mu(s)+\gamma\sum_{s',a'}P(s\mid s',a')\sum_{t\ge0}\gamma^t\,\mathbb P(s_t=s',a_t=a').$$
Step 4 (normalise). Multiply by $(1-\gamma)$ and recognise the definition of $\rho_\pi$ on both sides: $$\boxed{\ \rho_\pi(s)=(1-\gamma)\,\mu(s)+\gamma\sum_{s',a'}\rho_\pi(s',a')\,P(s\mid s',a')\quad\forall s\ }$$ Summing over $s$ gives total mass $M=(1-\gamma)+\gamma M$, i.e. $M=1$: the flow equations already encode normalisation.
- $\rho_\pi\in\mathcal Q(\mu)$ for every policy $\pi$, history-dependent or not.
- Conversely every $\rho\in\mathcal Q(\mu)$ is the occupancy measure of the stationary policy $$\pi_\rho(a\mid s):=\frac{\rho(s,a)}{\sum_{a'}\rho(s,a')}\qquad(\text{arbitrary where the denominator vanishes}).$$
- $\mathcal Q(\mu)$ is a closed convex polytope (a bounded set cut out by finitely many linear equalities and inequalities; Primer B) whose vertices are occupancy measures of deterministic policies.
Take $\rho\in\mathcal Q(\mu)$ and let $w=\pi_\rho$. Insert $\rho(s',a')=\rho(s')\,w(a'\mid s')$ into the flow equation: $$\rho(s)=(1-\gamma)\mu(s)+\gamma\sum_{s'}\rho(s')\underbrace{\sum_{a'}w(a'\mid s')P(s\mid s',a')}_{=:P_w(s\mid s')}.$$ In row-vector form $\rho^\top(I-\gamma P_w)=(1-\gamma)\mu^\top$. The stochastic matrix $P_w$ has spectral radius $1$, so with $\gamma\lt1$ the matrix $I-\gamma P_w$ is invertible and the state marginal is uniquely determined by $w$: $\rho^\top=(1-\gamma)\mu^\top(I-\gamma P_w)^{-1}$. But by part 1 the occupancy measure of $w$ itself satisfies the same equation, hence has the same marginal, $\rho_w(s)=\rho(s)$. Finally $\rho_w(s,a)=\rho_w(s)\,w(a\mid s)=\rho(s)\,w(a\mid s)=\rho(s,a)$. Part 3 follows because $\mathcal Q(\mu)$ is cut out by finitely many linear (in)equalities, and a standard extreme-point argument identifies its vertices with deterministic policies (Altman, Cor. 10.1).
Why $I-\gamma P_w$ is invertible. Index rows by the current state, $(P_w)_{s',s}=P_w(s\mid s')$. Every row is a probability vector, so $P_w\mathbf1=\mathbf1$ and $1$ is an eigenvalue. Each entry of $P_wv$ is an average of entries of $v$, so $\|P_wv\|_\infty\le\|v\|_\infty$ with $\|v\|_\infty=\max_s|v(s)|$ (Primer A); applied to an eigenvector, $P_wv=zv$, this gives $|z|\le1$. So the spectral radius of $P_w$ is $1$, every eigenvalue of $\gamma P_w$ has modulus at most $\gamma\lt1$, $1$ is not one of them, and $I-\gamma P_w$ is invertible.
Let $A$ be a finite real matrix of rank $r$. If the LP $\max q^Tx$ subject to $Ax=b$, $x\ge0$ is feasible and has a finite optimum, it has an optimal solution with at most $r$ positive entries. A solution whose positive columns are linearly independent is called basic. An inequality becomes an equality row by adding a nonnegative slack variable: the budget row $\langle\rho,c_i\rangle\le(1-\gamma)d_i$ becomes $\langle\rho,c_i\rangle+u_i=(1-\gamma)d_i$ with unused budget $u_i\ge0$.
Intuition: more than $r$ positive columns are dependent, so a small motion in a null direction preserves $Ax=b$ and positivity. At an optimum such a two-sided motion cannot improve the objective, so one can move until a positive entry reaches zero without changing the value. Repeat. In the occupancy LP there are at most $|\mathcal S|+m$ independent rows; subtracting one occupied action per visited state leaves at most $m$ extra actions. The next paragraph handles unvisited states.
The LP fact is standard; Altman 1999, Thm 3.8 applies it to CMDPs.
Three consequences that we will use. Randomisation count: the LP has $|\mathcal S|+m$ constraints besides $\rho\ge0$, so it has a basic optimal solution with at most $|\mathcal S|+m$ nonzero entries (slacks of the budget rows included). If every state is visited, each state uses at least one of them, which leaves at most $m$ extra entries, i.e. at most $m$ randomisations — Altman's bound with his $K=m$. If some states are never visited, their flow rows vanish on the support of $\rho$ (a zero-occupancy state receives no flow), so the same count runs over the visited states only and the conclusion is unchanged (Altman's proof removes those states); at unvisited states any deterministic action will do. Convex image: the zero-duality-gap proof of Section 3 rests on the convexity of $\mathcal Q(\mu)$, plus Slater's condition for continuity at the nominal budget. LP duality: the dual of this LP is the Lagrangian dual of the CMDP, and the dual variable of the budget row is the Lagrange multiplier $\lambda_i$.
Attach a free multiplier to each flow equality (we scale it as $V(s)/(1-\gamma)$ so that $V$ ends up with the units of a value function) and $\lambda_i\ge0$ to each budget row. The LP Lagrangian is $$\mathcal L(\rho,V,\lambda)=\frac{\langle\rho,r\rangle}{1-\gamma}+\sum_s\frac{V(s)}{1-\gamma}\Big[(1-\gamma)\mu(s)+\gamma\sum_{s',a'}\rho(s',a')P(s\mid s',a')-\sum_a\rho(s,a)\Big]+\sum_i\lambda_i\Big[d_i-\frac{\langle\rho,c_i\rangle}{1-\gamma}\Big].$$ Collect the coefficient of each $\rho(s,a)$ (rename summation indices in the transition term): $$\mathcal L=\langle\mu,V\rangle+\langle\lambda,d\rangle+\frac{1}{1-\gamma}\sum_{s,a}\rho(s,a)\Big[r(s,a)-\sum_i\lambda_ic_i(s,a)+\gamma\sum_{s'}P(s'\mid s,a)V(s')-V(s)\Big].$$ Maximise over $\rho\ge0$. The sup is $+\infty$ unless every bracket is $\le0$, in which case it is attained at $\rho=0$ and equals the constant. Hence the dual LP is $$\min_{V,\ \lambda\ge0}\ \langle\mu,V\rangle+\sum_i\lambda_id_i\quad\text{s.t.}\quad V(s)\ \ge\ r(s,a)-\sum_i\lambda_ic_i(s,a)+\gamma\sum_{s'}P(s'\mid s,a)V(s')\ \ \forall(s,a).$$ Read the constraint. It says $V\ge\mathcal T_\lambda V$ at every state, where $(\mathcal T_\lambda V)(s)=\max_a\big[r_\lambda(s,a)+\gamma\sum_{s'}P(s'\mid s,a)V(s')\big]$ is the Bellman optimality operator (Primer E) of the penalised reward $r_\lambda:=r-\sum_i\lambda_ic_i$. $\mathcal T_\lambda$ is monotone ($V\ge W$ implies $\mathcal T_\lambda V\ge\mathcal T_\lambda W$) and a $\gamma$-contraction, so applying it repeatedly to $V\ge\mathcal T_\lambda V$ gives $V\ge\mathcal T_\lambda V\ge\mathcal T_\lambda^2V\ge\cdots\to V^\star_\lambda$, and $V=V^\star_\lambda$ is itself feasible. With $\mu\ge0$ the inner minimisation therefore picks $V=V_\lambda^\star$, the optimal value of the penalised MDP (other minimisers can differ from it only at states with $\mu(s)=0$), and with $V^\star_\lambda(\mu):=\sum_s\mu(s)V^\star_\lambda(s)$ the dual LP collapses to $$\min_{\lambda\ge0}\Big[V^\star_\lambda(\mu)+\langle\lambda,d\rangle\Big]=\min_{\lambda\ge0}\max_\pi\Big[J_r(\pi)-\sum_i\lambda_i\big(J_{c_i}(\pi)-d_i\big)\Big],$$ which is the Lagrangian dual problem of Section 3. LP strong duality (a feasible LP with bounded value has no gap, and its dual optimum is attained) then gives $P^\star=D^\star$ for every feasible finite CMDP, with no Slater condition: this is the content of Altman's Theorem 3.6, which he proves by a minimax argument on the compact (closed and bounded, Primer 0) set of occupation measures. Paternain et al. reprove the zero gap for compact, continuous state and action spaces, where finite-dimensional LP duality is not available; their argument rests on the concavity of the perturbation function together with Slater's condition, and that is the content of the next section.
3. Lagrangian Relaxation and the Zero Duality Gap
Deep RL cannot manipulate occupancy measures directly: it has a parametrised policy $\pi_\theta$ and a gradient estimator (Primer E). The Lagrangian route keeps the policy as the variable and moves the constraint into the objective with a price $\lambda$.
Weak duality is two lines. For any feasible $\pi$ and any $\lambda\ge0$, every term $\lambda_i(J_{c_i}(\pi)-d_i)$ is $\le0$, so $L(\pi,\lambda)\ge J_r(\pi)$; taking the max over $\pi$ on the left and over feasible $\pi$ on the right gives $D(\lambda)\ge P^\star$ for every $\lambda\ge0$, hence $D^\star\ge P^\star$. Convexity is one line: $D$ is a pointwise maximum of functions $\lambda\mapsto L(\pi,\lambda)$ that are affine in $\lambda$, hence convex (Exercise 8.2 does the cost-minimisation mirror image, where the dual function is concave and the dual problem is a maximisation). So the dual problem is a convex program in $m$ variables. The question is whether its value is the CMDP value.
Statement. Then strong duality holds: $P^\star=D^\star$ (the proof below also shows that the dual minimum is attained).
In words. Although the CMDP is non-convex in $\pi$ (and infinite-dimensional for continuous spaces), the price $\lambda^\star$ that solves the convex dual problem is exact: penalising the costs with $\lambda^\star$ yields a Lagrangian whose maximum equals the constrained optimum. (A1) is what makes the returns finite and lets sums and integrals be exchanged; (A2) rules out constraints that are only just attainable, for which the multiplier can be unbounded and, in general (non-finite) spaces, the dual value could sit strictly above $P^\star$; for finite CMDPs the LP argument of Section 2 closes the gap even without Slater. "All randomised policies" matters: the proof mixes two policies, which a neural policy family need not allow, so the parametrised case below needs its own theorem.
Define the perturbation function $P(\xi):=\sup_\pi J_r(\pi)$ s.t. $J_{c_i}(\pi)\le d_i+\xi_i$ for $\xi\in\mathbb R^m$ (a maximum in the finite case), with $P(\xi)=-\infty$ when no policy is feasible. Then $P(0)=P^\star$, and $P$ is nondecreasing in each $\xi_i$ (looser budgets cannot hurt). The proof has three steps: express the dual function through $P$, show $P$ is concave, invoke Fenchel–Moreau.
Step 1: the dual function is the conjugate of $P$ (conjugates: Primer B). We claim $D(\lambda)=\sup_{\xi}\{P(\xi)-\langle\lambda,\xi\rangle\}$ for $\lambda\ge0$. ($\le$): for any $\pi$ put $\xi:=J_c(\pi)-d$; then $\pi$ is feasible for $P(\xi)$, so $J_r(\pi)\le P(\xi)$ and $L(\pi,\lambda)=J_r(\pi)-\langle\lambda,\xi\rangle\le P(\xi)-\langle\lambda,\xi\rangle$; maximise over $\pi$. ($\ge$): for any $\xi$ and any $\pi$ feasible for $P(\xi)$ we have $J_c(\pi)-d\le\xi$ componentwise, so with $\lambda\ge0$, $L(\pi,\lambda)\ge J_r(\pi)-\langle\lambda,\xi\rangle$; maximise over such $\pi$ to get $D(\lambda)\ge P(\xi)-\langle\lambda,\xi\rangle$. (Restricting to $\lambda\ge0$ loses nothing: if $\lambda_i\lt0$, sending $\xi_i\to\infty$ makes the sup $+\infty$ because $P$ is nondecreasing.)
Step 2: $P$ is concave. Take $\xi^1,\xi^2$ with $P$ finite, a mixing weight $\kappa\in(0,1)$ and a tolerance $\varepsilon'\gt0$. Pick policies $\pi_1,\pi_2$, feasible for the two perturbations, with $J_r(\pi_j)\ge P(\xi^j)-\varepsilon'$, and let $\rho_1,\rho_2\in\mathcal Q(\mu)$ be their occupancy measures. (In the finite case the occupancy LP attains the maxima and $\varepsilon'=0$ is allowed. Paternain et al. assume attainment in general, citing compactness of the set of occupation measures; compactness alone does not make a merely bounded reward attain its supremum, which is why we argue with near-maximisers.) Convexity of the set of occupancy measures gives a policy $\pi_\kappa$ with $\rho_{\pi_\kappa}=\kappa\rho_1+(1-\kappa)\rho_2$ (Section 2, part 2 of the theorem, in the finite case; for compact spaces Paternain et al. cite Borkar's convexity result for occupation measures). Returns are linear in $\rho$, so $$J_r(\pi_\kappa)=\kappa J_r(\pi_1)+(1-\kappa)J_r(\pi_2)\ge\kappa P(\xi^1)+(1-\kappa)P(\xi^2)-\varepsilon',\qquad J_{c_i}(\pi_\kappa)=\kappa J_{c_i}(\pi_1)+(1-\kappa)J_{c_i}(\pi_2)\le d_i+\kappa\xi_i^1+(1-\kappa)\xi^2_i .$$ Thus $\pi_\kappa$ is feasible for the perturbation $\kappa\xi^1+(1-\kappa)\xi^2$ and $P(\kappa\xi^1+(1-\kappa)\xi^2)\ge J_r(\pi_\kappa)\ge\kappa P(\xi^1)+(1-\kappa)P(\xi^2)-\varepsilon'$. As $\varepsilon'\gt0$ was arbitrary, this is concavity. Note that nothing about convexity in $\pi$ was needed: the mixture happens in occupancy space, where a mixture is again realisable. (If history-dependent policies are allowed, as in our definition of Section 1, the mixture is even more direct: draw $B\in\{1,2\}$ once at time zero with probabilities $\kappa$ and $1-\kappa$, remember it and follow $\pi_B$; conditioning on $B$ gives exactly the two displayed identities, with no occupancy-measure theorem.)
Let $F:\mathbb R^m\to\mathbb R\cup\{-\infty\}$ be concave and proper: finite somewhere (the value $-\infty$ is allowed; here it marks infeasible budgets). Put $D_F(q):=\sup_x\{F(x)-q^\top x\}$.
(i) If $F$ is also upper semicontinuous, $\limsup_{x_n\to x}F(x_n)\le F(x)$ at every $x$ (no downward jump at a point: $F(x)=1$ for $x\ne0$, $F(0)=0$ fails at $0$), then $F(x)=\inf_q\{D_F(q)+q^\top x\}$ for every $x$.
(ii) If $F$ is finite on a neighbourhood of $0$, it is continuous there and has a finite supergradient $q$ at $0$: $F(x)\le F(0)+q^\top x$ for all $x$. Then $D_F(q)=F(0)$, so the infimum in (i) at $x=0$ is attained at this $q$. If $F$ is nondecreasing in each coordinate, $q\ge0$: put $x=te_i$, $t\gt0$, into the supporting inequality.
Intuition: every affine function $x\mapsto D_F(q)+q^\top x$ lies above the concave graph; (i) says their lower envelope recovers $F$, and (ii) says that at an interior point one of them actually touches it.
Step 3: Fenchel–Moreau. By Step 1, $D^\star=\min_{\lambda\ge0}\sup_\xi\{P(\xi)-\langle\lambda,\xi\rangle\}$ is the value at $\xi=0$ of the biconjugate of $P$, the smallest concave upper-semicontinuous function above $P$. For a proper concave $P$ the biconjugate is its upper-semicontinuous hull and therefore agrees with $P$ at every point where $P$ is upper semicontinuous (Fenchel–Moreau; Paternain et al. package this step as their Proposition 1, citing Rockafellar's Convex Analysis, Cor. 30.2.2). $P$ is proper because (A1) bounds it above by $\sup|r|/(1-\gamma)$, and Slater's condition says $P$ is finite on a neighbourhood of $0$ (any $\xi$ with $\xi_i\gt-\xi_{\rm Slater}$ keeps $\bar\pi$ feasible); a concave function is continuous on the interior of its domain (the points with a whole small ball around them inside the set where it is finite; Primer 0). Hence $D^\star=P(0)=P^\star$. Part (ii) of the box gives more: Slater makes $P$ finite near $0$, so $P$ has a supergradient $q\ge0$ at $0$ ($P$ is nondecreasing), and $D(q)=\sup_\xi\{P(\xi)-\langle q,\xi\rangle\}=P(0)$. The dual minimum is attained, at $\lambda^\star=q$.
Geometric reading. The dual problem finds the best affine majorant $\xi\mapsto D(\lambda)+\langle\lambda,\xi\rangle$ of $P$ and evaluates it at $0$. If $P$ had a dent at $0$ (non-concave), the best majorant would sit above $P(0)$: a duality gap. Concavity removes the dent, and $\lambda^\star$ is a supergradient of $P$ at $0$: the shadow price of the budgets.
Proof. $D^\star=D(\lambda^\star)\ge L(\bar\pi,\lambda^\star)=J_r(\bar\pi)+\sum_i\lambda^\star_i\big(d_i-J_{c_i}(\bar\pi)\big)\ge J_r(\bar\pi)+\xi\|\lambda^\star\|_1$, and $D^\star=P^\star$. $\square$
This bound is what every primal-dual rate in Section 4 hides inside its constants: the projection interval $\Lambda=[0,2/((1-\gamma)\xi)]$ of NPG-PD is exactly twice this bound for rewards in $[0,1]$.
Parametrised policies: almost no price to pay
With a neural policy $\pi_\theta$ the maximisation in $D(\lambda)$ runs over $\theta$, and the dual value $D^\star_\theta$ can differ from $P^\star$. Paternain et al. bound the difference in terms of how expressive the class is.
Proof idea. Lemma 1 of the paper shows that the occupancy measures of $\pi$ and of its $\epsilon$-approximation differ by at most $\epsilon/(1-\gamma)$ in $L^1$ (the per-step error $\epsilon$ compounds geometrically); since $J=\langle\rho,r\rangle/(1-\gamma)$, their returns differ by at most $B\Delta_\epsilon$. For every $\lambda$, replacing a Lagrangian maximiser by its $\epsilon$-approximation therefore loses at most $(B_{r_0}+\|\lambda\|_1B_c)\Delta_\epsilon$: $D_\theta(\lambda)\ge D(\lambda)-(B_{r_0}+\|\lambda\|_1B_c)\Delta_\epsilon$, with $D_\theta$ the dual function of the parametrised problem. The $\lambda$-dependent part of the loss is exactly what turns $D$ into the dual function of the tightened problem (budgets $d_i-B_c\Delta_\epsilon$), $D_{\rm tight}(\lambda)=D(\lambda)-B_c\Delta_\epsilon\|\lambda\|_1$ for $\lambda\ge0$. Minimising over $\lambda\ge0$ and using weak duality $D(\lambda)\ge P^\star$ at the last step, $$D^\star_\theta\ \ge\ \min_{\lambda\ge0}D_{\rm tight}(\lambda)-B_{r_0}\Delta_\epsilon=D(\lambda^\star_\epsilon)-\big(B_{r_0}+B_c\|\lambda^\star_\epsilon\|_1\big)\Delta_\epsilon\ \ge\ P^\star-\big(B_{r_0}+B_c\|\lambda^\star_\epsilon\|_1\big)\Delta_\epsilon .$$ The upper bound $D^\star_\theta\le D^\star=P^\star$ holds because the $\pi_\theta$ form a subset of all policies, so $D_\theta\le D$ pointwise. (Primal reading: an $\epsilon$-approximation of an optimal policy of the tightened problem is feasible for the original one.)
Primal recovery: the right price is not the right policy
Zero duality gap means the values agree. It does not mean that a maximiser of $L(\cdot,\lambda^\star)$ solves the CMDP. The precise relation is one inclusion.
Proof. For $\pi^\star\in\Pi^\star$, feasibility and $\lambda^\star\ge0$ give $L(\pi^\star,\lambda^\star)\ge J_r(\pi^\star)=P^\star=D^\star=D(\lambda^\star)=\max_\pi L(\pi,\lambda^\star)$, so $\pi^\star$ attains the max, and the first inequality must be an equality, which forces each slack term to vanish. $\square$
The inclusion can be extremely loose. In the monitoring problem of Calvo-Fullana et al. (average reward; three states $R_0,R_1,R_2$; from $R_0$ the agent moves to $R_1$ or $R_2$, from $R_i$ it stays or returns to $R_0$; reward $\mathbf 1(s=R_0)$; constraints "spend at least a fraction $c=\tfrac13$ of the time in $R_1$ and in $R_2$", i.e. utility constraints $V_i\ge c$ in the paper's convention, costs $-\mathbf 1(s=R_i)$ with budget $-c$ in ours), an optimal policy flips a fair coin in every state and attains $P^\star=\tfrac13$ (the optimum is not unique: every policy whose long-run fractions are $(\tfrac13,\tfrac13,\tfrac13)$ is optimal). The dual optimum is $\lambda^\star=(1,1)$, and there the penalised reward is $\mathbf 1(R_0)+\mathbf 1(R_1)+\mathbf 1(R_2)-\tfrac23\equiv\tfrac13$: every policy maximises the Lagrangian, including "stay in $R_1$ forever", which violates the $R_2$ constraint. For any $\lambda\ne(1,1)$ no maximiser is optimal: with $\lambda_1\ne\lambda_2$ every maximiser abandons one region entirely ($V_1=0$ or $V_2=0$: infeasible), with $\lambda_1=\lambda_2\lt1$ the maximisers return to $R_0$ at once ($V_1+V_2=\tfrac12$: infeasible), and with $\lambda_1=\lambda_2\gt1$ every maximiser has $V_0=0$, hence zero return. The stationary maximisers enter a region and never leave (feasible in expectation only if the probability $q$ of entering $R_1$ lies in $[\tfrac13,\tfrac23]$, and even then every single trajectory starves one region). A history-dependent maximiser can instead shuttle between $R_1$ and $R_2$ in ever longer blocks, which meets both visit constraints on every trajectory but still earns zero return. So no fixed weighted reward identifies the solution; the multiplier is exact and useless at the same time (Exercise 8.6). The structural reason was stated in Section 1: finite penalised MDPs have deterministic optima, CMDPs often do not, so whenever the CMDP optimum must randomise, $\Pi(\lambda^\star)$ must contain several policies and the algorithm has to select among them.
From chance constraints to CMDP constraints with a safety guarantee
The constraints of a CMDP are expectations, while a safety requirement is usually "the trajectory stays in the safe set with probability at least $1-\delta$". Paternain, Calvo-Fullana, Chamon, Ribeiro, IEEE TAC 2023 show how to choose the budget so that the CMDP relaxation implies the chance constraint; the tool is the union bound over time steps (Primer C).
Let $E_t=\{s_t\in S_i\}$. The complement of "safe at all times" is the union of the per-step failures, so by Boole's inequality $$\mathbb P\Big(\bigcap_{t=0}^{T}E_t\Big)=1-\mathbb P\Big(\bigcup_{t=0}^{T}E_t^c\Big)\ \ge\ 1-\sum_{t=0}^{T}\mathbb P(E_t^c)=1-\sum_{t=0}^{T}\big(1-\mathbb P(E_t)\big)=1-(T+1)+U_i(\theta).$$ Feasibility $U_i(\theta)\ge T+1-\delta_i$ makes the right-hand side at least $1-\delta_i$. $\square$ The price of the relaxation is visible: the expected number of safe steps must be within $\delta_i$ of the maximum $T+1$, i.e. the per-step failure probabilities must be tiny on average. The survey of Wachi, Shen, Sui, IJCAI 2024 states the same fact in general: an expected-cumulative constraint on indicator costs is a conservative approximation of a joint chance constraint, by Boole.
Discounted case. Let $F=\sum_{t\ge0}\gamma^t\,\mathbb P(s_t\notin S_i)=\frac1{1-\gamma}-U_i(\theta)$. The threshold $c_i=\frac1{1-\gamma}-\delta_i\gamma^{T_i}$ of Theorem 2 gives $F\le\delta_i\gamma^{T_i}$. For $t\le T_i$ we have $\gamma^{t-T_i}\ge1$, so $\sum_{t=0}^{T_i}\mathbb P(s_t\notin S_i)\le\gamma^{-T_i}F\le\delta_i$, and the same union bound gives safety up to time $T_i$, not beyond.
4. Primal-Dual Algorithms and Their Convergence
The dual problem is convex and $m$-dimensional, so we would like to run (sub)gradient descent on $D(\lambda)$. The only obstacle is evaluating $D(\lambda)$, which is itself an RL problem. Danskin's theorem tells us what the gradient is once that RL problem is solved.
- Initialise $\theta_0$, $\lambda_0=0$, step $\eta$.
- For $k=0,1,\dots$:
- $\theta_{k+1}\approx\operatorname*{arg\,max}_\theta L(\theta,\lambda_k)$ with any RL algorithm on the reward $r-\sum_i\lambda_{k,i}c_i$. // inner loop, run to (approximate) convergence
- $\lambda_{k+1}=\big[\lambda_k+\eta\,(J_c(\theta_{k+1})-d)\big]_+$. // in practice a Monte-Carlo estimate of $J_c$ (Primer C); the theorem below assumes the exact value
Paternain et al. prove (their Theorem 3) that if the inner RL step returns a local maximiser whose Lagrangian value is within $\delta$ of the global one (their Assumption 1), then under Slater's condition for the parametrised problem and $\epsilon$-universality the dual iterates reach a neighbourhood of the optimum in at most $K\le\|\lambda_0-\lambda_\theta^\star\|^2/(2\eta\varepsilon)$ dual steps, with $P^\star-(B_{r_0}+\|\lambda^\star_\epsilon\|_1B_c)\Delta_\epsilon\le D_\theta(\lambda_K)\le P^\star+\eta B/2+\delta+\varepsilon$. Here $D_\theta$ is the dual function of the parametrised problem and $\lambda^\star_\theta$ its minimiser; the lower bound is the previous theorem, with the same tightened-problem multiplier $\lambda^\star_\epsilon$ and the same $\Delta_\epsilon=\epsilon/(1-\gamma)^2$ (the paper's statement prints $\epsilon/(1-\gamma)$ and calls the multiplier the solution of the unperturbed dual, but its proof, Eq. (46), inherits Theorem 2's tightened-problem multiplier); and $B=\sum_i\big(B_{c_i}/(1-\gamma)+d_i\big)^2$ is the paper's $\sum_i(B_{r_i}/(1-\gamma)-c_i)^2$ translated to cost budgets, a valid bound on $\|J_c-d\|_2^2$ when every $d_i\ge0$ (in general use $|d_i|$). The three error sources are visible: parametrisation ($\epsilon$), inner-loop inaccuracy ($\delta$) and the fixed dual step ($\eta$). Running the inner loop to convergence is expensive, which motivates interleaving the two updates.
Write $g_k=d-J_c(\theta_k)$ for the inner solution $\theta_k$ used at step $k$, and assume, as the theorem does, exact values and $\|g_k\|_2^2\le B$. (1) The $\delta$-accurate inner solve, $L(\theta_k,\lambda_k)\ge D_\theta(\lambda_k)-\delta$, makes $g_k$ a $\delta$-subgradient: for every $\lambda'\ge0$, $D_\theta(\lambda')\ge L(\theta_k,\lambda')=L(\theta_k,\lambda_k)+\langle g_k,\lambda'-\lambda_k\rangle\ge D_\theta(\lambda_k)-\delta+\langle g_k,\lambda'-\lambda_k\rangle$. (2) The update is $\lambda_{k+1}=[\lambda_k-\eta g_k]_+$, and projecting onto $\lambda\ge0$ cannot increase the distance to $\lambda^\star_\theta\ge0$: $$\|\lambda_{k+1}-\lambda^\star_\theta\|^2\le\|\lambda_k-\eta g_k-\lambda^\star_\theta\|^2=\|\lambda_k-\lambda^\star_\theta\|^2-2\eta\langle g_k,\lambda_k-\lambda^\star_\theta\rangle+\eta^2\|g_k\|^2 .$$ (3) Step (1) with $\lambda'=\lambda^\star_\theta$ gives $\langle g_k,\lambda_k-\lambda^\star_\theta\rangle\ge D_\theta(\lambda_k)-D^\star_\theta-\delta$. (4) Insert (3) into (2), sum over $k=0,\dots,T-1$ (the distances telescope, and the last one is $\ge0$) and divide by $2\eta T$: $$\min_{k\lt T}D_\theta(\lambda_k)-D^\star_\theta\ \le\ \frac1T\sum_{k\lt T}\big(D_\theta(\lambda_k)-D^\star_\theta\big)\ \le\ \frac{\|\lambda_0-\lambda^\star_\theta\|^2}{2\eta T}+\frac{\eta B}{2}+\delta .$$ So $T\ge\|\lambda_0-\lambda^\star_\theta\|^2/(2\eta\varepsilon)$ steps bring some iterate within $\varepsilon+\eta B/2+\delta$ of $D^\star_\theta\le P^\star$: the upper bound of the theorem. With Monte-Carlo estimates of $J_c$ the update becomes stochastic and noise terms must be added, and truncating a discounted rollout after $H$ steps (with $|c|\le B_c$) biases each estimate by up to $B_c\gamma^H/(1-\gamma)$.
RCPO: penalised reward and three timescales
Tessler, Mankowitz, Mannor, ICLR 2019 made the interleaved version the deep-RL standard. Two ideas. First, the actor and critic are trained on the penalised per-step reward $\hat r(\lambda,s,a)=r(s,a)-\lambda c(s,a)$, whose discounted value $\hat V^\pi(\lambda,s)=V_R^\pi(s)-\lambda V_{C_\gamma}^\pi(s)$ satisfies a Bellman equation and can be learned by an actor–critic with a temporal-difference (TD) critic (Primer E), even when the actual constraint $J_C$ is a general (e.g. average or non-discounted) functional that has no Bellman structure. Second, $\lambda$ is updated with Monte-Carlo estimates of the original constraint, on the slowest of three timescales.
- Input: penalty $c$, constraint $C$, threshold $\alpha$, step sizes $\eta_1(k)\lt\eta_2(k)\lt\eta_3(k)$; init $\theta_0,v_0,\lambda_0=0$.
- For each episode $k$: for $t=0,\dots,T-1$: sample $a_t\sim\pi_\theta$, observe $r_t,c_t,s_{t+1}$;
- target $\hat R_t=r_t-\lambda_kc_t+\gamma\hat V(\lambda,s_{t+1};v_k)$; // penalised reward, Eq. (10)
- critic $v_{k+1}\leftarrow v_k-\eta_3(k)\,\partial(\hat R_t-\hat V(\lambda,s_t;v_k))^2/\partial v$; // fastest
- actor $\theta_{k+1}\leftarrow\Gamma_\theta\big[\theta_k+\eta_2(k)\nabla_\theta\hat V(\lambda,s)\big]$; // policy gradient on the penalised value
- multiplier $\lambda_{k+1}\leftarrow\Gamma_\lambda\big[\lambda_k+\eta_1(k)\,(J_C^{\pi_\theta}-\alpha)\big]$. // slowest; Monte-Carlo estimate of the true constraint
Reading Algorithm 2: $v$ are the critic parameters, and the critic takes a TD semi-gradient step, i.e. the target $\hat R_t$ is computed with the current critic and held fixed while the squared prediction error is differentiated. $\Gamma_\theta$ projects onto the admissible actor parameters and $\Gamma_\lambda$ onto the multiplier range $[0,\lambda_{\max}]$. Actor and critic are updated after every transition; the multiplier only once per episode, which is what the index $k$ counts.
A stochastic-approximation update has the form $x_{k+1}=x_k+\eta_k(h(x_k)+M_{k+1})$: a mean direction $h$ plus noise. With $\mathcal F_k$ denoting everything observed by step $k$, the noise condition is $\mathbb E[M_{k+1}\mid\mathcal F_k]=0$, with controlled conditional variance (see Primer C). The conditions $\sum_k\eta_k=\infty$ and $\sum_k\eta_k^2\lt\infty$ allow continued motion while damping accumulated noise. For example, $(k+1)^{-0.8}$ satisfies both. The associated differential equation is $\dot x=h(x)$; stable equilibria explain what the noisy iterates can track. In multiple timescales, a ratio of steps tending to zero makes one variable effectively frozen while the other relaxes. The schedules alone prove no convergence: stability, bounded iterates and suitable mean/noise regularity are also required.
Statement. The iterates $(\theta_k,v_k,\lambda_k)$ converge almost surely (with probability one, Primer C) to a fixed point $(\theta^\star(\lambda^\star,v^\star),v^\star(\lambda^\star),\lambda^\star)$ that is a feasible solution.
In words. Because $\lambda$ is quasi-static from the policy's point of view, the policy tracks a local maximiser of the penalised value; because $\lambda$ keeps growing while the constraint is violated, the only stationary points are feasible ones. There is no claim of optimality: the fixed point is a local optimum of the Lagrangian. And the stability and noise conditions describe an idealised process; nothing guarantees them for a neural actor and critic, so the theorem is not a guarantee for every implementation of Algorithm 2.
NPG-PD: a dimension-free global rate
Mirror ascent maximises $\langle p,A\rangle-\eta^{-1}\mathrm{KL}(p\|p_{\rm old})$ over action probabilities. With full-support $p_{\rm old}$, differentiating with a multiplier for $\sum_a p_a=1$ gives $A_a-\eta^{-1}(\log(p_a/p_{{\rm old},a})+1)=\text{constant}$, hence $p_a\propto p_{{\rm old},a}e^{\eta A_a}$. For $p_{\rm old}=(1/2,1/2)$, $A=(1,0)$ and $\eta=\log2$, this yields $(2/3,1/3)$. KL geometry keeps a probability vector on its simplex. For $|A_{t,a}|\le G$, the usual potential bound is $\sum_{t\lt T}\langle p-p_t,A_t\rangle\le\mathrm{KL}(p\|p_0)/\eta+\eta G^2T/2$. It comes from bounding each log normaliser and telescoping the KL differences. “Regret” is this total shortfall relative to a fixed comparator $p$; choosing $\eta$ proportional to $T^{-1/2}$ makes regret per step vanish.
Ding, Zhang, Başar, Jovanović, NeurIPS 2020 analyse the single-loop scheme "one natural policy gradient step (Primer E), one projected dual step" for tabular softmax policies with a utility constraint $V_g^\pi(\rho)\ge b$ (Slater margin $\xi$, rewards and utilities in $[0,1]$, $\rho$ the initial distribution). Under softmax, the natural gradient step on the Lagrangian is a multiplicative-weights update with the penalised advantage:
The symbol $\propto$ means "proportional to": in each state divide the right-hand side by $Z_t(s)=\sum_b\pi^{(t)}(b\mid s)\exp\big(\eta_1A_L^{(t)}(s,b)/(1-\gamma)\big)$ so that the probabilities sum to one. Equivalently (background box above, with step $\eta_1/(1-\gamma)$), $\pi^{(t+1)}(\cdot\mid s)$ maximises $\sum_ap_aA_L^{(t)}(s,a)-\frac{1-\gamma}{\eta_1}\mathrm{KL}\big(p\,\|\,\pi^{(t)}(\cdot\mid s)\big)$ over probability vectors $p$: follow the penalised advantage, but pay for moving away from the old action distribution.
(In our cost convention: $A_L=A_r-\lambda A_c$ and $\lambda\leftarrow\mathcal P_\Lambda(\lambda+\eta_2(J_c-d))$.) Started from the uniform policy $\theta^{(0)}=0$ with $\lambda^{(0)}=0$ (the initialisation used in the proof) and run with $\eta_1=2\log|\mathcal A|$ and $\eta_2=2(1-\gamma)/\sqrt T$, the iterates satisfy, on average over $t$ (journal version, Ding, Zhang, Duan, Başar, Jovanović, JMLR 26(256), 2025, Theorem 10; the NeurIPS paper's Theorem 1 has the same $O(1/\sqrt T)$ rates but states them with $\eta_2=(1-\gamma)/\sqrt T$ and the constants $4$ and $1/\xi+4\xi$ in place of $7$ and $2/\xi+4\xi$; we quote the journal version)
In a finite MDP with $0\lt\gamma\lt1$, bounded reward and initial law $\mu$, let $\pi,\pi'$ be stationary stochastic policies. Define $V_r^\pi(s)=\mathbb E_s^\pi\sum_{t\ge0}\gamma^tr_t$, $Q_r^\pi(s,a)=r(s,a)+\gamma\sum_{s'}P(s'\mid s,a)V_r^\pi(s')$, $A_r^\pi=Q_r^\pi-V_r^\pi$, and $d_\mu^{\pi'}(s)=(1-\gamma)\sum_{t\ge0}\gamma^t\Pr_\mu^{\pi'}(s_t=s)$. Then
Intuition and proof: along a $\pi'$ trajectory, the conditional mean of $r_t+\gamma V_r^\pi(s_{t+1})-V_r^\pi(s_t)$ is $A_r^\pi(s_t,a_t)$. Multiplying by $\gamma^t$ and summing to $T$ cancels all intermediate values, leaving the reward sum minus $V_r^\pi(s_0)$ plus $\gamma^{T+1}V_r^\pi(s_{T+1})$. Boundedness makes the last term tend to zero. Take expectations over the $\pi'$ trajectory with $s_0\sim\mu$: the telescoped sum has expectation $J_r(\pi')-J_r(\pi)$, while the summands, by their conditional means, give $\mathbb E\sum_t\gamma^tA_r^\pi(s_t,a_t)=\frac1{1-\gamma}\mathbb E_{s\sim d_\mu^{\pi'},a\sim\pi'}A_r^\pi(s,a)$ by the definition of $d_\mu^{\pi'}$. Module 9 builds its trust-region bounds on this identity.
No factor $|\mathcal S|$ or $|\mathcal A|$ appears: $O(1/\varepsilon^2)$ iterations (big-O notation: Primer 0) for $\varepsilon$-optimality and $\varepsilon$-violation on average, whatever the size of the tables. The constants do depend on the start. The proof bounds the initial divergence (KL: Primer C) $\mathbb E_{s\sim d^{\pi^\star}_\rho}\mathrm{KL}\big(\pi^\star(\cdot\mid s)\,\|\,\pi^{(0)}(\cdot\mid s)\big)$ by $\log|\mathcal A|$, which holds only for the uniform $\pi^{(0)}$, and it telescopes the dual update from $\lambda^{(0)}=0$. From another start the paper still asserts convergence, but that divergence and $\lambda^{(0)}$ enter the bounds in place of the constants $7$ and $2/\xi+4\xi$. The divergence can be arbitrarily large when $\pi^{(0)}$ nearly excludes an optimal action. The proof combines the performance-difference lemma stated here (see Module 9 for further consequences) with the mirror-descent regret of the multiplicative-weights update and the multiplier bound of Section 3; the projection interval $\Lambda$ is twice the Slater bound on $\lambda^\star$. The result bounds averages over $t$ of the iterates' values, not the value of a policy obtained by averaging parameters or action probabilities; it is realised by drawing one iterate uniformly at random per episode, which is exactly the "averaging" cure of the primal-recovery problem.
Two readings. A bound $C/\sqrt T\le\varepsilon$ requires $T\ge(C/\varepsilon)^2$, which is where $O(1/\varepsilon^2)$ comes from; "dimension-free" refers to this iteration count with exact values and gradients, not to the cost of one iteration, which still grows with the numbers of states and actions. And the violation bound concerns $\big[\frac1T\sum_t\big(b-V_g^{(t)}(\rho)\big)\big]_+$, in which violations at some iterations cancel against slack at others: it is not the average violation $\frac1T\sum_t\big[b-V_g^{(t)}(\rho)\big]_+$ and bounds no single iterate.
Last-iterate convergence: regularise the saddle point
Average-iterate guarantees do not say that the current policy is safe: the iterates can circle the saddle forever (the walkthrough shows a period-two cycle). Ding, Wei, Zhang, Ribeiro, NeurIPS 2023 obtain last-iterate convergence for single-time-scale methods by regularising both players. They write the utility as $u$ with threshold $b$ and absorb the threshold into $g:=u-(1-\gamma)b\in[-1,1]$, so their constraint reads $V_g^\pi(\rho)\ge0$: the $g$ below is NPG-PD's utility shifted by $(1-\gamma)b$. With $\psi_t(s,a)=-\log\pi_t(a\mid s)$, the probability simplex $\Delta(\mathcal A)=\{p:p_a\ge0,\ \sum_ap_a=1\}$ of action distributions (Primer B) and its restricted version $\hat\Delta(\mathcal A)=\{\pi(\cdot\mid s)\in\Delta(\mathcal A):\ \pi(a\mid s)\ge\epsilon_0/|\mathcal A|\ \text{for all } a\}$, $\epsilon_0\in(0,1)$,
Here $\mathcal H(\pi)=\mathbb E_\rho^\pi\sum_{k\ge0}\gamma^k\big[-\log\pi(a_k\mid s_k)\big]$ is the discounted entropy of the policy, large when action probabilities are spread out. The shift is harmless: $\sum_{k\ge0}\gamma^k(1-\gamma)b=b$, so $V_g^\pi(\rho)=V_u^\pi(\rho)-b$ and $V_g^\pi(\rho)\ge0$ is exactly $V_u^\pi(\rho)\ge b$. The term $+\tfrac\tau2\lambda^2$ penalises the minimising multiplier player for large multipliers. The policy line is the KL-proximal (multiplicative-weights) step of the background box, restricted to $\hat\Delta(\mathcal A)$; the multiplier line is a projected gradient step, $\lambda_{t+1}=\mathcal P_\Lambda\big(\lambda_t-\eta(V_g^{\pi_t}(\rho)+\tau\lambda_t)\big)$, since $\partial_\lambda L_\tau=V_g^\pi(\rho)+\tau\lambda$.
Statement. Let $\mathrm{KL}_t(\rho)=\frac{1}{1-\gamma}\sum_sd_\rho^{\pi^\star_\tau}(s)\,\mathrm{KL}\big(\pi^\star_\tau(\cdot\mid s)\,\|\,\pi_t(\cdot\mid s)\big)$, the per-state divergences weighted by the normalised visitation distribution of the saddle policy: nonnegative, but not symmetric, and blind to states that $\pi^\star_\tau$ never visits. With $\Phi_t=\mathrm{KL}_t(\rho)+\tfrac12(\lambda_\tau^\star-\lambda_t)^2$ measuring the distance to the unique regularised saddle point $(\pi^\star_\tau,\lambda^\star_\tau)$, $$\Phi_{t+1}\le e^{-\eta\tau t}\,\Phi_1+\frac{\eta}{\tau}\max\big(C_{\tau,\xi,\epsilon_0}^2,(C'_{\tau,\xi})^2\big).$$ The first term decays linearly at rate $\eta\tau$; the second does not decay: the iterates reach a neighbourhood of $(\pi^\star_\tau,\lambda^\star_\tau)$ whose size scales with $\eta/\tau+\eta\tau(1+\log^2\epsilon_0)$ (the paper's remark after Thm 2), and only a small step makes it small. Choosing $\eta=\Theta(\varepsilon^4)$, $\tau=\Theta(\varepsilon^2)$, $\epsilon_0=\varepsilon$, the last policy iterate is $\varepsilon$-optimal and $\varepsilon$-feasible for the original CMDP after $\Omega\big(\varepsilon^{-6}\log^2(1/\varepsilon)\big)$ iterations (Cor. 3; here $\Omega(\cdot)$ means: at every $t$ beyond a problem-dependent constant times $\varepsilon^{-6}\log^2(1/\varepsilon)$. It is a sufficient budget, not a lower bound).
In words. The entropy and quadratic terms "convexify" the game (the paper's word; the value function itself stays non-concave in $\pi$), so the regularised problem has a unique saddle point (their App. C.1), and the KL-mirror-descent/gradient play contracts towards it at rate $\eta\tau$ up to the $O(\eta/\tau)$ residual. The regularised saddle point is within $O(\tau)$ of an optimal constrained policy (a sandwich property, Eq. (5) of the paper), but the last iterate is close to it only in KL, which Pinsker's inequality turns into a $\sqrt{\Phi_t}$ error in value; the corollary's choice $\tau=\Theta(\varepsilon^2)$, $\eta=\Theta(\varepsilon^4)$ makes both errors $O(\varepsilon)$ and costs the $\varepsilon^{-6}$. The companion method OPG-PD (optimistic gradients, no regularisation) converges linearly in the last iterate to the optimal sets under an extra assumption that the optimal state-visitation distribution is unique.
Use the same finite, discounted, one-constraint model with $r\in[0,1]$, $g\in[-1,1]$, Slater margin $\xi\gt0$, and $\Lambda=[0,1/((1-\gamma)\xi)]$. Assume exact values, full support of the initial distribution, $\rho_{\min}=\min_s\rho(s)\gt0$, and that all optimal policies have the same normalised state occupancy $d^\star$. Let $\Pi^\star$ and $\Lambda^\star$ be the sets of optimal policies and optimal multipliers. Put $Q_t=Q_{r+\lambda_tg}^{\pi_t}$ and $G_t=V_g^{\pi_t}(\rho)$. With Euclidean projections, OPG-PD uses the following two stages (policy projections are performed separately in each state):
Start with equal predicted and base iterates in the policy simplex and $\Lambda$. Define the distribution-mismatch coefficient $\kappa_\rho=\sup_\pi\max_s d_\rho^\pi(s)/\rho(s)$. If $0\lt\eta\le\min\{1/(4\sqrt\iota),(1-\gamma)^3/(4|\mathcal A|),(1-\gamma)^3/(2\kappa_\rho)\}$, where $\iota$ is an explicit polynomial in $\kappa_\rho$, $\sqrt{|\mathcal A|}$, $1/(1-\gamma)$ and $1/\xi$ (their Eq. (28)), there exist finite $C_0$ and $q\in(0,1)$, depending on the model and initial point, such that the squared distance of $(\hat\pi_t,\hat\lambda_t)$ to $\Pi^\star\times\Lambda^\star$ is at most $C_0q^t$. Here policy distance uses weights $d^\star(s)/(2(1-\gamma))$ and dual distance weight $1/2$; distance to a set means the infimum of those weighted squared distances over its elements.
Intuition: the old gradient predicts an intermediate point; its freshly evaluated gradient corrects the move from the same base. Full initial support prevents invisible states, and the common optimal occupancy lets the proof use one set of weights. This is a theorem for these updates, not for arbitrary extrapolation rules.
Montenegro, Mussi, Papini, Metelli, NeurIPS 2024 (C-PG) extend the regularised idea to general parametrisations, including action-based exploration (a stochastic policy randomises each action, as so far) and parameter-based exploration (a deterministic policy whose parameters are drawn at random once per episode), in the cost-minimisation convention $\min_\upsilon J_0(\upsilon)$ s.t. $J_i(\upsilon)\le b_i$. Only the dual is regularised, by a ridge term:
Where the closed form comes from: with $\Delta_i=J_i(\upsilon)-b_i$ the maximisation over $\lambda\ge0$ splits into scalar problems $\max_{\lambda_i\ge0}\{\lambda_i\Delta_i-\tfrac\omega2\lambda_i^2\}$, concave parabolas with vertex at $\lambda_i=\Delta_i/\omega$. If $\Delta_i\gt0$ the vertex is feasible and the value is $\Delta_i^2/(2\omega)$; if $\Delta_i\le0$ the best feasible point is $\lambda_i=0$ with value $0$. So $\lambda_i^\star=(\Delta_i)_+/\omega$ and the maximum is $(\Delta_i)_+^2/(2\omega)$; summing over $i$ gives $H_\omega$.
Fix a parameter domain $\mathcal V$ and a multiplier domain $\Lambda$. Assume $L_0(\cdot,\lambda)$ is differentiable and bounded below for every $\lambda\in\Lambda$, and there are constants $\psi\in[1,2]$, $\alpha_1\gt0$, $\beta_1\ge0$ such that, for every $(\upsilon,\lambda)$ in these domains,
Then a point with gradient norm at most $e$ has fixed-multiplier suboptimality at most $(e^\psi+\beta_1)/\alpha_1$. This follows by rearranging the inequality. The case $\psi=2$, $\beta_1=0$ is the Polyak–Łojasiewicz condition. Intuition: a nearly flat landscape must already have nearly optimal value. Smoothness only limits how quickly a gradient changes; it does not rule out a bad flat point. For example $f(x)=x^2$ has $|f'(x)|^2=4f(x)$, so it satisfies PL with $\alpha_1=4$.
Assume $\mathcal V$ is the policy-parameter domain with well-defined Euclidean projection; the objective and constraints are differentiable, bounded expected costs, $0\le J_i,b_i\le J_{\max}$; and an unregularised saddle $(\upsilon_0^\star,\lambda_0^\star)$ exists. Set $\omega\gt0$, $\Lambda=\{\lambda\ge0:\|\lambda\|_2\le\sqrt m J_{\max}/\omega\}$, so the proportional best response lies in $\Lambda$ (and, for $\omega$ small enough, so does the unregularised multiplier $\lambda_0^\star$, which the bias lemmas behind Theorem 3.1 compare against). Require the preceding weak-domination inequality uniformly on $\mathcal V\times\Lambda$. Require finite constants $L_1,L_2,L_3$ bounding, respectively, the Lipschitz changes of $J(\upsilon)$, of $\nabla_\upsilon L_0$ in $\upsilon$, and of $\nabla_\upsilon L_0$ in $\lambda$. Gradient estimates must be conditionally unbiased for the regularised gradients, with conditional mean-square errors bounded by $V_\upsilon,V_\lambda$. For the stated dependence on $\omega$, take $L_2=O(\omega^{-1})$, $L_1,L_3=O(1)$, $V_\upsilon=O(\omega^{-2})$, $V_\lambda=O(1)$.
For a suitable fixed $\chi\in(0,1/5)$ and sufficiently small target $\varepsilon$ and $\omega$, there are constant learning rates giving $\mathcal P_K\le\varepsilon+\beta_1/\alpha_1$ with the rates stated in the following paragraph. The exact-gradient choices have $\zeta_\lambda=1/\omega$, $\zeta_\upsilon=O(\omega)$; the estimated-gradient choices have $\zeta_\lambda=O(\omega\varepsilon^{2/\psi})$, $\zeta_\upsilon=O(\omega^3\varepsilon^{2/\psi})$, with sufficiently small theorem-dependent constants (the proof gives them explicitly; they are not free prefactors).
Intuition: $a_k$ measures the gap of the penalised policy and $b_k$ measures the multiplier's failure to attain its best response. Both are nonnegative, so controlling their weighted sum controls both players. Domination removes bad stationary values, regularity controls each step, and the variance bounds control sampling error. The floor $\beta_1/\alpha_1$ remains even with arbitrarily many iterations.
The closed form is worth a second look: maximising over the regularised multiplier turns the Lagrangian into a quadratic penalty on the violation, and the multiplier that goes with it is proportional to the violation rather than an integral of it. Their Theorem 3.1 quantifies the bias of the ridge: if the potential $\mathcal P_k$ that drives the analysis is below $\varepsilon$, then $\mathbb E[J_0(\upsilon_k)-J_0(\upsilon_0^\star)]\le\varepsilon+\frac\omega2\|\lambda_0^\star\|_2^2$ and $\mathbb E[(J_i(\upsilon_k)-b_i)_+]\le4\varepsilon+\omega\|\lambda^\star_0\|_2$, where $\lambda_0^\star$ is the unregularised multiplier; Theorem 3.2 gives last-iterate iteration complexities for driving the potential down to $\mathcal P_K\le\varepsilon+\beta_1/\alpha_1$: $O(\omega^{-1}\log\varepsilon^{-1})$ (exact gradients, Polyak–Łojasiewicz-type domination $\psi=2$), $O(\omega^{-1}\varepsilon^{-(2/\psi-1)})$ (exact gradients, $\psi\in[1,2)$), and $O(\omega^{-3}\varepsilon^{-4/\psi+1})$ with estimated gradients, under weak $\psi$-gradient domination of the Lagrangian, smoothness and bounded gradient variance (smoothness and stochastic gradients: Primer B; the existence of a saddle point enters Theorem 3.1). Here $\alpha_1\gt0$, $\beta_1\ge0$ are the constants of the weak gradient-domination assumption: $\beta_1=0$ for tabular softmax ($\psi=1$) or direct ($\psi=2$) parametrisations, while for general parametrisations $\beta_1$ carries a compatible-function-approximation bias, and the floor $\beta_1/\alpha_1$ does not shrink with more iterations; Theorem 3.1 then applies with $\varepsilon+\beta_1/\alpha_1$ in place of $\varepsilon$. When $\beta_1=0$, setting $\omega=O(\varepsilon)$ balances bias and rate. Alternatively one tightens the budget to $b_i'=b_i-\delta$ (the paper's route to "zero constraint violation"), which needs the tightened problem to remain feasible and $\delta\ge4\varepsilon+\omega\|\lambda^\star_0\|$ with $\lambda^\star_0$ now the multiplier of the tightened problem. Because $\mathbb E[J_i-b_i']\le\mathbb E[(J_i-b_i')_+]\le\delta$, what this buys is $\mathbb E[J_i(\upsilon_k)]\le b_i$: feasibility in expectation over the algorithm's randomness. With exact gradients the iterate is deterministic and is itself feasible. With estimated gradients individual runs can still violate $b_i$: $J_i-b_i'\in\{0,2\delta\}$ with equal probability satisfies the bound and violates $b_i$ half the time.
Off-policy: conservative cost critics
Off-policy actor-critics (SAC-Lagrangian; off-policy learning from a replay buffer: Primer E) estimate $J_c$ from a replay buffer through a learned $Q_c$, and a cost critic that underestimates makes $\lambda$ collapse to zero while the true cost exceeds the budget. Wu et al., ICLR 2024 (CAL) replace $Q_c$ by an upper confidence bound over an ensemble of $E$ cost critics, $\hat Q_c^{\rm UCB}=\frac1E\sum_i\hat Q_c^i+k\cdot\mathrm{Std}_i(\hat Q_c^i)$, so that the constraint seen by the dual update is pessimistic, and they rectify the actor gradient with an augmented-Lagrangian term (a Lagrangian plus a quadratic penalty on the violation; penalties: Primer B): the multiplier that multiplies $\nabla_a\hat Q_c^{\rm UCB}$ in the actor update is $\tilde\lambda=\max\{0,\lambda-c_{\rm pen}\,(d-\mathbb E[\hat Q_c^{\rm UCB}])\}$, a proportional correction of the same kind as C-PG's closed form, which convexifies the objective near the constraint boundary (their Proposition 1 is a Platt–Barr energy argument in continuous time; see Section 5). The benefit is empirical: on Safety Gym and velocity-constrained MuJoCo tasks CAL reaches the asymptotic performance of state-of-the-art on-policy methods with far fewer samples while markedly reducing constraint violations during training (plus a real-world auto-bidding study).
Here $E$ is the number of critics, $k\gt0$ a chosen uncertainty weight and $\mathrm{Std}_i$ the standard deviation of their $E$ predictions, a measure of disagreement. Without a calibration theorem, “mean plus $k$ standard deviations” is a conservative heuristic, not a $1-\delta$ confidence bound of the kind proved in Module 3. In $\tilde\lambda$, $c_{\rm pen}\gt0$ is CAL's penalty coefficient (their $c$), not a cost function.
What is proved
| Method | Policy class, loops | Guarantee | Assumptions that carry the proof |
|---|---|---|---|
| Dual descent (Paternain et al. 2019, Thm 3) | $\epsilon$-universal $\pi_\theta$; inner RL loop to $\delta$-accuracy, outer dual step | $K\le\|\lambda_0-\lambda_\theta^\star\|^2/(2\eta\varepsilon)$ dual steps to a $[\,-O(\epsilon/(1-\gamma)^2),\ \eta B/2+\delta+\varepsilon\,]$ neighbourhood of $P^\star$ (unnormalised returns; the paper prints $\epsilon/(1-\gamma)$) | bounded rewards, Slater for the parametrised problem, inner maximiser within $\delta$ of the global one |
| RCPO (Tessler et al. 2019, Thm 2) | parametrised actor-critic; three timescales | a.s. convergence to a feasible fixed point (local) | Robbins–Monro steps with $\eta_1/\eta_2\to0$; local minima of the discounted penalty are feasible; uncapped multiplier ($\lambda_{\max}=\infty$) |
| NPG-PD (Ding et al. 2020; JMLR Thm 10) | tabular softmax; single loop | average-iterate gap $\le7/((1-\gamma)^2\sqrt T)$, violation $\le(2/\xi+4\xi)/((1-\gamma)^2\sqrt T)$ | Slater margin $\xi$, exact gradients, rewards in $[0,1]$, uniform $\pi^{(0)}$ and $\lambda^{(0)}=0$ (for these constants); extensions with function-approximation error terms |
| RPG-PD (Ding et al. 2023, Thm 2, Cor. 3) | tabular softmax; single time scale, entropy + quadratic dual regularisation | linear rate to an $O(\eta/\tau)$ neighbourhood, provided the regularised saddle lies in $\hat\Delta(\mathcal A)$ (see the caveat); last iterate $\varepsilon$-optimal and $\varepsilon$-feasible after $\Omega(\varepsilon^{-6}\log^2\varepsilon^{-1})$ | feasibility with margin, $\eta\le1/C_{\tau,\xi,\epsilon_0}$, $\tau=\Theta(\varepsilon^2)$, $\epsilon_0=\varepsilon$ (restriction bias $O(\epsilon_0/(1-\gamma)^2)$) |
| OPG-PD (Ding et al. 2023, Thm 6) | tabular; optimistic gradients | linear last-iterate convergence to $\Pi^\star\times\Lambda^\star$, problem-dependent rate | unique optimal state-visitation distribution, $\rho_{\min}\gt0$ |
| C-PG (Montenegro et al. 2024, Thms 3.1–3.2) | general parametrisations, action- or parameter-based; ridge on the dual | last iterate: gap $\le\varepsilon+\frac\omega2\|\lambda_0^\star\|^2$, violation $\le4\varepsilon+\omega\|\lambda_0^\star\|$ once $\mathcal P_K\le\varepsilon$; $O(\omega^{-1}\log\varepsilon^{-1})$ to $O(\omega^{-3}\varepsilon^{-4/\psi+1})$ iterations reach $\mathcal P_K\le\varepsilon+\beta_1/\alpha_1$ | saddle point exists, weak $\psi$-gradient domination (error floor $\beta_1/\alpha_1$), smoothness, bounded variance |
| A-CRL (Calvo-Fullana et al. 2024, Thm 1) | average reward; policy conditioned on $\lambda$; dual dynamics at execution | trajectories feasible a.s.; average reward $\ge P^\star-\eta_\lambda B^2/2$ | strictly feasible policy, $\|r(s,a)-c\|_2\le B$ (see Section 7), unbiased epoch estimates |
| CAL (Wu et al. 2024) | off-policy SAC; UCB cost ensemble + augmented Lagrangian | energy decreases near a local optimum (continuous-time Prop. 1); otherwise empirical | large penalty $c$; heuristic outside the neighbourhood |
5. The Multiplier as a Controller: PID Lagrangians
Look again at the dual step $\lambda_{k+1}=(\lambda_k+K_I(J_{C,k}-d))_+$. The multiplier is a running sum of the constraint violation: it is an integral controller (PID control: Primer D) acting on the error $e_k=J_{C,k}-d$, with the RL algorithm as the plant. Stooke, Achiam, Abbeel, ICML 2020 make this reading explicit and draw the obvious conclusion: integral-only controllers overshoot and oscillate, and the standard remedy is to add proportional and derivative action.
Timing convention. For the matrix below and the explorer the order is: measure $e_k$, update $I_k=I_{k-1}+e_k$, form $\lambda_k=K_Pe_k+K_II_k$, then update the policy to obtain $e_{k+1}$. With integral action alone, $\lambda_k=\lambda_{k-1}+K_Ie_k$. This is the same indexing convention used by the simulation. Updating the policy with the old multiplier instead produces a different state matrix.
(a) Continuous time, Stooke et al.'s argument (after Platt & Barr). For $\min f(x)$ s.t. $g(x)=0$ the basic differential multiplier method is $\dot x=-\nabla f-\lambda\nabla g$, $\dot\lambda=\alpha g(x)$. Differentiating the first equation (chain rule and Hessians: Primer B) and substituting the second gives a forced oscillator $$\ddot x+A\dot x+\alpha\,g(x)\nabla g=0,\qquad A=\nabla^2f+\lambda\nabla^2g:$$ the only damping is the curvature of the Lagrangian; the multiplier update contributes no damping of its own (Platt and Barr: a positive-definite $A$ dissipates energy; the theorem below makes this precise for a linear constraint). Adding a proportional term, $\dot\lambda=\alpha g+\beta\dot g$ (here $\alpha,\beta$ and, below, $\gamma$ are the paper's gains, not a CVaR level, a budget or the discount), changes the damping matrix to $A+\beta\nabla g\nabla g^\top$: a positive semidefinite increase ($v^\top\nabla g\nabla g^\top v=(\nabla g^\top v)^2\ge0$; Primer A), which can damp oscillations but need not shorten settling time. A derivative term $\dot\lambda=\alpha g+\gamma\ddot g$ multiplies the dynamics by $B^{-1}$ with $B=I+\gamma\nabla g\nabla g^\top$, weakening both damping and forcing and adding a curvature-dependent drag: it acts predictively but "may be prone to instability".
Differentiate term by term: $\ddot x=-\nabla^2f\,\dot x-\dot\lambda\nabla g-\lambda\nabla^2g\,\dot x$. Substituting $\dot\lambda=\alpha g$ gives the displayed equation. With proportional action, $\dot g=\nabla g^\top\dot x$, so the extra term is $-\beta\nabla g\nabla g^\top\dot x$. Its quadratic form is $\beta(\nabla g^\top v)^2\ge0$, explaining the added damping term.
Let $f:\mathbb R^n\to\mathbb R$ be twice continuously differentiable with $\nabla^2f(x)\succeq\ell I$, $\ell\gt0$, for every $x$. Let $g(x)=b^\top x-d$ with $b\ne0$, and let $\alpha\gt0$. For the equality-constrained dynamics $\dot x=-\nabla f(x)-\lambda b$, $\dot\lambda=\alpha(b^\top x-d)$, with an unrestricted real multiplier, every solution converges to the unique constrained minimiser and its unique multiplier $(x^\star,\lambda^\star)$.
Intuition and proof: strong convexity makes the affine constrained optimum exist and be unique, with $\nabla f(x^\star)+\lambda^\star b=0$. The nonnegative energy $E=\|x-x^\star\|^2/2+(\lambda-\lambda^\star)^2/(2\alpha)$ has derivative $\dot E=-(x-x^\star)^\top (\nabla f(x)-\nabla f(x^\star))\le-\ell\|x-x^\star\|^2$ (use $\nabla f(x^\star)=-\lambda^\star b$, $b^\top x^\star=d$, and the mean value theorem). Its bounded level sets bound the whole trajectory. The only trajectory that can stay in $\dot E=0$ is the equilibrium, because $b\ne0$. LaSalle's invariance principle (a bounded trajectory approaches the largest invariant set inside $\{\dot E=0\}$) therefore gives convergence. This special case shows the energy reasoning; a nonlinear inequality constraint, a projected multiplier or a nonconvex neural objective needs its own hypotheses.
Since $\ddot g=\nabla g^\top\ddot x+\dot x^\top\nabla^2g\dot x$, substituting $\dot\lambda=\alpha g+\gamma\ddot g$ yields $(I+\gamma\nabla g\nabla g^\top )\ddot x+A\dot x+\alpha g\nabla g+\gamma(\dot x^\top\nabla^2g\dot x)\nabla g=0$. The final term depends on the curvature of $g$ and need not have a damping sign. This is why derivative action has no unconditional stability guarantee.
Complex numbers add a unit $i$ with $i^2=-1$. For $z=x+iy$ the conjugate is $\bar z=x-iy$ and the modulus $|z|=\sqrt{x^2+y^2}$, so $z\bar z=|z|^2$. The non-real eigenvalues of a real matrix come in conjugate pairs $z,\bar z$. Euler's formula $e^{i\vartheta}=\cos\vartheta+i\sin\vartheta$ writes any nonzero $z$ in polar form $z=re^{i\vartheta}$ with $r=|z|$, so a pair is $re^{\pm i\vartheta}$. In $x_{k+1}=Mx_k$ each such mode is multiplied by $r$ and rotated by the angle $\vartheta$ at every step: the modulus controls growth or decay, the angle the oscillation, with nominal period $2\pi/\vartheta$ iterations (exact repetition only when $\vartheta/2\pi$ is rational). For $r\lt1$ the envelope halves after $n$ steps with $r^n=\tfrac12$, i.e. $n=\log2/\log(1/r)$. Example: $z=0.8i=0.8e^{i\pi/2}$ turns a quarter-turn and shrinks by $0.8$ per step, so its period is $4$ and its envelope halves every $\log2/\log1.25\approx3.1$ steps.
(b) A discrete linear model of the loop (ours). Near the active constraint linearise (linear discrete-time systems and their modes: Primer D): along the direction of $\nabla J_C$ let $J_C(\theta)\approx d+b\,(\theta-\bar\theta)$ with constant $\nabla_\theta J=g_r$ and $\nabla_\theta J_C=b$. The policy step $\theta_{k+1}=\theta_k+\eta(g_r-\lambda_kb)$ is stationary at $\lambda^\star=g_r/b$, and the error $e_k=J_{C,k}-d$ obeys $$e_{k+1}=e_k-c\,(\lambda_k-\lambda^\star),\qquad c:=\eta b^2 .$$ With Algorithm 3 below (no derivative term, projections inactive) the multiplier is $\lambda_k=K_Pe_k+K_II_k$, $I_k=I_{k-1}+e_k$. Writing $\delta_k=I_k-\lambda^\star/K_I$ the state $x_k=(e_k,\delta_{k-1})$ evolves linearly, $x_{k+1}=Mx_k$ with $$M=\begin{bmatrix}1-c(K_P+K_I)&-cK_I\\ 1&1\end{bmatrix},\qquad \operatorname{tr}M=2-c(K_P+K_I),\qquad \det M=1-cK_P .$$ For $K_P=0$ we get $\det M=1$: whenever the eigenvalues are complex ($0\lt cK_I\lt4$) they lie on the unit circle, $z=e^{\pm i\vartheta}$ with $\cos\vartheta=1-cK_I/2$. The violation and the multiplier oscillate without decay with nominal period $2\pi/\vartheta\approx2\pi/\sqrt{cK_I}$; larger $K_I$ shortens the period but never damps, and $cK_I\ge4$ is not asymptotically stable (at equality the repeated root is $-1$). For $K_P\gt0$, as long as the eigenvalues stay complex, i.e. $(\operatorname{tr}M)^2\lt4\det M$, their modulus is $\sqrt{\det M}=\sqrt{1-cK_P}\lt1$: the envelope decays geometrically. For larger gains they become real, possibly negative (a sign-alternating transient), and only the Jury conditions decide: stability holds iff $0\lt cK_P\lt2$, $cK_I\gt0$ and $c(2K_P+K_I)\lt4$ (Exercise 8.4). The derivative term feeds back the increment $e_k-e_{k-1}$ (one more state in the model) and, being projected to $(\cdot)_+$, only resists increases of the cost: it damps a rising cost, and hence overshoot of the limit from below, without impeding decreases.
For $z^2-tz+q$, both roots lie strictly inside the unit disk exactly when $1-q>0$, $1-t+q>0$, and $1+t+q>0$. Here $t=2-c(K_P+K_I)$ and $q=1-cK_P$, giving $cK_P>0$, $cK_I>0$, and $4-c(2K_P+K_I)>0$. These imply $cK_P\lt 2$. Equality describes a stability boundary, not asymptotic stability.
(c) Curvature. The model takes $\nabla_\theta J$ and $\nabla_\theta J_C$ constant. If they vary, linearising the policy step at the optimum adds the curvature of the Lagrangian $L=J-\lambda^\star J_C$ along the direction: $e_{k+1}=a\,e_k-c(\lambda_k-\lambda^\star)$ with $a=1+\eta\,\partial^2_\theta L$, so the $(1,1)$ entry of $M$ becomes $a-c(K_P+K_I)$, $\operatorname{tr}M=1+a-c(K_P+K_I)$ and $\det M=a-cK_P$. A Lagrangian that is concave along the direction ($a\lt1$) adds damping, the discrete counterpart of Platt and Barr's damping matrix $A$ in (a); a convex one ($a\gt1$) removes it. Then even the integral-only loop is unstable ($\det M=a\gt1$ for $K_P=0$, so $|z|=\sqrt a$ when the eigenvalues are complex), and proportional action must supply $cK_P\gt a-1$ before the envelope can decay. The explorer below is of this second kind.
- Choose $K_P,K_I,K_D\ge0$; $I\leftarrow0$; $J_{C,\rm prev}\leftarrow0$.
- At each iteration $k$: receive the cost estimate $J_C$;
- $\Delta\leftarrow J_C-d$; $\ \partial\leftarrow(J_C-J_{C,\rm prev})_+$; $\ I\leftarrow(I+\Delta)_+$;
- $\lambda\leftarrow(K_P\Delta+K_II+K_D\partial)_+$; $\ J_{C,\rm prev}\leftarrow J_C$. // $K_P=K_D=0$ recovers the Lagrangian method
The policy is then updated with the Lagrangian gradient. Stooke et al. rescale it as $\nabla_\theta L=\frac{1}{1+\lambda}\big(\nabla_\theta\hat J-\lambda\nabla_\theta\hat J_C\big)$, a convex combination of the reward and cost gradients that keeps the step size bounded when $\lambda$ is large; since $\operatorname*{arg\,max}_\theta(J-\lambda J_C)=\operatorname*{arg\,max}_\theta\frac{1}{1+\lambda}(J-\lambda J_C)$, it does not change the fixed points. With $u=\lambda/(1+\lambda)\in[0,1]$ this reads $\nabla_\theta L=(1-u)\nabla_\theta J-u\nabla_\theta J_C$. Their constraint-controlled PPO (CPPO-PID) uses separate value and cost-value critics, because a rapidly moving $\lambda$ would make a single critic for $r-\lambda c$ chase a moving target.
Results. On Safety Gym tasks (cost limits from 25 to 200 depending on the experiment, e.g. 50 in DoggoGoal2 and 50–200 in DoggoButton1) the paper shows that with the integral-only rule the episodic cost oscillates around the limit with a period and amplitude that shrink as $K_I$ grows (a fast $K_I$ removes the oscillation but costs return), that proportional control damps these oscillations across a range of $K_I$ while keeping return high, and that derivative control reduces cost overshoot in the reported experiments and slows cost increases inside the feasible region, which the Lagrangian method cannot do. CPPO-PID is a standard baseline in SafePO/OmniSafe and its multiplier rule is reused inside SafeDreamer's planner (Module 9). The explorer below reproduces the phenomenon on a one-parameter policy: watch the plain multiplier ring and the PID multiplier settle. Its cost curve is concave, so the Lagrangian is slightly convex in the policy parameter (case $a\gt1$ of (c)): the integral-only loop is even weakly unstable, and its oscillation can grow until clipping changes the motion; a periodic limiting orbit is not implied by the local model.
6. Risk-Sensitive Constraints: CVaR and Beyond
An expected-cost budget allows rare catastrophes as long as the average is fine. Risk-constrained RL replaces the expectation of the cumulative cost $Z$ by a tail statistic. The two classical ones are the value-at-risk $\mathrm{VaR}_\alpha(Z)=\min\{z:F_Z(z)\ge\alpha\}$ (a chance constraint in disguise) and the conditional value-at-risk, which also counts how bad the tail is.
Chow, Ghavamzadeh, Janson, Pavone, JMLR 2018 pose the CVaR-constrained MDP (cost minimisation: $\min_\theta V^\theta(x^0)$ s.t. $\mathrm{CVaR}_\alpha(\text{cumulative constraint cost})\le\beta$) and use the Rockafellar–Uryasev form to turn it into a joint problem in $(\theta,\nu)$ with an expectation constraint, since $\mathrm{CVaR}_\alpha\le\beta$ iff some $\nu$ has $H_\alpha(Z,\nu):=\nu+\frac{1}{1-\alpha}\mathbb E[(Z-\nu)_+]\le\beta$. The new constraint is convex in $\nu$ but not smooth (the kink of $(\cdot)_+$; for a cost with atoms $H_\alpha$ is piecewise linear in $\nu$), which is why the $\nu$-derivative below is a subgradient. The Lagrangian and its (sub)gradients (their Eqs. 5, 7–9) are
Why $\ge$ in $\partial_\nu L$: as a function of $\nu$, $(Z-\nu)_+$ has slope $-1$ where $Z>\nu$, slope $0$ where $Z\lt\nu$, and any slope in $[-1,0]$ at $Z=\nu$. Taking expectations, the left and right derivatives of $H_\alpha$ in $\nu$ are $1-\mathbb P(Z\ge\nu)/(1-\alpha)$ and $1-\mathbb P(Z>\nu)/(1-\alpha)$, and $\partial_\nu H_\alpha$ is the interval between them; the displayed element is the left end. They differ only if $Z$ has an atom at $\nu$. $H_\alpha$ is minimal where $0\in\partial_\nu H_\alpha$, i.e. $\mathbb P(Z>\nu)\le1-\alpha\le\mathbb P(Z\ge\nu)$: $\mathrm{VaR}_\alpha(Z)$ is one such $\nu$, not necessarily the only one.
Statement. The policy iterates of the trajectory-based algorithm (their Algorithm 1) converge almost surely to a locally optimal policy $\theta^\star$ of the CVaR-constrained problem.
In words. The proof follows the timescales: $\nu$ tracks its best response for frozen $(\theta,\lambda)$, then $\theta$ for frozen $\lambda$; the limiting ODE is locally asymptotically stable, with the Lagrangian as Lyapunov function, at a local saddle point of $L$, which makes $\theta^\star$ locally optimal. Nothing is claimed about global optimality, and the actor–critic variants need further assumptions (e.g. linearly independent critic features, their Assumption 9).
Chow et al., JMLR 2018, Assumptions 2–6 and Theorem 7
Two structural points. An optimal policy need not be Markov in the state alone: the term $(Z-\nu)_+$ depends on the cost accumulated so far. Chow et al. cite Ott (2010) and Bäuerle and Ott (2011) for a deterministic optimal policy that depends on the history only through the time step, the current state and the accumulated discounted constraint cost. Those results are about minimising CVaR (Bäuerle and Ott minimise the AVaR of the discounted cost), not about the CVaR-constrained problem. For the constrained problem, the same augmented state (together with $\nu$) still gives a Markov description, since for fixed $\nu$ the constraint $H_\alpha\le\beta$ is an expected-cost constraint on the augmented MDP. But, as in every CMDP, the optimum may have to randomise. Take one decision with actions safe (task cost $1$, constraint cost $0$) and risky (task cost $0$, constraint cost $1$), $\alpha=0.5$ and $\beta=0.5$. Choosing risky with probability $p$ gives $\mathrm{CVaR}_{0.5}=\min(2p,1)$, so the optimum $p=\tfrac14$ has task cost $\tfrac34$, while the only feasible deterministic choice (safe) costs $1$. Their actor-critic algorithms work on this augmented MDP whose extra state variable tracks that running cost (compare Section 7), with stochastic policies $\mu(a\mid x,s;\theta)$. And in the policy-gradient algorithm the three variables move on three timescales, $\nu$ fastest, then $\theta$, then $\lambda$ (the actor-critic versions add a fourth, fastest one for the critic), which, under the assumptions of the theorem above, yields almost-sure convergence to a local saddle point of $L$, i.e. a locally optimal policy of the CVaR-constrained problem. The $\nu$ update is a subgradient step on a piecewise-linear function, exactly the kink phenomenon of the walkthrough.
Gaussian shortcut. Yang, Simão, Tindemans, Spaan, AAAI 2021 (WCSAC) keep SAC-Lagrangian but replace the expected-cost constraint by a per-state CVaR of a Gaussian safety critic $C^\pi(s,a)\sim\mathcal N(Q_c^\pi,\Sigma_c^\pi)$, which has the closed form (tail fraction $\alpha$)
with $\varphi,\Phi$ the standard normal density and CDF (Primer C), and the multiplier objective $J_s(\kappa)=\mathbb E[\kappa(d-\Gamma_{\pi_\theta})]$. WCSAC write the variance as $V_c^\pi$; we write $\Sigma_c^\pi$ because $V_c^\pi$ is this page's cost value function. The formula is the Gaussian tail mean. For a standard normal $U$, $\varphi'(u)=-u\varphi(u)$, so $\int_z^\infty u\varphi(u)\,du=\varphi(z)$ and $\mathbb E[U\mid U\ge z]=\varphi(z)/(1-\Phi(z))$ (the Mills-ratio identity). For $Z=\mu+\sigma U$ with $\mu=Q_c^\pi(s,a)$ and $\sigma=\sqrt{\Sigma_c^\pi(s,a)}$, the worst $\alpha$ fraction lies above $\mu+\sigma z_\alpha$ with $z_\alpha=\Phi^{-1}(1-\alpha)=-\Phi^{-1}(\alpha)$; since $1-\Phi(z_\alpha)=\alpha$ and $\varphi$ is even, $\mathbb E[Z\mid Z\ge\mu+\sigma z_\alpha]=\mu+\sigma\varphi(\Phi^{-1}(\alpha))/\alpha$, the displayed $\Gamma_\pi$. The formula is exact only when the cumulative cost really is Gaussian, not for every distribution with the same mean and variance; Exercise 8.5 shows how far it can be from the CVaR of a heavy-tailed cost.
Spectral risk. Kim et al., NeurIPS 2024 (SRCPO) constrain a spectral risk measure $R_\sigma(X)=\int_0^1F_X^{-1}(u)\sigma(u)\,du$ with an increasing spectrum $\sigma\ge0$, $\int_0^1\sigma=1$; CVaR is $\sigma(u)=\mathbf 1_{u\ge\alpha}/(1-\alpha)$. The dual form $R_\sigma(X)=\inf_g\{\mathbb E[g(X)]+\int_0^1g^\ast(\sigma(u))\,du\}$ over increasing convex $g$ (for CVaR, $g(x)=(x-\beta)_+/(1-\alpha)$ gives back Rockafellar–Uryasev) turns the risk constraint into an expectation for each fixed $g$.
Let $X$ be a bounded real loss on a probability space, and let $\sigma:[0,1]\to[0,\infty)$ be integrable, nondecreasing and normalised by $\int_0^1\sigma(u)\,du=1$. With $F_X^{-1}(u)=\inf\{x:F_X(x)\ge u\}$ and $g^*(y)=\sup_{x\in\mathbb R}(xy-g(x))$,
where the infimum is over finite-valued convex nondecreasing functions $g:\mathbb R\to\mathbb R$, allowing the conjugate integral to be $+\infty$ (such a function cannot lower the infimum). This is a value identity; an attaining $g$ need not be assumed.
Intuition: Fenchel's inequality $xy\le g(x)+g^*(y)$ gives an upper bound for each quantile paired with its weight. Optimising the convex function makes that bound sharp. Larger quantiles receive larger weights, explaining risk aversion. Boundedness of $X$ and integrability of $\sigma$ keep the risk finite. The CVaR substitution below computes the identity explicitly, including distributions with atoms.
The CVaR case in detail. For $g(x)=k(x-\beta)_+$ with $k=1/(1-\alpha)$, maximise $xy-g(x)$ separately over $x\le\beta$ (slope $y$) and over $x\ge\beta$ (slope $y-k$): $g^*(y)=\beta y$ for $0\le y\le k$ and $g^*(y)=+\infty$ otherwise. The CVaR spectrum takes only the values $0$ and $k$, so $\int_0^1g^*(\sigma(u))\,du=\beta\int_0^1\sigma(u)\,du=\beta$, and the infimum over this family of $g$ is $\inf_\beta\{\beta+\mathbb E[(X-\beta)_+]/(1-\alpha)\}$, exactly the Rockafellar–Uryasev formula.
SRCPO is therefore bilevel: the outer problem optimises the dual variables of the risk measure, the inner problem is a CMDP on the augmented state $(s_t,\{e_{i,t}\},\gamma^t)$ with $e_{i,t+1}=(c_{i,t}+e_{i,t})/\gamma$, and, to the authors' knowledge, it is the first risk-constrained method with a guarantee of convergence to an optimum in the tabular setting (earlier CVaR methods, Chow et al. included, guarantee only local convergence). That guarantee is narrower than "tabular" suggests. The inner theorem (their Thm 5.3) needs finite augmented state and action spaces (the accumulated-cost coordinates included), softmax policies and a strictly feasible policy. The outer theorem (Thm 6.3) needs a finite set of candidate parameters $\beta$ and a softmax sampler. A general spectrum is first replaced by an $M$-step function, which changes the risk by at most $C_{\max}\sigma(1)/((1-\gamma)M)$ (their Lemma 6.1). So the optimum reached is that of this finite, discretised problem; their practical algorithm, which samples $\beta$ from continuous ranges with a truncated-normal sampler, is not covered by the theorems.
The augmented state in detail: $e_{i,0}=0$ and $e_{i,t}=\gamma^{-t}\sum_{j\lt t}\gamma^jc_{i,j}$, the discounted cost accumulated so far, rescaled; then $e_{i,t+1}=(e_{i,t}+c_{i,t})/\gamma$, and the extra coordinate $\gamma^t$ converts back, $\gamma^te_{i,t}=\sum_{j\lt t}\gamma^jc_{i,j}$. The outer parameter vector $\beta$ fixes a finite-dimensional choice of the convex function $g$; it is not a CMDP multiplier. $C_{\max}$ bounds each one-step cost, and the discretisation bound is informative when $\sigma(1)$ is finite. See SRCPO, Sections 5–6.
7. Almost-Sure Constraints via State Augmentation
Under a cumulative constraint that must hold with probability one, how carefully the agent should act depends on how much budget is left, and a stationary policy $\pi(a\mid s)$ cannot see that. Feasibility is not necessarily the obstacle: with nonnegative costs, for instance, a policy that always picks an available zero-cost action is safe on every trajectory. What fails in general is optimality. Stationary policies in the original state need not include an optimal policy, and in Sootla et al.'s ablation the unaugmented policy hedges by leaving budget unused and pays for it in task cost. Tracking the remaining budget restores a Markov description, and Lemma 1 of the Wachi–Shen–Sui survey makes the missing variable explicit. Over a finite horizon $H$, with nonnegative costs (the survey takes $c\in[0,1]$) and budget $d$ (the survey's $\xi$), define the remaining discounted budget $\eta_{h+1}=\gamma_c^{-1}(\eta_h-c(s_h,a_h))$, $\eta_0=d$. Then $\sum_{h\le H}\gamma_c^hc(s_h,a_h)\le d$ iff $c(s_h,a_h)\le\eta_h$ for all $h$, so the single cumulative constraint is equivalent to instantaneous constraints on an augmented state. The closed form is $\eta_h=\gamma_c^{-h}\big(d-\sum_{h'\lt h}\gamma_c^{h'}c_{h'}\big)$: the rescaling by $\gamma_c^{-h}$ is what makes the recursion time-invariant, and $c_h\le\eta_h$ says exactly that the partial sum up to $h$ is within budget. Nonnegativity is what turns "every partial sum within budget" into "the total within budget": with signed costs an early overspend could be repaid later, and the instantaneous constraints would be strictly stronger than the cumulative one.
"With probability one" (almost surely, a.s.) allows exceptional trajectories as long as their total probability is zero; it is not literally a statement about every conceivable trajectory. Because time steps are countable, per-step statements combine: if $\mathbb P(E_t)=1$ for every $t$, then $\mathbb P(\bigcap_tE_t)=1$, since by the union bound the complements have total probability at most $\sum_t\mathbb P(E_t^c)=0$.
They make expected costs well defined and let minimising actions survive the limit $n\to\infty$. Measurable functions are those for which probabilities and integrals such as $\mathbb E\,\tilde c_n(s_t,z_t,a_t)$ are defined. A stochastic kernel assigns a distribution $P(\cdot\mid s,a)$ to every state-action pair, measurably in $(s,a)$; it need not have a density (a deterministic transition is a point mass). Weakly continuous transitions: $\int f(s')\,P(ds'\mid s,a)$ depends continuously on $(s,a)$ for every bounded continuous test function $f$. Compact actions: in $\mathbb R^k$, closed and bounded (Primer 0). A lower semicontinuous cost satisfies $\tilde c_n(y)\le\liminf_{y'\to y}\tilde c_n(y')$: it may jump up but never down at a point. The reshaped cost has exactly such a jump at the budget boundary, $\tilde c_n=c$ at $z=0$ and $n$ for $z\lt0$, which is lower semicontinuous (for continuous $c$) as long as $n\ge c$. For finite state and action sets all these conditions hold automatically. Theorem 3 is the union bound above at work: if $z_t\lt0$ had positive probability at some time $t$, the expected cost in $\tilde{\mathcal M}_\infty$ would be infinite, so a finite-cost optimal policy has $z_t\ge0$ at every $t$ with probability one, hence at all $t$ simultaneously.
Two remarks. The a.s. formulation is much stronger than an expected or CVaR budget, and only makes sense when a policy that never overspends exists; in practice $n$ is finite, and $V_n^\star\uparrow V_\infty^\star$ is a statement about optimal values, not a violation bound for any finite-$n$ policy: a finite penalty can still make a rare or heavily discounted violation worthwhile. And because $d$ enters only as the initial safety state, one policy generalises across budgets by changing $z_0$: in their generalisation experiment (a pendulum-type task, their Fig. 4) a policy trained with budgets sampled from $[5,100]$ met test budgets of 40 and 80 more reliably than one trained at the single budget 60. Their Safety Gym runs, by contrast, test the almost-sure constraint itself, with a few outlier trajectories still violating it.
The multiplier as a state. Calvo-Fullana, Paternain, Chamon, Ribeiro, IEEE TAC 2024 augment with a different summary of the constraint history: the Lagrange multiplier itself. (They use the utility convention of the monitoring problem: rewards $r_i$ with thresholds $c_i$ and constraints $V_i\ge c_i$ on long-run averages, so here $c_i$ is a number, not a cost function.) Training samples $(s,\lambda)$ from $\mathcal S\times\Lambda$ and solves the ordinary MDP with reward $r_\lambda(s,a)=r_0(s,a)+\sum_i\lambda_i(r_i(s,a)-c_i)$ for a policy $\pi_\theta(a\mid s,\lambda)$ (Alg. 1). Execution runs the dual dynamics online (Alg. 2): for epochs of length $T_0$, act with $\pi_\theta(\cdot\mid s_t,\lambda_k)$ and then
Assumptions. (A1) a strictly feasible policy with margin $C\gt0$; (A2) $|r_i(s,a)-c_i|\le B$ for all $s,a,i$, as printed; the proof, however, bounds the squared Euclidean norm of the whole vector of epoch-averaged violations by $B^2$, so with $m$ constraints read $B$ as a bound on $\|r(s,a)-c\|_2$, or replace $B^2$ by $mB^2$ below; (A3) the epoch averages are unbiased given the current multipliers, $\mathbb E\big[\frac1{T_0}\sum_{t=kT_0}^{(k+1)T_0-1}r_i(s_t,a_t)\,\big|\,\lambda_k\big]=V_i(\pi(\lambda_k))$ (the proof uses the same for the objective $r_0$). A rollout that starts from an arbitrary state is in general biased for a long-run average; the paper's Appendix II treats that case.
Statement. The state-action sequence satisfies $\liminf_{T}\frac1T\sum_{t\lt T}r_i(s_t,a_t)\ge c_i$ almost surely for every constraint, and $\lim_T\mathbb E\big[\frac1T\sum_{t\lt T}r_0(s_t,a_t)\big]\ge P^\star-\eta_\lambda B^2/2$ (the proof bounds the $\liminf$, which is the safe reading if the limit does not exist).
In words. Nothing is claimed about any single policy $\pi(\lambda_k)$ being optimal; the guarantee is about the trajectory generated by switching among Lagrangian maximisers as the multipliers drift. In the monitoring problem of Section 3 the multiplier $\lambda_i$ records the deficit of time spent in $R_i$ relative to $c$ (their Eq. 16); the executed policy at $R_1$ jumps between "return to $R_0$" ($\lambda_1\lt\max(1,\lambda_2)$) and "stay in $R_1$" ($\lambda_1\gt\max(1,\lambda_2)$; a large $\lambda_1$ alone is not enough, since with $\lambda_2\gt\lambda_1\gt1$ heading for $R_2$ pays more, and at ties the Lagrangian leaves the choice to the policy's tie-breaking), neither of which solves the problem, while the time averages of the switched trajectory meet both fractions (their Fig. 3). The failure of fixed-$\lambda$ methods there is one of recovery, not of representation (Exercise 8.6).
Reading the statement: for a sequence $a_T$, $\liminf_Ta_T=\lim_{N\to\infty}\inf_{T\ge N}a_T$ is its eventual lower envelope (Primer 0). So the constraint part says that, with probability one, for every $\epsilon\gt0$ the running average $\frac1T\sum_{t\lt T}r_i(s_t,a_t)$ falls below $c_i-\epsilon$ only finitely often; deficits at finite times are allowed. The reward part is about an expectation over trajectories, not a bound on each realised average.
8. Adjacent: Safe RLHF
The data are prompts $x$ with pairs of responses $(y_w,y_l)$, where a labeller preferred $y_w$. A Bradley–Terry model turns a score difference into a probability, $\mathbb P(y_w\succ y_l\mid x)=\sigma\big(R(y_w,x)-R(y_l,x)\big)$ with the sigmoid $\sigma(z)=1/(1+e^{-z})$: equal scores give $\tfrac12$, a difference of $\log3$ gives $\tfrac34$. Fitting $R$ means minimising the negative log-likelihood $-\log\sigma(\cdot)$ averaged over the labelled pairs, which is small when the model gives the observed preference a high probability. In the cost model the comparison is harmfulness, so $y_w$ is the more harmful response. Pairwise differences do not change if all scores are shifted by a constant, so the second term of $L_C$ anchors the sign: $-\log\sigma(sC)$ is small when a harmful response ($s=+1$) gets $C\gt0$ and a harmless one ($s=-1$) gets $C\lt0$.
Dai et al., ICLR 2024 carry the CMDP template into language-model alignment. Human preferences are collected separately for helpfulness and harmlessness; a reward model $R_\phi(y,x)$ (learned reward models: Primer E) is fitted to the first with the Bradley–Terry loss, and a cost model $C_\psi(y,x)$ to the second with a pairwise term plus a classification term that anchors the sign of the cost: $$L_C(\psi)=-\mathbb E\big[\log\sigma\big(C_\psi(y_w,x)-C_\psi(y_l,x)\big)\big]-\mathbb E\big[\log\sigma(s_wC_\psi(y_w,x))+\log\sigma(s_lC_\psi(y_l,x))\big],$$ where in the harmlessness dataset $y_w$ is the more harmful response of the pair and $s=+1$ marks a harmful, $s=-1$ a harmless response, so that $C_\psi\gt0$ means unsafe and the boundary $C_\psi=0$ is a virtual response that the second term pins down. The fine-tuning problem is then a CMDP with a one-step horizon if the whole response is read as one action (prompt $x$, response $y\sim\pi_\theta(\cdot\mid x)$; PPO itself works token by token, $y=a_{1:T}$): $\max_\theta J_R(\theta)$ s.t. $J_C(\theta)\le0$ with $J_R=\mathbb E[R_\phi(y,x)]$, $J_C=\mathbb E[C_\psi(y,x)]+d$, relaxed to $\min_\theta\max_{\lambda\ge0}[-J_R(\theta)+\lambda J_C(\theta)]$ and solved by alternating PPO steps (Primer E) on $\theta$ with multiplier steps on $\lambda$ (Section 4); the offset $d$ tunes the permitted expected signed cost score.
The offset enforces $\mathbb E[C_\psi]\le-d$. This constrains an average score, not directly $\Pr(C_\psi>0)$. Positive scores can be offset by sufficiently negative ones. Converting this budget to a harmful-output frequency requires additional assumptions about score bounds or calibration. Likewise, convergence results from earlier sections do not transfer automatically to PPO with learned reward and cost models.
The Lagrangian template applies: the multiplier tracks the constraint violation as an integral controller, the trained policy is a Lagrangian maximiser rather than a certified-safe object, and the guarantee is on an expectation over prompts, not on individual outputs. The reported effect over three rounds on Alpaca-7B is a drop of harmful responses on their evaluation set from 53.08% to 2.45% with improved helpfulness, and the method spawned multimodal follow-ups. For the reader of this section the interesting point is the decoupling: one reward model per objective, with the trade-off set by a budget instead of a fixed weight, which is exactly the argument of Section 1 restated for LLMs.
Walkthrough: Dual Ascent on a Two-Action CMDP
The smallest CMDP that shows everything: one state, two actions, one budget. We compute the dual function by hand, recover the mixed optimum from the KKT conditions, and watch a fixed-step dual ascent oscillate around $\lambda^\star$. ("Dual ascent" is the traditional name, from the cost-minimisation convention, in which the dual function is concave and maximised; in this page's convention the very same multiplier update is projected subgradient descent on the convex $D$, as in Section 4.)
Interactive: Multiplier Dynamics (Plain vs PID)
Compare plain and PID multiplier updates on the same toy constrained policy. Change one gain and predict whether the cost settles near the budget, oscillates or overshoots. The plots show a finite simulation; the model and reference-line assumptions are explained below.
A one-parameter policy $p\in[0,1]$ with return $J_r(p)=p$ and a nonlinear cost $J_c(p)=2p+0.5\sin(3p)$ is trained by projected gradient ascent on the Lagrangian, $p\leftarrow\mathrm{clip}(p+\eta_\pi(1-\lambda J_c'(p)))$, while the multiplier follows either the plain integral rule or Algorithm 3 with the same $K_I$. The cost fed to the controller is a noisy estimate $\hat J_c=J_c(p)+\sigma\xi$ with seeded Gaussian noise (identical noise for both controllers). Everything is simulated for 300 iterations. The constrained optimum $p^\star$ is found by bisection on $J_c(p^\star)=d$ and $\lambda_{\rm KKT}=1/J_c'(p^\star)$ from stationarity; for $d\ge J_c(1)\approx2.07$, $p^\star=1$ and zero is a valid KKT multiplier; the constraint is strictly slack only for $d\gt J_c(1)$.
This explorer is a nonlinear scalar control surrogate, not the unrestricted occupancy-LP CMDP. Denote its equilibrium multiplier by $\lambda_{\rm KKT}=1/J_c'(p^\star)$. Since $J_c''(p)\lt0$ in the interior, $L(p,\lambda)=p-\lambda(J_c(p)-d)$ is convex in $p$ for $\lambda\gt0$ ($\partial_p^2L=-\lambda J_c''(p)\gt0$): the stationary point is a minimum in $p$, not the maximum. At $d=1$, $p^\star\approx0.30285$ and $\lambda_{\rm KKT}\approx0.34219$. Because $L$ is convex in $p$, its maximum over $[0,1]$ sits at an endpoint, so the actual dual function is $D(\lambda)=\lambda d+\max(0,1-\lambda J_c(1))$ (using $J_c(0)=0$). It is minimised at $\lambda=1/J_c(1)\approx0.48296$ with value $d/J_c(1)\approx0.483$ at $d=1$, above $P^\star=p^\star\approx0.303$: a positive duality gap, possible here because this one-parameter family cannot mix policies. The plotted reference $\lambda_{\rm KKT}$ illustrates local feedback regulation around a KKT point, not the dual optimum.
Why bisection: $J_c'(p)=2+1.5\cos(3p)\ge2+1.5\cos3\gt0.5$ on $[0,1]$, so the cost is strictly increasing. For $0\lt d\lt J_c(1)$ the feasible $p$ form an interval $[0,p^\star]$ with $J_c(p^\star)=d$, and maximising the reward $p$ picks its right end. Bisection finds $p^\star$: start with $[0,1]$, evaluate $J_c$ at the midpoint, keep the half in which $J_c-d$ changes sign; each step halves the interval.
Reading the panel. The eigenvalue readout describes the noise-free local P–I model of Section 5(b)–(c) (projections inactive, $K_D=0$): a modulus above one means that small perturbations grow in that model, not that the clipped nonlinear dynamics settle on a periodic orbit; noise, clipping and the one-sided D term can change what you see, so treat an apparent cycle as a simulation observation. The controllers see $\hat J_{c,k}=J_c(p_k)+\sigma\xi_k$ with standard-normal $\xi_k$ from a fixed seed, so both runs get the same draws. The settling readout reports the iteration from which all remaining displayed samples (up to iteration 299) stay within $\max(0.05d,0.02)$ of $J_c(p^\star)$: a finite-run diagnostic, not a guarantee for later iterations or fresh noise. Overshoot is the largest positive $J_c(p_k)-d$ in the run.
If $d>J_c(1)$, the cost constraint is strictly slack at $p=1$, so its KKT multiplier is zero. If $d=J_c(1)$, the cost constraint and the boundary $p=1$ are both active; zero is one valid multiplier choice, but complementary slackness does not uniquely determine it.
Linear-model prediction (Section 5(b)–(c)): with loop gain $c=\eta_\pi J_c'(p^\star)^2$ and curvature factor $a=1-\eta_\pi\lambda_{\rm KKT} J_c''(p^\star)$ the local loop matrix is $M=\begin{bmatrix}a-c(K_P+K_I)&-cK_I\\1&1\end{bmatrix}$ with $\det M=a-cK_P$. Here $J_c$ is concave, so the Lagrangian is convex in $p$ and $a\gt1$: the integral-only loop is weakly unstable ($|z|=\sqrt a$ slightly above 1) and its oscillation can grow until clipping changes the motion; a periodic limiting orbit is not implied by the local model. With $K_P\gt0$ complex eigenvalues have modulus $\sqrt{a-cK_P}$, below 1 once $cK_P\gt a-1$. Try $K_P=K_D=0$ to see the two curves coincide, then raise $K_P$; raise $\sigma$ to see how the P and D terms pass estimation noise straight into $\lambda$ (the projected D term only upwards), which is why Stooke et al. smooth the proportional and derivative inputs.
From the mathematics to a real decision
- Translate an operational requirement into an expected discounted cost and identify what that requirement leaves uncontrolled.
- Solve a constrained choice between policies and interpret a multiplier as a trade-off price.
- Carry a remaining budget through a trajectory instead of treating every decision as a fresh start.
A delivery robot with two operating modes
Imagine a warehouse robot whose planner chooses a cautious or a fast mode. The following numbers are invented to make the modeling choices visible; they are not measurements from a warehouse. At each decision, cautious mode has expected productivity reward 2 points and probability 0.02 of entering a marked exclusion zone. Fast mode has expected reward 5 points and probability 0.20 of such an entry. The cost is an indicator: 1 for an entry, 0 otherwise. We assume the same distribution is available at every decision and that actions do not change future state distributions. This one-state model is deliberately simpler than a moving robot.
The engineering question is not initially “Which algorithm should we train?” It is “What exactly is the admissible operating behavior?” Suppose a designer sets discount $\gamma=0.9$ and expected discounted cost budget $d=1$. Discounting says that an event ten decisions from now receives weight $0.9^{10}$. That is a mathematical preference, not a physical claim that a late exclusion-zone entry is harmless. If entry must never happen, this cost budget expresses the wrong requirement, whatever optimizer is used.
Worked decision: mix the two modes
Let $p\in[0,1]$ be the probability of choosing fast mode independently at each decision. Its expected one-step reward is $2(1-p)+5p=2+3p$. The expected one-step cost is $0.02(1-p)+0.20p=0.02+0.18p$. Linearity of expectation and the geometric series give
First solve feasibility, before maximizing anything. The inequality $0.2+1.8p\le1$ gives $p\le0.8/1.8=4/9$. Productivity increases with $p$, so the best feasible mixture is $p^\star=4/9$, with $J_r=100/3$ and $J_c=1$. The cost constraint is active: it is the feature that prevents the reward-maximizing choice $p=1$.
Now construct the reward-maximization Lagrangian $L(p,\lambda)=20+30p-\lambda(0.2+1.8p-1)$, with $\lambda\ge0$. Its coefficient of $p$ is $30-1.8\lambda$. At $\lambda^\star=50/3$ that coefficient is zero. Every mixture maximizes this particular inner objective, while the constrained problem selects the feasible one with the greatest reward. This explains why finding an optimal multiplier alone does not necessarily identify a unique policy.
The same number has a useful sensitivity interpretation. For budgets between 0.2 and 2, the optimal reward is $20+(50/3)(d-0.2)$. Increasing the budget by 0.01 increases the attainable discounted reward by $1/6$ point in this model. The interpretation is local to this range and this model. Outside it, the probability limits $0\le p\le1$ change the formula.
Even cautious mode has a positive entry probability. Under independent repetitions, the probability of no entry in the first $T$ decisions is $0.98^T$, which tends to zero. Its discounted cost is only 0.2, yet an entry eventually occurs with probability 1. The independence assumption is needed for this particular product calculation; the general distinction between expected cost and trajectory safety does not depend on it. A physical exclusion zone needs a different model or a safety mechanism such as the filter in Module 10’s application.
Worked trajectory: remember what has already been spent
A second designer specifies a pathwise discounted resource budget rather than an expected entry count. Let the realized resource costs be $c_0=0.4$ and $c_1=0.2$, with initial budget 1 and discount 0.9. The rescaled remaining budget is $z_{t+1}=(z_t-c_t)/0.9$. The units of $z_t$ match the cost at decision $t$, because discounting back to decision zero has been divided out.
Check this against the original accounting. The discounted spend is $0.4+0.9(0.2)=0.58$; the remainder is 0.42, and $0.9^2z_2=0.42$. A proposed next cost 0.6 exceeds $z_2$ and produces total discounted spend $0.58+0.81(0.6)=1.066$. An agent looking only at the current physical state could miss this violation. The augmented state must include the budget when the objective is to respect this trajectory requirement.
This update is bookkeeping, not a complete controller. A policy must still choose an action whose possible costs and successors respect the remaining budget, and there may be no such action. Expected-cost CMDPs, almost-sure budget constraints and robust physical constraints are different design problems. Write the chosen requirement in words beside the equation.
Application exercises
Exercise 8.B1 — Medium: Reprice a tighter operating budget
Keep the two-mode model but reduce $d$ to 0.65. Find the best fast-mode probability, discounted reward and cost. Explain whether the optimal multiplier changes while the constraint remains between the two pure-mode costs.
Show hint
Solve $0.2+1.8p\le0.65$ first. Then inspect the slope of the best reward as a function of the budget.
Show solution
Feasibility gives $p\le0.45/1.8=1/4$. Increasing reward makes $p^\star=1/4$, $J_r=20+30/4=27.5$ and $J_c=0.65$. The interior-range slope is still $30/1.8=50/3$, so the multiplier remains $50/3$. The smaller budget changes the mixture, not this model’s marginal productivity-to-cost ratio. Neither result implies zero entry probability.
Exercise 8.B2 — Hard: Change the discount without changing the meaning by accident
Change $\gamma$ to 0.95 and keep the numerical budget $d=1$. Find the new optimal mixture and reward. What happens if the designer reuses $p=4/9$? State a modeling reason to reconsider the budget when changing the discount.
Show hint
The divisor is now $1-\gamma=0.05$. A constant one-step cost is counted twice as heavily as before.
Show solution
The new cost is $0.4+3.6p$, so $p^\star=0.6/3.6=1/6$. The reward is $(2+3/6)/0.05=50$. Reusing $4/9$ gives cost $0.4+3.6(4/9)=2$, violating the budget. Reward values at different discounts are not directly comparable totals over the same effective horizon. A fixed numerical discounted budget represents a different allowable constant cost when the discount changes; the operational requirement must determine whether that change is intended.
Exercise 8.B3 — Hard: A monitoring variable is part of the decision
Use the trajectory example with $z_2=14/27$. Two actions next have deterministic resource costs 0.5 and 0.6. Which action preserves a nonnegative remaining budget? Compute $z_3$ for the admissible action and verify the accounting at the original time scale.
Show hint
Compare each immediate cost with $z_2$ and multiply the new remainder by $0.9^3$ to check it.
Show solution
Only 0.5 is at most $14/27$. It gives $z_3=(14/27-1/2)/(9/10)=5/243$. Discounted spend becomes $0.4+0.9(0.2)+0.81(0.5)=0.985$, while $0.9^3(5/243)=0.015$. These sum to 1. The check concerns deterministic realized costs here. With uncertain costs, preserving a pathwise budget requires considering every allowed cost realization rather than substituting its expectation.
What to carry into the next chapter
Close the calculations and explain three objects: the feasible policy set, the multiplier, and the trajectory budget. Give an example of a requirement each one does not enforce. Then change one assumption—state dependence, discount or uncertain costs—and identify the first step of the derivation that needs replacing. Module 9 addresses a further problem: even when the target constraint is clear, an approximate update can mispredict its effect.
Exercises
Graded practice
Each level has four problems. Write your steps before opening the answer; use the hint when you need a first move. Close the answer and retry after checking it.
Easy practice
Exercise 8.P1 — Easy: Discounted reward and cost
A policy receives reward $2$ and cost $1/4$ at every time step. Let $\gamma=1/2$ and cost budget $d=3/5$. Compute $J_r,J_c$ and decide feasibility.
Review this topic · Revisit the prerequisite
Show hint
Show answer
$J_r=2/(1-1/2)=4$ and $J_c=(1/4)/(1-1/2)=1/2$. Since $1/2\le3/5$, the policy is feasible. The per-step cost is $1/4$, but the constraint is on its discounted cumulative value $1/2$; comparing $1/4$ directly with $d$ would check a different requirement.
Exercise 8.P2 — Easy: A mixed action and its occupancy
In one self-looping state, choose action $R$ with probability $0.3$ and action $S$ otherwise. Rewards are $r(R)=3,r(S)=1$; costs are $c(R)=2,c(S)=0$; $\gamma=1/2$. Find normalized action occupancies, $J_r$ and $J_c$.
Review this topic · Revisit the prerequisite
Show hint
Show answer
The occupancies are $\rho(R)=0.3$, $\rho(S)=0.7$, summing to $1$. The expected per-step reward is $0.3(3)+0.7(1)=1.6$ and cost is $0.3(2)=0.6$. Dividing by $1-\gamma=0.5$ gives $J_r=3.2$ and $J_c=1.2$. Occupancy normalizes visitation; the discounted return restores the factor $1/(1-\gamma)$.
Exercise 8.P3 — Easy: Evaluate the penalized reward
Use $L=J_r-\lambda(J_c-d)$ with $J_r=8$, $d=4$, $\lambda=1.5$. Evaluate $L$ for $J_c=5$ and for $J_c=3$. Explain the difference.
Review this topic · Revisit the prerequisite
Show hint
Show answer
For cost $5$, the residual is $1$, so $L=8-1.5=6.5$. For cost $3$, the residual is $-1$, so $L=8+1.5=9.5$. At this fixed multiplier, violating the budget lowers the policy objective and slack raises it. Neither number alone is the dual optimum: the dual function also maximizes over policies and then minimizes over nonnegative multipliers.
Exercise 8.P4 — Easy: Two projected multiplier updates
Update $\lambda_{k+1}=\max\{0,\lambda_k+0.2(J_{c,k}-2)\}$. Starting from $\lambda_0=0.1$, use costs $J_{c,0}=3$ and $J_{c,1}=0$. Find both updates.
Review this topic · Revisit the prerequisite
Show hint
Show answer
First, $\lambda_1=\max\{0,0.1+0.2(3-2)\}=0.3$. Then $\lambda_2=\max\{0,0.3+0.2(0-2)\}=\max\{0,-0.1\}=0$. Violation increases the penalty; slack reduces it. Projection keeps the multiplier in its permitted domain $\lambda\ge0$.
Medium practice
Exercise 8.P5 — Medium: Verify discounted flow on two states
Start at state $0$, move deterministically to state $1$, and stay there. There is one action and $\gamma=1/2$. Find normalized state occupancies and verify their flow equations. With rewards $r(0)=0,r(1)=2$, find the return.
Review this topic · Revisit the prerequisite
Show hint
Show answer
$\rho(0)=(1-\gamma)=1/2$ and $\rho(1)=(1-\gamma)\sum_{t\ge1}\gamma^t=1/2$. State $0$ has flow $\rho(0)=(1-\gamma)\mu(0)+0=1/2$. State $1$ has flow $\rho(1)=0+\gamma(\rho(0)+\rho(1))=1/2$. The normalized expected reward is $0(1/2)+2(1/2)=1$, so $J_r=1/(1-\gamma)=2$. Directly, $2\sum_{t\ge1}(1/2)^t=2$, confirming the normalization.
Exercise 8.P6 — Medium: Solve a small constrained policy problem
One state self-loops. A risky action has reward $4$ and cost $2$; the other has reward $1$ and cost $0$. Choose the risky action with stationary probability $p$. Let $\gamma=1/2,d=1$. Find the feasible range of $p$ and the optimal return.
Review this topic · Revisit the prerequisite
Show hint
Show answer
The one-step reward is $1+3p$ and cost is $2p$. Thus $J_r=2+6p$ and $J_c=4p$. Feasibility requires $0\le p\le1$ and $4p\le1$, giving $0\le p\le1/4$. Since the return increases with $p$, the optimum is $p=1/4$ with $J_r=7/2=3.5$. Always choosing the safe action gives only $2$; always choosing the risky action violates the budget. Randomization fills the useful gap.
Exercise 8.P7 — Medium: A tail statistic differs from its expectation
A cost $Z$ is $0$ with probability $0.8$ and $10$ with probability $0.2$. Find its expectation, $\mathrm{VaR}_{0.9}$ and upper-tail $\mathrm{CVaR}_{0.9}$, where CVaR averages the worst $10\%$, including fractional mass at a quantile.
Review this topic · Revisit the prerequisite
Show hint
Show answer
$\mathbb E[Z]=0.8(0)+0.2(10)=2$. The distribution function is $0.8$ at $0$ and $1$ at $10$, so its first value reaching $0.9$ is at $10$: $\mathrm{VaR}_{0.9}=10$. The worst $10\%$ of outcomes all have cost $10$, hence $\mathrm{CVaR}_{0.9}=10$. Counting only half the mass at $10$ is legitimate; the tail definition does not require taking an entire atom.
Exercise 8.P8 — Medium: Track a discounted remaining budget
For $\sum_{t\ge0}\gamma^t c_t\le2$ with $\gamma=1/2$, express remaining budget in current-time units by $z_{t+1}=(z_t-c_t)/\gamma$, $z_0=2$. Take $c_0=1,c_1=1.5$. Compute $z_1,z_2$ and the unused budget in original-time units after these costs.
Review this topic · Revisit the prerequisite
Show hint
Show answer
$z_1=(2-1)/(1/2)=2$ and $z_2=(2-1.5)/(1/2)=1$. The original discounted spending is $1+(1/2)(1.5)=1.75$, leaving $0.25$. This matches $\gamma^2 z_2=(1/4)(1)=0.25$. The value $z_1=2$ does not mean the original budget refilled: future costs are measured in different discount units. Including $z_t$ in the state makes that available budget visible to the policy.
Hard practice
Exercise 8.P9 — Hard: Recover the mixed optimum from the dual
For $J_r=2+6p$, $J_c=4p$, $d=1$, $0\le p\le1$, derive $D(\lambda)=\max_p L(p,\lambda)$ and minimize it for $\lambda\ge0$. Why is selecting an arbitrary maximizer of $L$ at the optimal multiplier insufficient?
Review this topic · Revisit the prerequisite
Show hint
Show answer
$L=2+6p-\lambda(4p-1)=2+\lambda+(6-4\lambda)p$. Therefore $D(\lambda)=\max\{2+\lambda,8-3\lambda\}$. The second line decreases until it meets the increasing first line: $2+\lambda=8-3\lambda$ gives $\lambda^\ast=1.5$ and $D(\lambda^\ast)=3.5$.
At that multiplier the coefficient of $p$ is zero, so every $p\in[0,1]$ maximizes $L$. Some are infeasible. Among feasible values, the largest reward occurs at $p=1/4$, which has cost $1$ and reward $3.5$. Dual optimality must be combined with primal feasibility and complementary slackness to recover an optimal policy.
Exercise 8.P10 — Hard: Audit an average-violation guarantee
Two successive constraint residuals are $e_1=1,e_2=-1$. Compare $[(e_1+e_2)/2]_+$ with $([e_1]_++[e_2]_+)/2$, where $[x]_+=\max\{x,0\}$. What can a bound on the first quantity establish about the safety of each iterate?
Review this topic · Revisit the prerequisite
Show hint
Show answer
The signed average is $0$, so its positive part is $0$. The average of positive violations is $(1+0)/2=1/2$. The first quantity allows unsafe iterations to cancel against slack at other iterations; the second counts the violation without that cancellation. Even a zero bound on the signed average does not establish feasibility of every iterate: the first residual is positive. The location of the positive-part operation changes the guarantee.
Exercise 8.P11 — Hard: An expected budget can allow rare failure
A trajectory costs $100$ with probability $0.01$ and $0$ otherwise; call the cost-$100$ outcome a failure. Does it meet expected budget $1$? Find failure probability, $\mathrm{VaR}_{0.95}$ and $\mathrm{CVaR}_{0.95}$. Explain what an expected-cost certificate permits here.
Review this topic · Revisit the prerequisite
Show hint
Show answer
The expected cost is $0.01(100)=1$, so the expected budget is met. Failure still has probability $0.01$. Since $\mathbb P(Z\le0)=0.99\ge0.95$, $\mathrm{VaR}_{0.95}=0$. The worst $5\%$ has total weighted cost $0.01(100)+0.04(0)=1$; dividing by $0.05$ gives $\mathrm{CVaR}_{0.95}=20$.
The expected-cost statement is correct but does not exclude rare expensive trajectories. Replacing it by a chance or tail-risk requirement changes the optimization problem and its meaning.
Exercise 8.P12 — Hard: Derive the multiplier sign rather than memorizing it
For reward maximization subject to $J_c\le d$, prove that $D(\lambda)=\sup_\pi[J_r-\lambda(J_c-d)]$ is an upper bound on the feasible optimum for every $\lambda\ge0$. Assuming an exact inner maximizer, derive the projected dual descent update.
Review this topic · Revisit the prerequisite
Show hint
Show answer
For any feasible policy, $J_c-d\le0$, hence $-\lambda(J_c-d)\ge0$ and $L(\pi,\lambda)\ge J_r(\pi)$. Taking the supremum over all policies can only increase this, so $D(\lambda)\ge\sup_{\pi\ {\rm feasible}}J_r(\pi)$. Consequently the tightest such dual bound is obtained by minimizing $D$.
An exact maximizing policy supplies subgradient $d-J_c$ of $D$. A projected descent step is $\lambda^+=[\lambda-\eta(d-J_c)]_+=[\lambda+\eta(J_c-d)]_+$. This explains why an upper-budget violation increases the multiplier even though the dual objective is minimized in this convention.
Original longer exercises
Key Papers
| Paper | Venue | Contribution | Why read it |
|---|---|---|---|
| Altman, Constrained Markov Decision Processes | Book, Chapman & Hall/CRC 1999 | Occupation-measure LPs, Lagrangian duality, at most $K$ randomisations | The reference for Sections 1–2; cost-minimisation convention |
| Paternain, Chamon, Calvo-Fullana, Ribeiro, Constrained RL Has Zero Duality Gap | NeurIPS 2019 | Zero duality gap under Slater; $O(\epsilon/(1-\gamma)^2)$ gap for $\epsilon$-universal policies with unnormalised returns (printed as $\epsilon/(1-\gamma)$, see Section 3); dual descent analysis | The theoretical licence for every Lagrangian method |
| Calvo-Fullana, Paternain, Chamon, Ribeiro, State Augmented Constrained RL | IEEE TAC 69(7), 2024 | CMDPs that no weighted reward solves; multiplier as state; feasible near-optimal trajectories | Makes the primal-recovery problem concrete |
| Tessler, Mankowitz, Mannor, Reward Constrained Policy Optimization | ICLR 2019 | Penalised reward, three timescales, a.s. convergence to a feasible fixed point | Template of PPO-/SAC-Lagrangian baselines |
| Stooke, Achiam, Abbeel, Responsive Safety in RL by PID Lagrangian Methods | ICML 2020 | Multiplier update as integral control; P and D terms; reward-scale invariance via $\beta_\nabla$ | Explains and fixes the oscillations you will see in practice |
| Ding, Zhang, Başar, Jovanović, Natural Policy Gradient Primal-Dual Method for CMDPs; journal version (source of the constants quoted in Sections 3–4): Ding, Zhang, Duan, Başar, Jovanović, Convergence and Sample Complexity of Natural Policy Gradient Primal-Dual Methods for Constrained MDPs | NeurIPS 2020; journal version JMLR 26(256):1–76, 2025 | Dimension-free $O(1/\sqrt T)$ average-iterate convergence for softmax NPG-PD | First global rate; the MWU view of the primal step |
| Ding, Wei, Zhang, Ribeiro, Last-Iterate Convergent Policy Gradient Primal-Dual Methods | NeurIPS 2023 | RPG-PD (regularised, linear rate to a neighbourhood of a regularised saddle) and OPG-PD (optimistic) | How regularisation stops the cycling |
| Montenegro, Mussi, Papini, Metelli, Last-Iterate Global Convergence of Policy Gradients for Constrained RL | NeurIPS 2024 | C-PG: ridge-regularised dual, last-iterate rates under weak gradient domination, general parametrisations | The bias–rate trade-off of dual regularisation made explicit |
| Chow, Ghavamzadeh, Janson, Pavone, Risk-Constrained RL with Percentile Risk Criteria | JMLR 18(167), 2018 | CVaR- and chance-constrained MDPs, Lagrangian gradients with the VaR parameter, augmented-state actor-critic | The landmark risk-constrained formulation |
| Yang, Simão, Tindemans, Spaan, WCSAC | AAAI 2021 | Gaussian safety critic with closed-form CVaR constraint in SAC-Lagrangian | Simplest risk-averse deep baseline; know its Gaussian assumption |
| Kim et al., Spectral-Risk Safe RL with Convergence Guarantees | NeurIPS 2024 | Spectral risk constraints via duality; bilevel SRCPO with convergence to an optimum for finite, discretised problems (finite augmented spaces, finitely many $\beta$) | Generalises CVaR-constrained RL |
| Sootla et al., Sauté RL | ICML 2022 | Budget-augmented state and reshaped cost; Bellman equation; almost-sure constraints | The principal state-augmentation approach |
| Paternain, Calvo-Fullana, Chamon, Ribeiro, Safe Policies for RL via Primal-Dual Methods | IEEE TAC 68(3):1321–1336, 2023 | Chance constraints relaxed to CMDP constraints with safety-preserving slacks | Bridges invariance-type safety and the Lagrangian machinery |
| Dai et al., Safe RLHF | ICLR 2024 (spotlight) | Reward and cost models, Lagrangian PPO for LLM alignment | The CMDP template in a very different domain |
| Ray, Achiam, Amodei, Benchmarking Safe Exploration in Deep RL | OpenAI report 2019 | Safety Gym, cost-rate metric, Lagrangian vs CPO comparison | Why Lagrangian methods are the default baselines |
Further reading: García & Fernández, JMLR 2015 (the classic taxonomy: constrained criteria are one of its "modified optimality criterion" branches), Gu et al., IEEE TPAMI 2024 (comprehensive review including a comparison of CMDP sample complexities), Wachi, Shen, Sui, IJCAI 2024 (how the constraint formulations relate), Wu et al., ICLR 2024 (CAL).