Simple Algorithm
Reinforcement Learning · Fixed Point · 28 min

Advantages & the Performance Difference Lemma

An exact formula for how much better one policy is than another.

How much better is one policy than another? The performance difference lemma answers exactly: average the old policy's advantages over the states the new policy visits. That one identity proves the policy improvement theorem, prices the regret of any policy, and explains why policy iteration, conservative policy iteration, TRPO and the natural policy gradient work. It also names their central difficulty: the states that matter belong to a policy you have not run yet.

What you’ll learn

  • State and use the properties of the advantage function: zero mean under its policy, equality with the expected TD error, invariance under potential-based shaping, and nonpositivity at the optimum.
  • Prove the performance difference lemma by telescoping and in matrix form, and verify it on a two-state MDP.
  • Derive the policy improvement theorem, an optimality criterion and a regret decomposition as corollaries.
  • Bound the distribution mismatch ∥dμπ′−dμπ∥1\norm{d^{\pi'}_\mu - d^\pi_\mu}_1 and derive the improvement guarantee behind conservative policy iteration and TRPO.
  • Explain the tabular natural policy gradient as soft policy iteration and prove that it improves monotonically.

The advantage function

The advantage Aπ(s,a)=Qπ(s,a)−Vπ(s)A^\pi(s,a) = Q^\pi(s,a) - V^\pi(s) measures a single deviation: take aa now, then return to π\pi. Throughout, J(π)=ES0∼μ[Vπ(S0)]J(\pi) = \E_{S_0\sim\mu}\big[V^\pi(S_0)\big] and dμπ(s,a)=(1−γ)∑tγtPr⁡μπ(St=s,At=a)d^\pi_\mu(s,a) = (1-\gamma)\sum_t\gamma^t\Pr^\pi_\mu(S_t = s, A_t = a) is the normalized discounted occupancy measure of Occupancy Measures & the Dual View, with state marginal dμπ(s)d^\pi_\mu(s).

PairAπA^\pi for π\pi = (stay, stay)A⋆A^\star, optimal policy (go, stay)
(s1,stay)(s_1, \text{stay})00−0.8-0.8
(s1,go)(s_1, \text{go})+8+800
(s2,stay)(s_2, \text{stay})0000
(s2,go)(s_2, \text{go})−11-11−3.8-3.8
Advantages in the two-state MDP of the value-space widget (γ=0.9\gamma = 0.9; in s1s_1, stay pays 1 and go pays 0 and moves to s2s_2; in s2s_2, stay pays 2 and go pays 0 and moves back). Under (stay, stay) one action has a positive advantage, so the policy can be improved. Under the optimal policy every advantage is at most 0, and the zeros mark the optimal actions.
Check your understanding

In state ss a policy plays a1a_1, a2a_2 and a3a_3 with probabilities 0.5, 0.25 and 0.25. You know Aπ(s,a1)=2A^\pi(s,a_1) = 2 and Aπ(s,a2)=−2A^\pi(s,a_2) = -2. What is Aπ(s,a3)A^\pi(s,a_3)?

  1. 22
  2. 00
  3. −2-2
  4. It cannot be determined without QπQ^\pi
Show the answer

C. −2-2

The advantages average to zero under the policy: 0.5⋅2+0.25⋅(−2)+0.25 x=00.5 \cdot 2 + 0.25 \cdot (-2) + 0.25\,x = 0 gives x=−2x = -2. Both a2a_2 and a3a_3 are worse than the policy's average, and a1a_1 makes up for them.

The performance difference lemma

DerivationProof by telescoping
  1. J(π′)−J(π)=Eμπ′[∑t≥0γtRt+1]−Eμ[Vπ(S0)]=Eμπ′[∑t≥0γt(Rt+1+γVπ(St+1)−Vπ(St))]J(\pi') - J(\pi) = \E^{\pi'}_\mu\Big[\sum_{t\ge0}\gamma^t R_{t+1}\Big] - \E_\mu\big[V^\pi(S_0)\big] = \E^{\pi'}_\mu\Big[\sum_{t\ge0}\gamma^t\big(R_{t+1} + \gamma V^\pi(S_{t+1}) - V^\pi(S_t)\big)\Big]

    Run π′\pi' from S0∼μS_0 \sim \mu. Since VπV^\pi is bounded and γ<1\gamma < 1, the sum ∑t≥0(γt+1Vπ(St+1)−γtVπ(St))\sum_{t\ge0}\big(\gamma^{t+1}V^\pi(S_{t+1}) - \gamma^t V^\pi(S_t)\big) telescopes to −Vπ(S0)-V^\pi(S_0). Add it inside the expected return of π′\pi':

  2. Eπ′[Rt+1+γVπ(St+1)−Vπ(St) ∣ St=s,At=a]=r(s,a)+γ∑s′P(s′∣s,a) Vπ(s′)−Vπ(s)=Aπ(s,a)\E^{\pi'}\big[R_{t+1} + \gamma V^\pi(S_{t+1}) - V^\pi(S_t) \,\big|\, S_t = s, A_t = a\big] = r(s,a) + \gamma\sum_{s'}P(s' \mid s,a)\,V^\pi(s') - V^\pi(s) = A^\pi(s,a)

    Each bracket is a TD error of the old value function on a transition of the new policy. Conditioned on (St,At)(S_t, A_t), the Markov property makes its expectation an advantage of the old policy, whichever policy chose AtA_t:

  3. J(π′)−J(π)=∑t≥0γt Eμπ′[Aπ(St,At)]=11−γ∑s,adμπ′(s,a) Aπ(s,a)J(\pi') - J(\pi) = \sum_{t\ge0}\gamma^t\,\E^{\pi'}_\mu\big[A^\pi(S_t, A_t)\big] = \frac{1}{1-\gamma}\sum_{s,a}d^{\pi'}_\mu(s,a)\,A^\pi(s,a)

    Sum over time with weights γt\gamma^t (bounded rewards justify exchanging sum and expectation) and regroup by state–action pair, as in the definition of the occupancy measure. ■\blacksquare

For stationary policies there is a second proof, in one line of linear algebra, that gives the improvement in every state at once. Let Aˉ(s)=∑aπ′(a∣s) Aπ(s,a)\bar A(s) = \sum_a\pi'(a \mid s)\,A^\pi(s,a), which equals (Tπ′Vπ−Vπ)(s)(\mathcal T^{\pi'}V^\pi - V^\pi)(s), the one-step gain from following π′\pi' for a single step:

Vπ′−Vπ=(I−γPπ′)−1(rπ′+γPπ′Vπ−Vπ)=(I−γPπ′)−1 AˉV^{\pi'} - V^\pi = (I - \gamma P^{\pi'})^{-1}\big(r^{\pi'} + \gamma P^{\pi'}V^\pi - V^\pi\big) = (I - \gamma P^{\pi'})^{-1}\,\bar A
Check: (I−γPπ′)−1rπ′=Vπ′(I - \gamma P^{\pi'})^{-1}r^{\pi'} = V^{\pi'} and (I−γPπ′)−1(γPπ′−I)Vπ=−Vπ(I - \gamma P^{\pi'})^{-1}(\gamma P^{\pi'} - I)V^\pi = -V^\pi. The matrix (I−γPπ′)−1(I - \gamma P^{\pi'})^{-1} is the new policy's successor representation (Successor Representations & Features). Multiplying by μ⊤\mu^\top turns it into dμπ′/(1−γ)d^{\pi'}_\mu/(1-\gamma) and gives back the lemma.

Corollaries: improvement, optimality, regret

DerivationProof
  1. Vπ′−Vπ=MAˉ  ≥  Aˉ  ≥  0V^{\pi'} - V^\pi = M\bar A \;\ge\; \bar A \;\ge\; 0

    The successor matrix M=(I−γPπ′)−1=∑tγt(Pπ′)tM = (I - \gamma P^{\pi'})^{-1} = \sum_t\gamma^t(P^{\pi'})^t has nonnegative entries and satisfies M=I+γPπ′M≥IM = I + \gamma P^{\pi'}M \ge I entrywise. With Aˉ≥0\bar A \ge 0:

  2. Optimality. If no advantage is positive, every stationary π′\pi' has Aˉ≤0\bar A \le 0, so Vπ′=Vπ+MAˉ≤VπV^{\pi'} = V^\pi + M\bar A \le V^\pi; by the telescoping form, every history-dependent policy is no better either. Conversely, if Aπ(s,a)>0A^\pi(s,a) > 0, switching to aa in ss alone gives Aˉ≥0\bar A \ge 0 with Aˉ(s)>0\bar A(s) > 0, and the first part makes ss strictly better. ■\blacksquare

The criterion is the Bellman optimality equation in disguise: Aπ≤0A^\pi \le 0 everywhere means max⁡aQπ(s,a)=Vπ(s)\max_a Q^\pi(s,a) = V^\pi(s), that is T⋆Vπ=Vπ\mathcal T^\star V^\pi = V^\pi. Swapping the roles of the two policies in the lemma gives the regret of any policy against an optimal one:

J(π⋆)−J(π)=11−γ E(s,a)∼dμπ[−A⋆(s,a)].J(\pi^\star) - J(\pi) = \frac{1}{1-\gamma}\,\E_{(s,a)\sim d^\pi_\mu}\big[-A^\star(s,a)\big].

Now the occupancy is that of the policy being judged, and A⋆A^\star is fixed once and for all. The regret is the discounted sum of the action gaps that π\pi pays along its own trajectories: a wrong action in a state the policy never visits costs nothing, and a small gap paid in a frequently visited state can cost more than a large one paid once.

Predict before you look

Apply the regret decomposition to π\pi = (stay, go) started in s2s_2. Its occupancy puts 0.10.1 on (s2,go)(s_2, \text{go}) and 0.90.9 on (s1,stay)(s_1, \text{stay}), and the action gaps are −A⋆(s2,go)=3.8-A^\star(s_2, \text{go}) = 3.8 and −A⋆(s1,stay)=0.8-A^\star(s_1, \text{stay}) = 0.8. What is V⋆(s2)−Vπ(s2)V^\star(s_2) - V^\pi(s_2)?

Show the answer

11

10×(0.1⋅3.8+0.9⋅0.8)=10×1.1=1110 \times (0.1 \cdot 3.8 + 0.9 \cdot 0.8) = 10 \times 1.1 = 11, which matches V⋆(s2)−Vπ(s2)=20−9V^\star(s_2) - V^\pi(s_2) = 20 - 9. Most of the regret comes from the small gap 0.8, paid at every step in s1s_1, not from the large gap 3.8, paid once.

Differentiating the lemma gives the policy gradient theorem. Put π′=πθ′\pi' = \pi_{\boldsymbol\theta'} and differentiate at θ′=θ\boldsymbol\theta' = \boldsymbol\theta. By the product rule there are two terms. The one in which the occupancy dμπθ′d^{\pi_{\boldsymbol\theta'}}_\mu is differentiated is weighted by ∑aπθ(a∣s)Aπθ(s,a)\sum_a\pi_{\boldsymbol\theta}(a \mid s)A^{\pi_{\boldsymbol\theta}}(s,a), which is zero in every state, so only the other survives: ∇J(θ)=11−γEs∼dμπθ[∑a∇πθ(a∣s) Aπθ(s,a)]\nabla J(\boldsymbol\theta) = \frac{1}{1-\gamma}\E_{s\sim d^{\pi_{\boldsymbol\theta}}_\mu}\big[\sum_a\nabla\pi_{\boldsymbol\theta}(a \mid s)\,A^{\pi_{\boldsymbol\theta}}(s,a)\big] (The Policy Gradient Theorem & REINFORCE). The state distribution changes with θ\boldsymbol\theta, but to first order that change does not matter.

