TRPO is a policy gradient method in RL that ensures policy parameters don’t change too much from one step to the next with the help of KL-divergence as a constraint.
We maximize the surrogate objective (instead of directly maximizing rewards):
Trust Region Policy Optimization
The objective function measures the expected advantage of policy relative to a baseline, which in this case is the old policy parameters . This baseline serves as a reference point for measuring improvement - we want to know if our new policy performs better than our previous one. The objective can be written as:
where is the state visitation distribution under the old policy. The estimated advantage measures how much better taking action in state is compared to the average value of that state.
Since we collect data using a behavior policy that differs from our target policy , we need to account for this mismatch. We can do this by introducing an importance sampling ratio:We can express this as an expectation over state-action pairs sampled according to the behavior policy. Note that when we convert from the sum to an expectation, the term becomes implicit in our sampling distribution , leaving us with:
Even in an on-policy example, where the current policy is used to collect trajectories, the actor policy can sometimes get out of sync, i.e.
TRPO introduces a trust region constraint for the distance between the old and the new policy to be within a parameter :
We measure this distance using states sampled from the old policy’s distribution, since those represent the actual states where we have data to evaluate policy performance.
As a second order method (approximating the KL divergence by computing hessian through fisher information matrix), TRPO can be computationally expensive, which motivated the development of simpler first-order alternatives like PPO that achieve similar performance.
The theory justifying TRPO actually suggests using a penalty instead of a constraint, i.e., solving the unconstrained optimization problem:
for some coefficient β. This follows from the fact that a certain surrogate objective (which computes the max KL over states instead of the mean) forms a lower bound (i.e., a pessimistic bound) on the performance of the policy π. TRPO uses a hard constraint rather than a penalty because it is hard to choose a single value of β that performs well across different problems—or even within a single problem, where the the characteristics change over the course of learning.
The objective (without the constraint) was first introduced in conservative policy iteration.