An MDP has two states X and Y and γ=0.5. In X, action a gives reward 2 and moves to Y, while action b gives reward 1 and stays in X. In Y, action c gives reward 0 and moves to X, while action d gives reward 3 and stays in Y. Run policy iteration from the policy "b in X, c in Y". What are the evaluation and improvement steps, and what are the optimal policy and values?

Reinforcement learning, Dynamic programming
Level L3 Intermediate. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can alternate full policy evaluation (solving the Bellman expectation equations) with greedy improvement, and know when to stop.

Key idea

Policy iteration repeats two steps. Evaluate: solve Vπ(s)=r(s,π(s))+γVπ(s′). Improve: set π′(s)=arg⁡max⁡a[r(s,a)+γVπ(s′)]. It stops when the policy no longer changes, and that policy is optimal.

Steps

  1. Evaluate π0 (b in X, c in Y). V(X)=1+0.5 V(X) gives V(X)=2. V(Y)=0+0.5 V(X)=1.
  2. Improve in X: Q(X,a)=2+0.5×1=2.5 and Q(X,b)=1+0.5×2=2. Choose a.
  3. Improve in Y: Q(Y,c)=0+0.5×2=1 and Q(Y,d)=3+0.5×1=3.5. Choose d. So π1 is (a in X, d in Y).
  4. Evaluate π1. V(Y)=3+0.5 V(Y) gives V(Y)=6. V(X)=2+0.5 V(Y)=5.
  5. Improve again. In X: Q(X,a)=5 and Q(X,b)=1+0.5×5=3.5. In Y: Q(Y,d)=6 and Q(Y,c)=0+0.5×5=2.5. Nothing changes, so the policy is stable.
  6. Conclude: π∗=(a in X, d in Y) with V∗=(5,6). Policy iteration needed two improvement rounds, which is typical, because each round is a full evaluation.

Common mistakes

How long your answer should be

About one page: two evaluations and two improvements; 6–8 minutes.

Last checked on 4 December 2026.

Read this

Previous in Reinforcement learning: Write PPO's clipped surrogate objective. With ϵ=0.2, evaluate the per-sample objective, and say whether it has a non-zero gradient, when (a) A=+1, r=1.5; (b) A=−1, r=0.5; (c) A=−1, r=1.5. What is the clipping for?
Next in Reinforcement learning: An MDP has non-terminal states A and B, and γ=0.9. In A, action a1 gives reward 2 and ends the episode. Action a2 gives reward 0, and moves to B with probability 0.8 or stays in A with probability 0.2. In B, action b1 gives reward 4 and ends the episode. Action b2 gives reward 0 and moves to A. Starting from V0=0, what are the results of three sweeps of value iteration, and then what are V∗ exactly and the optimal policy?