Whose states? Distribution mismatch

To choose π′\pi', the lemma needs dμπ′d^{\pi'}_\mu, which is unknown until π′\pi' has been run. Policy-improvement methods replace it by the current policy's distribution, which the data already collected can sample:

Lπ(π′)=J(π)+11−γ Es∼dμπ, a∼π′(⋅∣s)[Aπ(s,a)],L_\pi(\pi') = J(\pi) + \frac{1}{1-\gamma}\,\E_{s\sim d^\pi_\mu,\ a\sim\pi'(\cdot \mid s)}\big[A^\pi(s,a)\big],

the surrogate objective, estimated from π\pi's samples by reweighting actions with π′(a∣s)/π(a∣s)\pi'(a \mid s)/\pi(a \mid s). It equals JJ at π′=π\pi' = \pi and has the same gradient there (Kakade & Langford, 2002), so it is right to first order. Far from π\pi it can be badly wrong.

On the two-state MDP from s1s_1, π\pi = (stay, stay) never leaves s1s_1, so dπd^\pi is a point mass there and the surrogate credits a switch to go with its advantage 8 at every step: it predicts a gain of 10×8=8010 \times 8 = 80. The true gain is 8, because after one go the new policy sits in s2s_2, where there is nothing more to gain. The mixtures πα\pi_\alpha that go with probability α\alpha in s1s_1 show the transition from right to wrong.

