Dynamic Programming (DP) is a core set of algorithms used in Reinforcement Learning (RL) to solve problems modeled as a Markov Decision Process (MDP)1. DP methods are particularly effective when the agent has full knowledge of the environment’s dynamics (the transition probabilities P(s’|s, a) and the reward function R(s, a, s’).
The fundamental challenge in solving MDPs is that the Bellman Equation — which defines the value of a state or action — creates a massive system of simultaneous equations. For a problem with S states and A actions, solving this system directly is computationally infeasible.
DP circumvents this by using iterative updates and the concept of bootstrapping (where updates to the value function are based on estimated values of successor states). This approach falls into two main categories: Policy Iteration and Value Iteration.
DP algorithms are built around two interlocking sub-problems:
The Policy Iteration method is a complete solution that alternates between Policy Evaluation and Policy Improvement until the optimal policy is found.
This step calculates the value function $V_{\pi}$ for the current policy pi. It uses the Bellman Expectation Equation iteratively:

Process: Starting with an arbitrary value function $V_0(s)$ (often all zeros) , the value of each state $s$ is updated based on the estimated value of the next state s’ (bootstrapping).
Once $V_{\pi}$ is accurately calculated, the policy is improved by taking an action that is greedy with respect to the new value function.

Policy iteration alternates between evaluation and improvement. Since there is a finite number of policies in a finite MDP, this process is guaranteed to converge to the optimal policy pi* and its optimal value function V*.
Value Iteration is a simplified DP algorithm that implicitly combines the Policy Evaluation and Policy Improvement steps. It does not require a full, separate policy evaluation phase.
Instead of iteratively solving the Bellman Expectation Equation (Policy Evaluation), Value Iteration directly uses the Bellman Optimality Equation for V*:

Both Policy Iteration and Value Iteration are forms of Generalized Policy Iteration (GPI), where Policy Evaluation ($V \to V$) and Policy Improvement ($\mu \to \mu’$) interact until convergence.
Value Iteration typically converges faster by reducing the number of evaluation steps, making it computationally more efficient, especially in large MDPs.
<hr><p>Dynamic Programming in RL: Policy Iteration vs. Value Iteration 🚀 was originally published in KAIST Include AI Club on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>