A shaped reward is r′(s,a,s′)=r(s,a,s′)+γΦ(s′)−Φ(s) for some potential function Φ. Prove that the optimal policy does not change. If γ=0.9, Φ(s)=10 and Φ(s′)=20, what bonus does the agent get on the move s→s′, and what does the bonus sum to along a whole episode?

Reinforcement learning, Reward shaping
Level L4 Advanced. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you can show that potential-based shaping only shifts optimal action values by a state-dependent constant, so it speeds up learning without changing what is optimal.

Key idea

If Q∗ is optimal for r, then Q∗(s,a)−Φ(s) satisfies the Bellman optimality equation for r′. The subtracted term depends on s only, so the maximising action in each state is unchanged.

Steps

  1. Write the Bellman optimality equation for the original reward: Q∗(s,a)=∑s′P(s′∣s,a)[r+γmax⁡a′Q∗(s′,a′)].
  2. Subtract Φ(s) from both sides and add and subtract γΦ(s′) inside the bracket: Q∗(s,a)−Φ(s)=∑s′P(s′∣s,a)[r+γΦ(s′)−Φ(s)+γmax⁡a′(Q∗(s′,a′)−Φ(s′))]. This uses ∑s′P=1.
  3. Recognise r+γΦ(s′)−Φ(s)=r′ and define Q^(s,a)=Q∗(s,a)−Φ(s). The line becomes Q^(s,a)=∑s′P(s′∣s,a)[r′+γmax⁡a′Q^(s′,a′)], which is the optimality equation for r′.
  4. The solution of that equation is unique (the Bellman operator is a contraction), so Q′∗(s,a)=Q∗(s,a)−Φ(s).
  5. For a fixed state s, arg⁡max⁡aQ′∗(s,a)=arg⁡max⁡a(Q∗(s,a)−Φ(s))=arg⁡max⁡aQ∗(s,a), since Φ(s) is the same for all actions. The optimal policy is unchanged.
  6. Numbers. The bonus for s→s′ is 0.9×20−10=8. Over an episode s0,…,sT the shaping terms telescope: ∑t=0T−1γt[γΦ(st+1)−Φ(st)]=γTΦ(sT)−Φ(s0). If the final state has Φ=0, the total discounted bonus is −Φ(s0), a constant that depends only on the start state.

Common mistakes

How long your answer should be

Half a page; 4–5 minutes.

Read this

Previous in Reinforcement learning: For the policy-gradient estimate g^=(R−b) ∇θlog⁡πθ(a), derive the constant baseline b∗ that minimises variance. Then take a one-state problem with π(a1)=σ(θ)=0.8, π(a2)=0.2, rewards R(a1)=1 and R(a2)=0. Compute b∗ and the variance for b=0, b∗ and b=E[R]. Is the average reward the best baseline?
Next in Reinforcement learning: How do you prove that the Bellman optimality operator is a γ-contraction in the max-norm, and what does this tell you about value iteration converging to a unique V∗ and when to stop it?