α\alphaTrue gainSurrogate: 80α80\alphaGuarantee: 80α−1440α280\alpha - 1440\alpha^2
0.010.010.730.730.800.800.660.66
1/36≈0.0281/36 \approx 0.0281.781.782.222.221.111.11 (largest)
0.10.14.214.2188−6.4-6.4
0.50.57.277.274040−320-320
11888080−1360-1360
True gains from Vπα(s1)=(1+17α)/(0.1+0.9α)V^{\pi_\alpha}(s_1) = (1 + 17\alpha)/(0.1 + 0.9\alpha), whose slope at α=0\alpha = 0 is 80, as the surrogate's is. The surrogate then overshoots without limit. The guarantee, derived next, is valid for every α\alpha and useful only for small steps.
DerivationHow far can the state distribution move?
  1. dμπ′⊤−dμπ⊤=γ dμπ⊤(Pπ′−Pπ) Gˉd^{\pi'\top}_\mu - d^{\pi\top}_\mu = \gamma\,d^{\pi\top}_\mu\big(P^{\pi'} - P^\pi\big)\,\bar G

    Let G=(I−γPπ)−1G = (I - \gamma P^\pi)^{-1} and Gˉ=(I−γPπ′)−1\bar G = (I - \gamma P^{\pi'})^{-1}, so that dμπ⊤=(1−γ)μ⊤Gd^{\pi\top}_\mu = (1-\gamma)\mu^\top G. The resolvent identity Gˉ−G=γ G(Pπ′−Pπ)Gˉ\bar G - G = \gamma\,G(P^{\pi'} - P^\pi)\bar G writes the new distribution as the old one plus a correction driven by the change in transitions:

  2. ∥dμπ′−dμπ∥1≤2γ1−γ Es∼dμπ[DTV(s)],DTV(s)=12∑a∣π′(a∣s)−π(a∣s)∣\norm{d^{\pi'}_\mu - d^\pi_\mu}_1 \le \frac{2\gamma}{1-\gamma}\,\E_{s\sim d^\pi_\mu}\big[D_{TV}(s)\big],\qquad D_{TV}(s) = \tfrac12\sum_a\abs{\pi'(a \mid s) - \pi(a \mid s)}

    The rows of Gˉ≥0\bar G \ge 0 sum to 1/(1−γ)1/(1-\gamma), so multiplying a row vector by Gˉ\bar G multiplies its ℓ1\ell_1 norm by at most that. And dμπ⊤(Pπ′−Pπ)d^{\pi\top}_\mu(P^{\pi'} - P^\pi) has ℓ1\ell_1 norm at most ∑sdμπ(s)∑a∣π′(a∣s)−π(a∣s)∣\sum_s d^\pi_\mu(s)\sum_a\abs{\pi'(a \mid s) - \pi(a \mid s)}. This is Lemma 3 of Achiam, Held, Tamar and Abbeel (2017):

  3. J(π′)−J(π)≥11−γ(Es∼dμπ[Aˉ(s)]−2γϵ1−γ Es∼dμπ[DTV(s)])J(\pi') - J(\pi) \ge \frac{1}{1-\gamma}\Big(\E_{s\sim d^\pi_\mu}\big[\bar A(s)\big] - \frac{2\gamma\epsilon}{1-\gamma}\,\E_{s\sim d^\pi_\mu}\big[D_{TV}(s)\big]\Big)

    Replace dπ′d^{\pi'} by dπd^\pi in the lemma and pay for it. With Aˉ(s)=Ea∼π′[Aπ(s,a)]\bar A(s) = \E_{a\sim\pi'}\big[A^\pi(s,a)\big] and ϵ=max⁡s∣Aˉ(s)∣\epsilon = \max_s\abs{\bar A(s)}, the error is at most ∥dμπ′−dμπ∥1 ϵ/(1−γ)\norm{d^{\pi'}_\mu - d^\pi_\mu}_1\,\epsilon/(1-\gamma), which gives their Corollary 1. ■\blacksquare

For the mixtures, Aˉ(s1)=8α\bar A(s_1) = 8\alpha, ϵ=8α\epsilon = 8\alpha and DTV(s1)=αD_{TV}(s_1) = \alpha, so the guarantee is 10(8α−144α2)=80α−1440α210(8\alpha - 144\alpha^2) = 80\alpha - 1440\alpha^2: it peaks at α=1/36\alpha = 1/36 with a promise of 1.11, where the true gain is 1.78. This is the logic of conservative policy iteration (Kakade & Langford, 2002), which mixes an improved policy into the current one with a weight α\alpha chosen to maximize such a bound. Schulman et al. (2015) extended it to general stochastic policies: with ϵ=max⁡s,a∣Aπ(s,a)∣\epsilon = \max_{s,a}\abs{A^\pi(s,a)} and the largest total variation α=max⁡sDTV(s)\alpha = \max_s D_{TV}(s), J(π′)≥Lπ(π′)−4ϵγ(1−γ)2α2J(\pi') \ge L_\pi(\pi') - \frac{4\epsilon\gamma}{(1-\gamma)^2}\alpha^2, and since DTV2≤DKLD_{TV}^2 \le \KL, a penalty on the largest KL divergence works too. On the example (ϵ=11\epsilon = 11) that bound promises at most 0.40, at α≈0.010\alpha \approx 0.010, where the true gain is 0.74. Bounds this conservative are not run as they stand: TRPO keeps their shape, maximizing the surrogate while staying close to π\pi, but swaps the penalty for a hard limit on the KL divergence averaged over visited states, and PPO by clipping the probability ratio (Trust Regions: TRPO & PPO).

Check your understanding

Why do surrogate objectives such as Lπ(π′)L_\pi(\pi') use the old policy's state distribution dμπd^\pi_\mu instead of the new policy's?

  1. Because the two distributions are always equal
  2. Because the lemma becomes false with dμπ′d^{\pi'}_\mu
  3. Because the old policy's states are the more important ones
  4. Because dμπd^\pi_\mu can be sampled from data already collected, while dμπ′d^{\pi'}_\mu is unknown until π′\pi' runs; the price is an error that grows with how far π′\pi' moves from π\pi
Show the answer

D. Because dμπd^\pi_\mu can be sampled from data already collected, while dμπ′d^{\pi'}_\mu is unknown until π′\pi' runs; the price is an error that grows with how far π′\pi' moves from π\pi

The exact identity needs the new occupancy. The surrogate trades exactness for computability, and the mismatch lemma bounds the error by 2γϵ(1−γ)2Edπ[DTV]\frac{2\gamma\epsilon}{(1-\gamma)^2}\E_{d^\pi}[D_{TV}], which is why every practical method limits the size of the policy change.

Soft policy iteration: the natural policy gradient

Policy iteration takes the boldest step the advantages allow: jump to the greedy policy. The natural policy gradient takes a soft version of the same step. For a tabular softmax policy πθ(a∣s)∝eθs,a\pi_{\boldsymbol\theta}(a \mid s) \propto e^{\theta_{s,a}}, Kakade's natural gradient with step size η\eta adds scaled advantages to the logits, so the policy is reweighted multiplicatively (Agarwal, Kakade, Lee & Mahajan, 2021):

πt+1(a∣s)=πt(a∣s) exp⁡(ηAπt(s,a)/(1−γ))Zt(s).\pi_{t+1}(a \mid s) = \frac{\pi_t(a \mid s)\,\exp\big(\eta A^{\pi_t}(s,a)/(1-\gamma)\big)}{Z_t(s)}.

As η→∞\eta \to \infty this becomes policy iteration's greedy step; for finite η\eta it is soft policy iteration, the multiplicative-weights update of online learning run in every state. The Fisher matrix cancels the state distribution: the update does not depend on dμπtd^{\pi_t}_\mu.

DerivationEvery step improves, by the lemma
  1. ∑aπt+1(a∣s) Aπt(s,a)=1−γη(Dt(s)+log⁡Zt(s)),Dt(s)=DKL(πt+1(⋅∣s) ∥ πt(⋅∣s))\sum_a \pi_{t+1}(a \mid s)\,A^{\pi_t}(s,a) = \frac{1-\gamma}{\eta}\Big(D_t(s) + \log Z_t(s)\Big),\qquad D_t(s) = \KL\big(\pi_{t+1}(\cdot \mid s)\,\big\|\,\pi_t(\cdot \mid s)\big)

    Take logarithms of the update: ηAπt(s,a)/(1−γ)=log⁡πt+1(a∣s)πt(a∣s)+log⁡Zt(s)\eta A^{\pi_t}(s,a)/(1-\gamma) = \log\frac{\pi_{t+1}(a \mid s)}{\pi_t(a \mid s)} + \log Z_t(s). Average over a∼πt+1(⋅∣s)a \sim \pi_{t+1}(\cdot \mid s), and write Dt(s)D_t(s) for the KL divergence from πt(⋅∣s)\pi_t(\cdot \mid s) to πt+1(⋅∣s)\pi_{t+1}(\cdot \mid s):

  2. J(πt+1)−J(πt)=1η Es∼dμπt+1[Dt(s)+log⁡Zt(s)]  ≥  1−γη Es∼μ[log⁡Zt(s)]  ≥  0J(\pi_{t+1}) - J(\pi_t) = \frac{1}{\eta}\,\E_{s\sim d^{\pi_{t+1}}_\mu}\Big[D_t(s) + \log Z_t(s)\Big] \;\ge\; \frac{1-\gamma}{\eta}\,\E_{s\sim\mu}\big[\log Z_t(s)\big] \;\ge\; 0

    By Jensen's inequality and Ea∼πt[Aπt(s,a)]=0\E_{a\sim\pi_t}\big[A^{\pi_t}(s,a)\big] = 0, log⁡Zt(s)≥Ea∼πt[ηAπt(s,a)/(1−γ)]=0\log Z_t(s) \ge \E_{a\sim\pi_t}\big[\eta A^{\pi_t}(s,a)/(1-\gamma)\big] = 0. The lemma, and dμπt+1(s)≥(1−γ)μ(s)d^{\pi_{t+1}}_\mu(s) \ge (1-\gamma)\mu(s), then give improvement from every start distribution (their Lemma 5.2). ■\blacksquare

Key takeaways

  • Advantages average to zero under their policy, equal expected TD errors, are unchanged by potential-based shaping, and are never positive under an optimal policy.
  • Performance difference lemma: J(π′)−J(π)=11−γEdμπ′[Aπ]J(\pi') - J(\pi) = \frac{1}{1-\gamma}\E_{d^{\pi'}_\mu}[A^\pi], the old policy's advantages averaged over the new policy's occupancy; in matrix form Vπ′−Vπ=(I−γPπ′)−1AˉV^{\pi'} - V^\pi = (I - \gamma P^{\pi'})^{-1}\bar A.
  • Corollaries: greedy steps never hurt any state, a policy is optimal exactly when no advantage is positive, and a policy's regret is the discounted sum of the action gaps it pays on its own trajectories.
  • The new occupancy is unknown, so methods optimize a surrogate on the old policy's states. Its error is controlled by ∥dμπ′−dμπ∥1≤2γ1−γEdμπ[DTV]\norm{d^{\pi'}_\mu - d^\pi_\mu}_1 \le \frac{2\gamma}{1-\gamma}\E_{d^\pi_\mu}[D_{TV}], the root of conservative policy iteration, TRPO and PPO.
  • The tabular natural policy gradient is soft policy iteration, πt+1∝πt eηAπt/(1−γ)\pi_{t+1} \propto \pi_t\,e^{\eta A^{\pi_t}/(1-\gamma)}: it improves monotonically by the lemma and is ε\varepsilon-optimal after O(1/((1−γ)2ε))O\big(1/((1-\gamma)^2\varepsilon)\big) iterations.

Check yourself

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

Question 1

You add a potential-based shaping reward γΦ(s′)−Φ(s)\gamma\Phi(s') - \Phi(s) to every transition of a continuing task. What happens to the advantage function AπA^\pi of each policy?

  1. It shifts by −Φ(s)-\Phi(s)
  2. It is unchanged
  3. It shifts by γΦ(s′)−Φ(s)\gamma\Phi(s') - \Phi(s)
  4. It is scaled by γ\gamma
Show the answer

B. It is unchanged

The shaping terms telescope along every trajectory, so every return from S0=sS_0 = s shifts by −Φ(s)-\Phi(s), whatever the first action. Qπ(s,a)Q^\pi(s,a) and Vπ(s)V^\pi(s) both shift by −Φ(s)-\Phi(s), and their difference is untouched. This is one way to see why potential-based shaping cannot change which actions are better.

Question 2

A policy π′\pi' picks, in every state, an action whose advantage under π\pi is nonnegative, and in state s0s_0 an action with Aπ(s0,a)=2A^\pi(s_0, a) = 2. What is the smallest possible value of Vπ′(s0)−Vπ(s0)V^{\pi'}(s_0) - V^\pi(s_0)?

  1. 00
  2. 2γ2\gamma
  3. 2/(1−γ)2/(1-\gamma)
  4. 22
Show the answer

D. 22

Vπ′−Vπ=MAˉV^{\pi'} - V^\pi = M\bar A with M=(I−γPπ′)−1=I+γPπ′M≥IM = (I - \gamma P^{\pi'})^{-1} = I + \gamma P^{\pi'}M \ge I entrywise and Aˉ≥0\bar A \ge 0, so the gain at s0s_0 is at least Aˉ(s0)=2\bar A(s_0) = 2. It equals 2 when π′\pi' never returns to s0s_0 and gains nothing elsewhere; it reaches 2/(1−γ)2/(1-\gamma) only if π′\pi' collects that advantage at every step.

Question 3

A colleague estimates J(π′)−J(π)J(\pi') - J(\pi) by averaging Aπ′A^{\pi'}, the new policy's advantages, over states and actions drawn from the old policy π\pi. What does the lemma say this estimates?

  1. J(π′)−J(π)J(\pi') - J(\pi), the same quantity, by symmetry
  2. J(π)−J(π′)J(\pi) - J(\pi'), after multiplying by 11−γ\frac{1}{1-\gamma}: the lemma with the roles of the two policies exchanged
  3. Zero, because advantages average to zero
  4. Nothing meaningful
Show the answer

B. J(π)−J(π′)J(\pi) - J(\pi'), after multiplying by 11−γ\frac{1}{1-\gamma}: the lemma with the roles of the two policies exchanged

Exchanging π\pi and π′\pi' in the lemma gives J(π)−J(π′)=11−γEdμπ, π[Aπ′]J(\pi) - J(\pi') = \frac{1}{1-\gamma}\E_{d^\pi_\mu,\,\pi}\big[A^{\pi'}\big]: the old policy's occupancy, the new policy's advantages, and the opposite sign. It is a valid identity, but Aπ′A^{\pi'} is exactly what is unknown before π′\pi' has been evaluated.

Question 4

In the tabular natural policy gradient, πt+1(a∣s)∝πt(a∣s)exp⁡(ηAπt(s,a)/(1−γ))\pi_{t+1}(a \mid s) \propto \pi_t(a \mid s)\exp\big(\eta A^{\pi_t}(s,a)/(1-\gamma)\big). What does the update become as η→∞\eta \to \infty?

  1. The uniform policy
  2. No change: πt+1=πt\pi_{t+1} = \pi_t
  3. A plain gradient step on JJ with step size η\eta
  4. Policy iteration: in every state all probability moves to arg max⁡aAπt(s,a)=arg max⁡aQπt(s,a)\argmax_a A^{\pi_t}(s,a) = \argmax_a Q^{\pi_t}(s,a)
Show the answer

D. Policy iteration: in every state all probability moves to arg max⁡aAπt(s,a)=arg max⁡aQπt(s,a)\argmax_a A^{\pi_t}(s,a) = \argmax_a Q^{\pi_t}(s,a)

Exponential weights concentrate on the largest advantage, and since Aπt(s,a)=Qπt(s,a)−Vπt(s)A^{\pi_t}(s,a) = Q^{\pi_t}(s,a) - V^{\pi_t}(s), that is policy iteration's greedy action. A softmax policy gives every action positive probability, so no action is excluded. Small η\eta gives small, safe steps; large η\eta gives policy iteration's big jumps.

Further reading

  • S. Kakade & J. Langford, "Approximately optimal approximate reinforcement learning," ICML (2002).
  • S. M. Kakade, "A natural policy gradient," Advances in Neural Information Processing Systems 14 (2001).
  • J. Schulman, S. Levine, P. Moritz, M. Jordan & P. Abbeel, "Trust region policy optimization," ICML, PMLR 37 (2015).
  • J. Achiam, D. Held, A. Tamar & P. Abbeel, "Constrained policy optimization," ICML, PMLR 70 (2017).
  • A. Agarwal, S. M. Kakade, J. D. Lee & G. Mahajan, "On the theory of policy gradient methods: Optimality, approximation, and distribution shift," Journal of Machine Learning Research 22(98), 1–76 (2021).