Simple Algorithm
Reinforcement Learning · Fixed Point · 28 min

Constrained MDPs & Lagrangian Methods

Cost constraints, the primal–dual method and constrained policy optimization.

Add a single expected-cost constraint to an MDP and three classical facts fail at once: the optimal policy may have to randomize, it depends on where the agent starts, and Bellman's optimality equation over states no longer characterizes it. Yet the problem stays tractable: it is a linear program over occupancy measures, and its Lagrangian dual has no gap. This lesson proves both facts, follows the primal–dual dynamics that many deep safe-RL methods run and shows why they cycle, and derives the trust-region bound behind constrained policy optimization.

What you’ll learn

  • Write a constrained MDP as a linear program over discounted occupancy measures, and prove that some optimal stationary policy randomizes in at most KK states when there are KK constraints.
  • Prove that CMDPs have zero duality gap under Slater's condition from the convexity of the set of occupancy measures, and state the error term for parameterized policies.
  • Explain why gradient descent–ascent on the bilinear Lagrangian cycles in the last iterate while its average converges, and derive how a proportional term damps the multiplier.
  • Derive CPO's bound on a new policy's cost from the performance-difference lemma, and evaluate its worst-case constraint violation.

The linear program, and why optimal policies randomize

max⁡d≥0 ∑s,ad(s,a) r(s,a)s.t.∑ad(s′,a)=(1−γ)μ(s′)+γ∑s,aP(s′∣s,a) d(s,a)  ∀s′,∑s,ad(s,a) ck(s,a)≤(1−γ) bk  ∀k\max_{d\ge0}\ \sum_{s,a}d(s,a)\,r(s,a)\quad\text{s.t.}\quad\sum_ad(s',a)=(1-\gamma)\mu(s')+\gamma\sum_{s,a}P(s'\mid s,a)\,d(s,a)\ \ \forall s',\qquad\sum_{s,a}d(s,a)\,c_k(s,a)\le(1-\gamma)\,b_k\ \ \forall k
The CMDP linear program. dd ranges over normalized discounted occupancy measures dμπ(s,a)=(1−γ)∑tγtPr⁡π(St=s,At=a)d^\pi_\mu(s,a)=(1-\gamma)\sum_t\gamma^t\Pr_\pi(S_t=s,A_t=a), so Jf(π)=11−γ∑s,adμπ(s,a)f(s,a)J_f(\pi)=\frac1{1-\gamma}\sum_{s,a}d^\pi_\mu(s,a)f(s,a). Every policy's occupancy measure satisfies the flow constraints, and every feasible dd is the occupancy measure of the stationary policy πd(a∣s)=d(s,a)/∑a′d(s,a′)\pi_d(a\mid s)=d(s,a)/\sum_{a'}d(s,a') (Occupancy Measures & the Dual View).
DerivationProof of 1 and 2
  1. Jf(π)=Jf(πdμπ)for f∈{r,c1,…,cK} and every policy πJ_f(\pi)=J_f\big(\pi_{d^\pi_\mu}\big)\qquad\text{for }f\in\{r,c_1,\dots,c_K\}\text{ and every policy }\pi

    1. The objective and constraints are linear, and the feasible set is a nonempty polytope, bounded because summing the flow constraints forces ∑s,ad(s,a)=1\sum_{s,a}d(s,a)=1. So an optimum d⋆d^\star exists. Any policy, history-dependent or not, has an occupancy measure satisfying the flow constraints, and the stationary policy built from it has the same occupancy measure, hence the same reward and costs:

  2. #{(s,a):d⋆(s,a)>0} + #{k:σk>0} ≤ ∣S∣+K\#\{(s,a):d^\star(s,a)>0\}\ +\ \#\{k:\sigma_k>0\}\ \le\ \abs{\mathcal S}+K

    2. Turn each cost constraint into an equality with a slack variable σk≥0\sigma_k\ge0. There are now ∣S∣+K\abs{\mathcal S}+K equality constraints, so a basic optimal solution, which exists whenever an optimum does and which the simplex method returns, has at most ∣S∣+K\abs{\mathcal S}+K nonzero variables, slacks included:

  3. ∑s(∣supp⁡πd⋆(⋅∣s)∣−1)=#{d⋆>0}−∣S∣ ≤ K−#{k:σk>0} ≤ K■\sum_s\Big(\abs{\supp\pi_{d^\star}(\cdot\mid s)}-1\Big)=\#\{d^\star>0\}-\abs{\mathcal S}\ \le\ K-\#\{k:\sigma_k>0\}\ \le\ K\qquad\blacksquare

    Assume μ(s)>0\mu(s)>0 for every ss. Then every state has occupancy at least (1−γ)μ(s)>0(1-\gamma)\mu(s)>0, so each uses at least one action. Subtracting one entry per state leaves the extra actions:

  4. With K=0K=0 this is the classical fact that some optimal policy is deterministic. Each binding constraint can cost one randomization; a constraint with slack costs none, since its positive slack uses up one of the ∣S∣+K\abs{\mathcal S}+K places.

Part 3 is why there is no Bellman optimality equation over states alone. The budget is spent wherever the occupancy measure puts weight, so how much cost a state may incur depends on how often it will be visited, which depends on μ\mu. In an unconstrained MDP a greedy policy is optimal from every state at once; in a CMDP the states compete for one shared budget.

One might hope to bypass all this: find the optimal multiplier λ⋆\boldsymbol\lambda^\star, then run value iteration on r−∑kλk⋆ckr-\sum_k\lambda^\star_kc_k. That gives the right value but not the right policy. At λ⋆\boldsymbol\lambda^\star the Lagrangian is typically maximized by several deterministic policies, some infeasible, and the optimum is a particular mixture of them that only the constraints themselves pin down. In the three-route example of Safe & Robust RL, both route A (infeasible) and route B (suboptimal) maximize the Lagrangian at λ⋆=803\lambda^\star=\tfrac{80}3, and only the mixture with A one third of the time is optimal.

Check your understanding

A CMDP has 50 states, 4 actions per state and 2 cost constraints, and μ\mu gives every state positive probability. The simplex method returns a basic optimal solution of its linear program. At most how many states can the induced policy randomize in?

  1. 0: optimal policies can always be taken deterministic
  2. 4
  3. 2
  4. 50
Show the answer

C. 2

A basic solution has at most ∣S∣+K=52\abs{\mathcal S}+K=52 nonzero variables. All 50 states are visited, so each uses at least one action, which leaves at most 2 extra positive entries: two states mixing two actions each, or one state mixing three.

Strong duality without convexity

For finite CMDPs, linear-programming duality already gives P⋆=D⋆P^\star=D^\star. Deep RL works with continuous states and actions and with policies parameterized by networks, where JrJ_r and JckJ_{c_k} are non-concave in the parameters. It is not obvious that the dual, which every Lagrangian method solves, still has the right value.

DerivationProof sketch: the perturbation function is concave
  1. Φ(ξ)=sup⁡π{Jr(π): Jck(π)≤bk+ξk  ∀k}\Phi(\boldsymbol\xi)=\sup_\pi\big\{J_r(\pi):\ J_{c_k}(\pi)\le b_k+\xi_k\ \ \forall k\big\}

    Perturb the budgets by ξ∈RK\boldsymbol\xi\in\R^K and record the optimal value as a function of the perturbation. Φ(0)=P⋆\Phi(\mathbf 0)=P^\star, Φ\Phi is nondecreasing in each ξk\xi_k, and Φ(ξ)=−∞\Phi(\boldsymbol\xi)=-\infty where the perturbed problem is infeasible:

  2. Jf(πθ)=θJf(π1)+(1−θ)Jf(π2) ⟹ Φ(θξ1+(1−θ)ξ2) ≥ θ Φ(ξ1)+(1−θ) Φ(ξ2)J_f(\pi^\theta)=\theta J_f(\pi^1)+(1-\theta)J_f(\pi^2)\ \Longrightarrow\ \Phi\big(\theta\boldsymbol\xi^1+(1-\theta)\boldsymbol\xi^2\big)\ \ge\ \theta\,\Phi(\boldsymbol\xi^1)+(1-\theta)\,\Phi(\boldsymbol\xi^2)

    Concavity. Take near-optimal policies π1,π2\pi^1,\pi^2 for ξ1,ξ2\boldsymbol\xi^1,\boldsymbol\xi^2 and θ∈[0,1]\theta\in[0,1]. Flip one coin with bias θ\theta at the start of the episode and follow π1\pi^1 or π2\pi^2 throughout: this policy's occupancy measure is the mixture, and every JfJ_f is linear in the occupancy measure. (The set of occupancy measures is convex, so a stationary policy achieves the same mixture.)

  3. Φ(ξ) ≤ P⋆+λ⋆⊤ξfor all ξ∈RK\Phi(\boldsymbol\xi)\ \le\ P^\star+\boldsymbol\lambda^{\star\top}\boldsymbol\xi\qquad\text{for all }\boldsymbol\xi\in\R^K

    Supporting hyperplane. Slater's policy is feasible for every slightly negative ξ\boldsymbol\xi, so 0\mathbf 0 is interior to the domain of the concave Φ\Phi, and Φ\Phi has a non-vertical supporting hyperplane at 0\mathbf 0. Its slope λ⋆\boldsymbol\lambda^\star is nonnegative because Φ\Phi is nondecreasing:

  4. P⋆ ≤ D⋆ ≤ max⁡πL(π,λ⋆) ≤ P⋆■P^\star\ \le\ D^\star\ \le\ \max_\pi\mathcal L(\pi,\boldsymbol\lambda^\star)\ \le\ P^\star\qquad\blacksquare

    No gap. Any policy π\pi is feasible for its own perturbation ξk=Jck(π)−bk\xi_k=J_{c_k}(\pi)-b_k, so Jr(π)≤Φ(ξ)≤P⋆+∑kλk⋆(Jck(π)−bk)J_r(\pi)\le\Phi(\boldsymbol\xi)\le P^\star+\sum_k\lambda^\star_k\big(J_{c_k}(\pi)-b_k\big). Rearranged, L(π,λ⋆)≤P⋆\mathcal L(\pi,\boldsymbol\lambda^\star)\le P^\star for every π\pi; with weak duality:

The proof never uses convexity in the policy's parameters. What is convex is the set of achievable occupancy measures, and the objective and constraints are linear on it. Multipliers are also sensitivities: λk⋆\lambda^\star_k is a slope of Φ\Phi at 0\mathbf 0, the marginal value of loosening budget kk.

Paternain et al. extend the result to a parameterization πθ\pi_{\boldsymbol\theta} that is ϵ\epsilon-universal: every policy is matched by some πθ\pi_{\boldsymbol\theta} to within ϵ\epsilon in ℓ1\ell_1 distance at every state. The proof rests on a lemma: policies ϵ\epsilon-close at every state have normalized occupancy measures within ϵ/(1−γ)\epsilon/(1-\gamma) in ℓ1\ell_1. A value is such an integral divided by 1−γ1-\gamma, so values then differ by up to Bϵ/(1−γ)2B\epsilon/(1-\gamma)^2 for rewards bounded by BB. With ∣r∣≤Br\abs r\le B_r and ∣ck∣≤Bc\abs{c_k}\le B_c, the parameterized dual value Dθ⋆D^\star_{\boldsymbol\theta} satisfies

P⋆ ≥ Dθ⋆ ≥ P⋆−(Br+∥λϵ⋆∥1Bc)ϵ(1−γ)2,P^\star\ \ge\ D^\star_{\boldsymbol\theta}\ \ge\ P^\star-\big(B_r+\norm{\boldsymbol\lambda^\star_\epsilon}_1B_c\big)\frac{\epsilon}{(1-\gamma)^2},

where λϵ⋆\boldsymbol\lambda^\star_\epsilon solves the dual of the problem with budgets tightened by Bcϵ/(1−γ)2B_c\epsilon/(1-\gamma)^2. The paper prints ϵ/(1−γ)\epsilon/(1-\gamma) in both places; with values defined as unnormalized discounted sums, one step of its proof appears to drop the factor 1/(1−γ)1/(1-\gamma) that turns a normalized occupancy measure into a value. A two-state check shows the square is needed. If a fatal action that ends all reward is forced with probability ϵ/2\epsilon/2 at every step, the best policy in the class earns 1/(1−0.99×0.995)≈66.91/(1-0.99\times0.995)\approx66.9 instead of 100100 at γ=0.99\gamma=0.99, ϵ=0.01\epsilon=0.01, Br=1B_r=1: a gap of 33, against ϵ/(1−γ)=1\epsilon/(1-\gamma)=1 and ϵ/(1−γ)2=100\epsilon/(1-\gamma)^2=100.

Predict before you look

Rewards and costs lie in [0,1][0,1], γ=0.99\gamma=0.99, the network class matches every policy to within ϵ=10−4\epsilon=10^{-4} in ℓ1\ell_1 at every state, and ∥λϵ⋆∥1=4\norm{\boldsymbol\lambda^\star_\epsilon}_1=4. How far below P⋆P^\star can the parameterized dual value be, according to the bound?

Show the answer

5

(1+4⋅1)⋅10−4/(1−0.99)2=5×10−4/10−4=5(1+4\cdot1)\cdot10^{-4}/(1-0.99)^2=5\times10^{-4}/10^{-4}=5, out of a largest possible return of 1/(1−γ)=1001/(1-\gamma)=100. The gap is linear in ϵ\epsilon, but it is amplified by the square of the effective horizon and by the multipliers: at ϵ=0.01\epsilon=0.01 the same bound is 500, larger than any return, and a tightly binding constraint, with a large λ⋆\lambda^\star, makes small policy-approximation errors expensive.

Primal–dual learning: a game that cycles

Every Lagrangian method alternates a policy step on L\mathcal L with a multiplier step. In occupancy coordinates the Lagrangian is bilinear (dropping the factor 11−γ\frac1{1-\gamma}),

L(d,λ)=⟨d,r⟩−∑kλk(⟨d,ck⟩−(1−γ)bk),\mathcal L(d,\boldsymbol\lambda)=\langle d,r\rangle-\sum_k\lambda_k\big(\langle d,c_k\rangle-(1-\gamma)b_k\big),

so the method is gradient play in a zero-sum game between a policy player choosing dd in the occupancy polytope and a price player choosing λ≥0\boldsymbol\lambda\ge0. Its saddle points are exactly the pairs (d⋆,λ⋆)(d^\star,\boldsymbol\lambda^\star). Bilinear games are the hard case for gradient dynamics (Learning Dynamics in Games).

DerivationSimultaneous gradient steps spiral outward
  1. xt+1=xt+η yt,yt+1=yt−η xtx_{t+1}=x_t+\eta\,y_t,\qquad y_{t+1}=y_t-\eta\,x_t

    The smallest bilinear game: f(x,y)=xyf(x,y)=xy, with xx maximizing and yy minimizing, and its saddle at (0,0)(0,0). Simultaneous gradient steps of size η\eta:

  2. xt+12+yt+12=(1+η2)(xt2+yt2)x_{t+1}^2+y_{t+1}^2=(1+\eta^2)\big(x_t^2+y_t^2\big)

    The update is a rotation scaled by 1+η2\sqrt{1+\eta^2} (eigenvalues 1±iη1\pm i\eta); expanding the squares, the cross terms cancel:

  3. εT=RegT x+RegT yT ⟶ 0\varepsilon_T=\frac{\mathrm{Reg}^{\,x}_T+\mathrm{Reg}^{\,y}_T}{T}\ \longrightarrow\ 0

    The distance to the saddle grows geometrically for every step size, and in continuous time the iterates circle forever. The averages converge anyway: with step sizes shrinking like 1/t1/\sqrt t (or tuned to the horizon TT), projected gradient steps on bounded domains have regret O(T)O(\sqrt T) for each player, and in a zero-sum game the average strategies of two no-regret players form an εT\varepsilon_T-saddle point with

In constrained RL the cycling appears as a cost that swings above and below the budget, with violations during training long after the average has settled. Three remedies are in use.

  • Averaging. Report the mixture of past policies, a randomized policy, which is what a CMDP may need anyway. Natural policy gradient primal–dual methods come with guarantees for the averaged iterates (Ding et al., 2020).
  • Optimism. Correct each step by the change in the gradient, as optimistic mirror descent does. ReLOAD (Moskovitz et al., 2023) proves last-iterate convergence in the convex occupancy formulation and carries the idea to deep RL.
  • Damping. Treat the multiplier as a feedback controller and add proportional and derivative terms (Stooke, Achiam & Abbeel, 2020). A toy model shows why this works.
DerivationA toy model: why a proportional term damps
  1. e˙=−κ (λ−λ⋆),λ˙=kI e,κ,kI>0\dot e=-\kappa\,(\lambda-\lambda^\star),\qquad\dot\lambda=k_I\,e,\qquad\kappa,k_I>0

    Let e(t)=Jc(πt)−be(t)=J_c(\pi_t)-b be the violation, in continuous time. Suppose that near the saddle the learning policy lowers its cost in proportion to how far the price exceeds λ⋆\lambda^\star. The standard multiplier update is pure integral control:

  2. e¨=−κ λ˙=−κkI e⟹e(t)=Acos⁡(κkI t+ϕ)\ddot e=-\kappa\,\dot\lambda=-\kappa k_I\,e\quad\Longrightarrow\quad e(t)=A\cos\big(\sqrt{\kappa k_I}\,t+\phi\big)

    Differentiate the first equation and substitute the second: an undamped oscillator. The violation swings with angular frequency κkI\sqrt{\kappa k_I} and never decays, so the constraint is broken half of the time, forever:

  3. e¨+κkP e˙+κkI e=0,ζ=κkP2κkI=kP2κkI\ddot e+\kappa k_P\,\dot e+\kappa k_I\,e=0,\qquad\zeta=\frac{\kappa k_P}{2\sqrt{\kappa k_I}}=\frac{k_P}{2}\sqrt{\frac{\kappa}{k_I}}

    Add a proportional term, λ=kPe+kI∫e dt\lambda=k_Pe+k_I\int e\,dt. Now λ˙=kPe˙+kIe\dot\lambda=k_P\dot e+k_Ie, and the same substitution gives a damped oscillator with damping ratio ζ\zeta:

  4. For ζ≥1\zeta\ge1 the violation decays without overshoot. The model is a caricature (a real policy responds with delays, its cost is estimated from noisy samples, and the multiplier is clipped at 0), but it explains what is observed: integral-only multipliers overshoot, and a term proportional to the violation reacts before the integral has built up. Stooke et al. also add a derivative term that reacts to how fast the cost is rising.

Predict before you look

In the toy model with κ=1\kappa=1 and kI=1k_I=1, which proportional gain kPk_P gives critical damping, ζ=1\zeta=1?

Show the answer

2

ζ=kP2κ/kI=kP2\zeta=\frac{k_P}{2}\sqrt{\kappa/k_I}=\frac{k_P}{2}, so kP=2k_P=2. The characteristic equation s2+2s+1=(s+1)2s^2+2s+1=(s+1)^2 then has a double root at −1-1: the violation decays like (A+Bt)e−t(A+Bt)e^{-t} without oscillating.

Constrained policy optimization

Averaged or damped Lagrangian methods satisfy the constraint eventually or on average. Constrained policy optimization (CPO; Achiam, Held, Tamar & Abbeel, 2017) aims for every iterate to be approximately feasible. That needs a way to predict a new policy's cost from data collected by the old one, and the tool is the one behind TRPO (TRPO & Monotonic Improvement). Below, dπd^\pi is the normalized discounted state distribution from μ\mu.

DerivationBounding the cost of the next policy
  1. Jc(π′)−Jc(π)=11−γ Es∼dπ′, a∼π′(⋅∣s)[Acπ(s,a)]J_c(\pi')-J_c(\pi)=\frac1{1-\gamma}\,\E_{s\sim d^{\pi'},\,a\sim\pi'(\cdot\mid s)}\big[A^\pi_c(s,a)\big]

    The performance-difference lemma for the cost, with AcπA^\pi_c the old policy's cost advantage:

  2. ∥dπ′−dπ∥1 ≤ 2γ1−γ Es∼dπ[DTV(π′ ∥ π)[s]]\norm{d^{\pi'}-d^\pi}_1\ \le\ \frac{2\gamma}{1-\gamma}\,\E_{s\sim d^\pi}\big[D_{\mathrm{TV}}(\pi'\,\|\,\pi)[s]\big]

    The expectation is over the unknown dπ′d^{\pi'}. Swap in dπd^\pi and pay for the swap: with ϵc=max⁡s∣Ea∼π′Acπ(s,a)∣\epsilon_c=\max_s\abs{\E_{a\sim\pi'}A^\pi_c(s,a)} the error is at most ϵc∥dπ′−dπ∥1\epsilon_c\norm{d^{\pi'}-d^\pi}_1, and state distributions move at most in proportion to the per-state policy change (Achiam et al., 2017, Lemma 3):

  3. Jc(π′) ≤ Jc(π)+11−γ Es∼dπ, a∼π′[Acπ(s,a)+2γ ϵc1−γ DTV(π′ ∥ π)[s]]J_c(\pi')\ \le\ J_c(\pi)+\frac1{1-\gamma}\,\E_{s\sim d^\pi,\,a\sim\pi'}\Big[A^\pi_c(s,a)+\frac{2\gamma\,\epsilon_c}{1-\gamma}\,D_{\mathrm{TV}}(\pi'\,\|\,\pi)[s]\Big]

    Together they bound the new cost by quantities estimable from the old policy's data, plus a penalty for moving:

  4. πk+1=arg max⁡π Es∼dπk, a∼π[Arπk(s,a)]  s.t.  Jc(πk)+Es∼dπk, a∼π[Acπk(s,a)]1−γ≤b,DˉKL(π ∥ πk)≤δ\pi_{k+1}=\argmax_\pi\ \E_{s\sim d^{\pi_k},\,a\sim\pi}\big[A^{\pi_k}_r(s,a)\big]\ \ \text{s.t.}\ \ J_c(\pi_k)+\frac{\E_{s\sim d^{\pi_k},\,a\sim\pi}\big[A^{\pi_k}_c(s,a)\big]}{1-\gamma}\le b,\quad\bar D_{\mathrm{KL}}(\pi\,\|\,\pi_k)\le\delta

    Pinsker's inequality DTV≤DKL/2D_{\mathrm{TV}}\le\sqrt{D_{\mathrm{KL}}/2} and Jensen's inequality trade the TV penalty for a KL trust region. CPO maximizes the reward surrogate subject to the cost surrogate and the trust region:

  5. Jc(πk+1) ≤ b+2δ γ ϵc(1−γ)2J_c(\pi_{k+1})\ \le\ b+\frac{\sqrt{2\delta}\,\gamma\,\epsilon_c}{(1-\gamma)^2}

    If the update is solved exactly, the surrogate constraint holds, and the penalty term, with Edπk[DTV]≤δ/2\E_{d^{\pi_k}}[D_{\mathrm{TV}}]\le\sqrt{\delta/2}, bounds the violation (Achiam et al., 2017, Proposition 2):

Predict before you look

With δ=0.01\delta=0.01, γ=0.99\gamma=0.99 and ϵc=0.01\epsilon_c=0.01, how large is CPO's worst-case constraint violation 2δ γ ϵc/(1−γ)2\sqrt{2\delta}\,\gamma\,\epsilon_c/(1-\gamma)^2?

Show the answer

14

0.02≈0.1414\sqrt{0.02}\approx0.1414, times 0.99×0.010.99\times0.01, divided by 10−410^{-4}: about 14.0, in units of discounted cost, where costs in [0,1][0,1] allow at most 100. The (1−γ)−2(1-\gamma)^{-2} makes the worst case loose at long horizons; the bound explains the shape of the update, not the size of the violations seen in practice.

In practice CPO linearizes both surrogates around πk\pi_k and replaces the KL by its quadratic approximation (the Fisher matrix). What remains is a convex problem with one linear and one quadratic constraint, whose two-variable dual is solved in closed form. If πk\pi_k is infeasible, CPO instead takes a recovery step that only decreases the cost within the trust region. With sampled advantages and these approximations the guarantee is approximate, and violations during training still occur; on Safety Gym (Ray, Achiam & Amodei, 2019), Lagrangian versions of PPO and TRPO were the baselines beside CPO.

Key takeaways

  • A finite CMDP is a linear program over occupancy measures: stationary policies suffice, and some optimal policy mixes in at most KK extra actions, but the optimum depends on μ\mu and no Bellman equation over states characterizes it.
  • Under Slater's condition there is no duality gap even for non-convex policy classes, because the set of occupancy measures is convex; multipliers are sensitivities to the budgets, and a parameterization costs at most (Br+∥λϵ⋆∥1Bc) ϵ/(1−γ)2(B_r+\norm{\boldsymbol\lambda^\star_\epsilon}_1B_c)\,\epsilon/(1-\gamma)^2 (the paper prints ϵ/(1−γ)\epsilon/(1-\gamma)).
  • Knowing λ⋆\boldsymbol\lambda^\star gives the optimal value, not the optimal policy, which is a particular mixture of Lagrangian maximizers.
  • Primal–dual learning is gradient play on a bilinear game: its last iterate cycles while averages converge; averaging, optimism, PID damping and regularization are the remedies.
  • CPO bounds the next policy's cost from current data through the performance-difference lemma and a TV trust region; an exact update violates the budget by at most 2δ γϵc/(1−γ)2\sqrt{2\delta}\,\gamma\epsilon_c/(1-\gamma)^2.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

The zero-duality-gap theorem applies to CMDPs with network policies whose returns are non-concave in the parameters. Which property does its proof rest on?

  1. Concavity of JrJ_r in the policy parameters
  2. Convexity of the set of achievable occupancy measures, on which reward and costs are linear
  3. Finiteness of the state and action spaces
  4. The existence of a deterministic optimal policy
Show the answer

B. Convexity of the set of achievable occupancy measures, on which reward and costs are linear

Mixing two policies' occupancy measures is achievable and mixes their rewards and costs linearly, so the perturbation function is concave; Slater's condition then gives a supporting hyperplane, whose slope is λ⋆\boldsymbol\lambda^\star. The parameterization enters only through a separate approximation error.

Question 2

You know the optimal multiplier λ⋆\lambda^\star of a one-constraint CMDP exactly. Is every policy that maximizes the return for the reward r−λ⋆cr-\lambda^\star c optimal for the CMDP?

  1. Yes: λ⋆\lambda^\star encodes everything about the constraint
  2. Yes, provided the policy is deterministic
  3. No: λ⋆\lambda^\star is only an upper bound on the optimal value
  4. No: the maximizers at λ⋆\lambda^\star can include infeasible policies, and the optimum is a specific mixture of them
Show the answer

D. No: the maximizers at λ⋆\lambda^\star can include infeasible policies, and the optimum is a specific mixture of them

At λ⋆\lambda^\star the Lagrangian is typically maximized by several policies with different costs. They all have the same Lagrangian value P⋆P^\star, but only a mixture whose cost meets the budget with complementary slackness is optimal. In the three-route example, routes A and B both maximize it, and only one third A, two thirds B is optimal.

Question 3

In Lagrangian PPO, the cost swings above and below the budget for thousands of iterations, while the average of the policy iterates is nearly feasible and optimal. What explains this?

  1. The step sizes are too small; larger steps would stop the oscillation
  2. Simultaneous gradient play on a bilinear saddle problem cycles in its last iterate while the averages of no-regret iterates converge
  3. The duality gap must be positive
  4. The constraint is infeasible
Show the answer

B. Simultaneous gradient play on a bilinear saddle problem cycles in its last iterate while the averages of no-regret iterates converge

The Lagrangian is bilinear in occupancy coordinates, and simultaneous gradient steps rotate around the saddle, spiraling out by 1+η2\sqrt{1+\eta^2} per step in the simplest case. Averages converge at the rate set by the players' regret. Optimism, damping and regularization target the last iterate.

Question 4

In CPO's worst-case violation 2δ γ ϵc/(1−γ)2\sqrt{2\delta}\,\gamma\,\epsilon_c/(1-\gamma)^2, what happens to the bound if the trust-region radius δ\delta is quadrupled, all else equal?

  1. It doubles
  2. It quadruples
  3. It is unchanged
  4. It halves
Show the answer

A. It doubles

The bound grows like δ\sqrt\delta, because Pinsker's inequality turns a KL radius into a TV radius by a square root. The horizon enters far more strongly: from γ=0.99\gamma=0.99 to 0.9990.999 the factor (1−γ)−2(1-\gamma)^{-2} grows a hundredfold.

Further reading

  • E. Altman, Constrained Markov Decision Processes (Chapman & Hall/CRC, 1999).
  • S. Paternain, L. Chamon, M. Calvo-Fullana & A. Ribeiro, "Constrained reinforcement learning has zero duality gap," NeurIPS (2019).
  • J. Achiam, D. Held, A. Tamar & P. Abbeel, "Constrained policy optimization," ICML (2017).
  • A. Stooke, J. Achiam & P. Abbeel, "Responsive safety in reinforcement learning by PID Lagrangian methods," ICML (2020).
  • T. Moskovitz, B. O'Donoghue, V. Veeriah, S. Flennerhag, S. Singh & T. Zahavy, "ReLOAD: Reinforcement learning with optimistic ascent-descent for last-iterate convergence in constrained MDPs," ICML (2023).