In value iteration, we were focused on finding the optimal value function $J^*$. In policy iteration, we start with a random policy and then improve it iteratively.
Algorithm Description
Policy iteration alternates between two main steps:
Policy Evaluation: Given a policy $\mu_k$, compute its cost-to-go vector $J^{\mu_k}$ by solving the system of linear equations:
$$ J^{\mu_k}(i) = \sum_{j=1}^n p_{ij}(\mu_k(i))(g(i,\mu_k(i),j) + J^{\mu_k}(j)) \quad i=1,\ldots,n $$
where $J^{\mu_k}(1), J^{\mu_k}(2), \ldots, J^{\mu_k}(n)$ are the unknowns to be solved for.
This is equivalent to solving the fixed point equation:
$$ J^{\mu_k} = T_{\mu_k}J^{\mu_k} $$
Policy Improvement: Given the cost-to-go vector $J^{\mu_k}$, find an improved policy $\mu_{k+1}$ by: $$ \mu_{k+1}(i) = \arg\min_{u \in \mathcal{A}(i)} \sum_{j=1}^n p_{ij}(u)(g(i,u,j) + J^{\mu_k}(j)) \quad \forall i=1,\ldots,n $$ This is equivalent to: $$ T_{\mu_{k+1}}J^{\mu_k} = TJ^{\mu_k} $$
The algorithm terminates when:
$$ J^{\mu_{k+1}}(i) = J^{\mu_k}(i) \quad \forall i=1,\ldots,n $$
indicating that an optimal policy has been found.
Algorithm Structure
The policy iteration algorithm has a nested loop structure, contrasting with value iteration’s single loop:
- Outer Loop (Policy Iteration)
- Continues until policy convergence
- Each iteration represents a complete policy update cycle
- Inner Loop (Policy Evaluation)
- Solves the linear system of equations to evaluate current policy
- Computes exact cost-to-go values for current policy
- Policy Improvement Step
- Single-pass improvement of policy using current cost values
- Not a loop, but rather a direct computation for each state
This structure can be represented mathematically as:
Proposition
The policy iteration procedure generates an improving sequence of proper policies and terminates with an optimal policy in a finite number of iterations, assuming the starting policy is proper. This can be formalized in the following proposition:
Proposition 4 (Policy Iteration Convergence): Under Assumptions 1 and 2, if the initial policy $\mu_0$ is proper, then:
- Improving Sequence: The sequence of policies ${\mu_k}$ generated by policy iteration satisfies:
with strict inequality for at least one state unless $\mu_k$ is optimal.
Finite Termination: The algorithm terminates with an optimal policy $\mu^*$ in a finite number of iterations.
Proper Policies: Each generated policy $\mu_k$ is proper, ensuring: $$ \underbrace{J^{\mu_k}(i)}_{\substack{\text{Cost under} \ \text{policy } \mu_k}} < \infty \quad \forall i=1,\ldots,n $$
Key implications:
- The algorithm makes steady progress, never cycling between policies
- Each iteration produces a strictly better policy until optimality
- The finite termination property is particularly valuable for practical implementation
- The proper policy requirement ensures well-defined cost functions throughout the process
Modified Policy Iteration
Modified policy iteration (MPI) is a hybrid algorithm that combines elements of both value iteration and policy iteration to achieve better computational efficiency. It addresses the main computational bottleneck of policy iteration - the exact policy evaluation step - by replacing it with a partial policy evaluation using a fixed number of value iterations.
Algorithm Structure
The algorithm consists of two main components:
- Partial Policy Evaluation: Instead of solving the linear system exactly, perform $m_k$ iterations of value iteration for the current policy:
where $m_k$ is the number of inner loop iterations for the $k$th policy.
- Policy Improvement: Update the policy using the approximate value function:
The algorithm can be represented mathematically as:
Convergence Properties
The modified policy iteration algorithm maintains the convergence guarantees of standard policy iteration while potentially reducing computational cost. Key properties include:
- Convergence to Optimal Policy: The sequence of policies converges to an optimal policy $\mu^*$
- Value Function Convergence: The sequence of value functions converges to the optimal value function $J^*$
- Flexibility in Implementation: The number of inner iterations $m_k$ can be:
- Fixed across all outer iterations
- Varied based on convergence criteria
- Adapted dynamically during execution
Computational Advantages
Modified policy iteration offers several benefits:
- Reduces computational cost per iteration compared to exact policy evaluation
- Maintains monotonic improvement in policy quality
- Allows tuning of computational effort through $m_k$ parameter
- Can be more efficient than both value iteration and policy iteration in practice
Note that
Modified policy iteration includes two special cases:
Value Iteration: When $m_k = 1$ for all $k$
- Each iteration performs just one value update
- The policy improvement step becomes:
- Policy Iteration: When $m_k = \infty$ for all $k$
- Each iteration solves the policy evaluation exactly
- Equivalent to solving the linear system:
The algorithm becomes value iteration when we set $m_k=1$ because $J_{k+1} = T_{\mu_k}J_k = TJ_k$, making each iteration equivalent to applying the optimal Bellman operator once.
Multi-stage look ahead policy iteration
Multi-stage look-ahead policy iteration extends regular policy iteration by looking ahead multiple stages when making policy decisions. Let’s understand this algorithm in detail.
Key Idea
The core concept is to improve upon regular policy iteration, which uses one-step look-ahead to find optimal decisions for one-stage problems with stage cost $g(i,a,j)$ and terminal cost $J^*(j)$. Instead, we look ahead multiple stages to find improved policies.
Mathematical Formulation
In an m-step look-ahead approach, we:
- Start at state $i$ and make $m$ subsequent decisions
- Incur corresponding stage costs $g$ over $m$ stages
- Get a terminal cost $J^*(j)$ where $j$ is the state after $m$ stages
Algorithm Properties
- Claim: m-stage policy iteration terminates with optimal policy under same conditions as regular policy iteration
Formal Definition
Let
be an optimal policy for m-stage dynamic programming with terminal cost $J^*$. Then:
- $T_k$ represents the Bellman operator at stage $k$
- $J^*$ is the optimal cost-to-go function
- The equation starts with $k = m-1$
Implementation Considerations
Computational Complexity:
- Increases with look-ahead horizon $m$
- Requires solving m-stage optimization problems
- May need approximate methods for large $m$
Trade-offs:
- Longer look-ahead potentially improves policy quality
- Computational cost grows exponentially with $m$
- Need to balance accuracy vs. computational efficiency
Practical Applications:
- Games (like chess) with deep look-ahead search
- Planning problems with clear future state predictions
- Control systems with well-defined dynamics