Skip to content

1. Trust Region Policy Optimization (TRPO)

1. Introductions & Preliminaries

What is so-called reinforced learning
The reinforced learning is a computational approaches by emphasizing on the learning by an agent from direct interaction with its environment

(1) Concepts of TRPO

1. Concepts of random state functions

The trust region policy optimization (TRPO)[1] is a gradient-based method optimization algorithm, the variants of TRPO includes the vine method and the single-path method.

  • single-path method can be applied in the model-free-settings
  • vine method requires the system to be restored to particular states.
  1. Firstly, we define the following Markov decision process[2] :
(1.1.1)(S,A,P,r,ρ0,γ)

We note except the concepts in original statement, the ρ0 : SR is the distribution of the initial state s0, then γ(0,1) is discount factor.

The reinforced learning process is a kind of

2. Random state functions

Firstly, we define the following 3 random state functions for optimization :

Random state functions

  1. Definition of state-action-value function Qπ, defined as the average reward on all available current state and action :
(state-action-value-function)Qπ(st,at)=Est+1,at+1,[l=0γlr(st+l)]

Qπ fixes both the state stand the action at, representing the result when take specific action at. And l is the foresight. This describes the recent reward when we take action at at time t.

  1. The no-policy value function Vπ , we note here the input action of this step at is not defined, so :
(value-function)Vπ(st)=Eat,st+1,[l=0γlr(st+l)]

In this function, the action at is not given, drawn from the policy atπ(|st)

  1. The advantage function Aπ is :
(advantage-function)Aπ(s,a)=Qπ(s,a)Vπ(s)

where the atπ(at|st) is current-step action, and st+1P(st+1|st,at) is the next state, and this is affected by the current state st and action at, for every t0

We note in above theorem, the Aπ gives the advantage of the specific action on specific state

Also note the definition of the above random-state function in [3] is different, which is :

(1.1.2)Vπ(s)(1γ)E[l=0γlr(st+l)]

state-action value :

(1.1.3)Qπ(s,a)(1γ)R(s,a)+γE[Vπ(s)]

The difference is that the (1.1.2~3) is normalized by following factor :

(1.1.4)t=0γl=11γ

3. Average Notations under specific policy

For a policy with

(1.1.5)Eτπ~[X]=τPπ~(τ)[X]

where Pπ~ is the model decision under specific state and actions, defined by (2.1.2)[2:1]. Since the action is defined on the current state of policy, This can be further expand as (we note s is kept ):

(1.1.6)Eτπ~[X]=1Ni=1NPπ~(τ)X(τ)

In the second term in equation , the s is the same

We note we also use following notation :

(1.1.7)Esdπ~,aπ~(|s)

(2) Expected discounted reward

Here the π is a policy that determines the result state. denoted by π:S×A[0,1], the η(π) denotes the expected discounted reward, as given in (2.4.1)[2:2], (2.3.3)[2:3]. which can be rewritten as The sum of the as-far reward:

(1.2.1)η(π)=Es0,a0,[t=0γtr(st)]

The initial state is given by:

(1.2.2)s0ρ0(s0), atπ(at|st), st+1P(st+1|st,at)

(3) Policy Relation Theorem

Then, the expected return of another policy π~ in the terms of advantage over π can be given as follows, compare to (1.2.1), we should state following lemma :

Policy relation

(policy-relation)η(π~)=η(π)+Eτπ~[t=0γtAπ(st,at)]

Such expectation is taken over the trajectory τ:=(s0,a0,s1,a1,)

To derive Lemma. region-policy-relation,.We know from (3.1.1)[2:4] that, for a fixed policy π, we have :

(1.3.1)Vπ(s)=Eaπ(|s)[r(s,a)+γVπ(s)]

Then Q is, since a is already determined, we have :

(1.3.2)Qπ(s,a)=Eπ[r(s)+γVπ(s)]

We also note here that the optimal policy gives :

(1.3.3)V(s)=maxaQ(s,a)

Substituting (1.3.2) into (advantage-function), we use the Q as the real value function :

(1.3.4)Aπ(s,a)=Eπ[r(s)+γVπ(s)Vπ(s)]

For a specific time t, the E automatically disappear, then :

(1.3.5)Aπ(st,at)=r(st)+γVπ(st+1)Vπ(st)

Then, we prove from (policy-relation), here :

(1.3.6)Eτπ~[t=0γtAπ]=Eτπ~[t=0(γt+1Vπ(st+1)γtVπ(st)+γtr(st))]=Erπ~[t=0γtr(st)Vπ(s0)]

So using (1.2.1), we have :

(1.3.7)Eτπ~[t=0γtAπ]=η(π~)Es0ρ0[Vπ(s0)]

Since starting from s0ρ0, Using (value-function), also using (1.2.1), since t=0 we have :

(1.3.8)Vπ(s0)=l=0γlr(st)E[Vπ(s0)]=η(π)

the expected return under policy is ηπ=E[Vπ(s0)], then (policy-relation) holds, so the proof completes.

(4) Visitation Frequencies

We let the ρπ be the unnormalized discounted visitation frequencies.

(1.4.1)ρπ(s)=P(s0=s)+γP(s1=s)+γ2P(s2=s)+

This is the sum of the possibility to visit a specific state over some time. This is positive on every term. The ρπ is called visitation frequency density.

Using the relation (policy-relation), we can expand it using (1.1.5), we also limit the result state and action, i.e., st=s,at=a. on a deterministic states s and the available actions a, so the policy is written as π~(a|s), then we sum all the probability that under that policy, on all the possible states at time t.

Since the state on any s at all t under a trajectory, can be summed by t, then :

(1.4.2)Eτπ~[t=0γtAπ(s,a)]=st=0P(st=s|π~)aπ~(a|s)γtAπ(s,a)

408

Title To help to understand above equations,
We note that A policy π~ is a rule or probability distribution for selecting actions, which is often a distribution of the next action :

π(a|s)={1if a is chosen at some state s0 otherwise

For example :

π~(a1|s)=0.7π~(a1|s)=0.3

then we substitute ρ here, we got :

(1.4.3)η(π~)=η(π)+sρπ~(s)aπ~(a|s)Aπ(s,a)

For any policy update ππ~ if we ensure that :

(1.4.4)aπ~(a|s)Aπ(s,a)>0

then the performance of policy η is ==guaranteed to increase==. But due to the estimation and approximation error.

(5) Local Approximation of performance

The model training process is a process of optimizing the policy. From (1.4.3), we change the π~ in ρ to the π, we get the approximation by substituting to visitation frequency ρπ :

(1.5.1)Lπ(π~)=η(π)+sρπ(s)aπ~(a|s)Aπ(s,a)

Subs the π into above part, we have :

Lπ(π)=η(π)

always satisfied

We note if, we have a policy that parametrized by θ, i.e., πθ(a|s), which is a differentiable function of the parameter vector θ, then, Lπ matches η to first order. We have that for any parameter value set θ0, we should make that :

(1.5.2)Lπθ0(πθ)=η(πθ0)

satisfying :

(1.5.3)θLπθ0(πθ)|θ=θ0=θηπθ|θ=θ0

We note that, for a sufficiently small step πθ0π, we can use (1.5.2) to substitute η in (1.4.3). So the new policy πnew should be defined as following policy update criterion :

(1.5.4)πnew(a|s)=(1α)πold(a|s)+απ(a|s)

In [3:1], the lowest bound is derived as :

(1.5.5)η(πnew)ηπold(πnew)2ϵγ(1γ)2α2

where :

(1.5.6)ϵ=maxs|Eaπ(a|s)[Aπ(s,a)]|

note (1.5.5) only applies to mixture policies generated by (1.5.4). This policy class is unwieldly and restrictive in practice.

2. Monotonic Improvement guarantee

(1) Introduction

For the lowest bound by (1.5.5), this is a principle applied into general stochastic policy classes (rather than just mixed classes of (1.5.4)). For all the possible policies, the (1.5.4) is often desired.

The Total Variation divergence is used for the distance measure, defined as half of Manhattan distance :

(2.1.1)DTV(p||q)=12i|piqi|

We define we total variation distance DTV between two policies, is :

(2.1.2)DTVmax(π,π~)=maxsDTV(π(|s)||π~(|s))

In (1.5.4), we have :

Total variation distance theorem
The theorem is that, if we set α=DTVmax(πold||πnew), we have, the following relation holds :

(total-variation-distance){η(πnew)Lπold(πnew)4ϵγ(1γ)2α2whereϵ=maxs,a|Aπ(s,a)|

(2) Using KL divergence to express

In (total-variation-distance), the α is held for the α=DTVmax, we have the relation between the total variation divergence and the KL divergence [4], stated as :

(2.2.1)DTV(p||q)2DKL(p||q)

Similar to (2.1.2), We still use a max notation to the KL divergence for policy difference (on all states) :

(2.2.2)DKLmax(π,π~)=maxsDKL(π(|s)||π~(|s))

We also have the relationship between the total variation divergence and the KL divergence, as :

(2.2.3)η(π~)Lπ(π~)4ϵγ(1γ)2DKLmax(π,π~)

in later derivations, we set C=4ϵγ(1γ)2

To maximize η(π~) in the next iteration, we got the following optimization steps (here L is defined by (1.5.1)) :

(2.2.4)πi+1argmaxπ[Lπi(π)CDKLmax(πi,π)Mi(π)]

Here M is a surrogate function that memorize η. Thus we have :

(2.2.5)η(πi+1)η(πi)Mi(πi+1)Mi(πi)

The Trusted region policy optimization is an approximation of the algorithm (2.2.4). Such a policy uses constraint on the KL divergence rather than a penalty.

3. Trusted Region Policy Optimization

(1) Parameterized Policy

We considerate the optimization of the parameterized policy, i.e., πθ(a|s) with the parameter vector θ, so that, we can express the notations on the policy by θ, e.g. (1.5.1) and (2.2.3) as :

(3.1.1)L(θ):=Lπθ(πθ)η(θ):=η(πθ)

The target is to maximize M(θ), i.e., :

(3.1.2)maximizeθ[Lθold(θ)CDKLmax(θold,θ)]

Trusted region policy constraint
In the practical case, since DKL is always positive, we can make the second term as small as possible, then, the trust region constraint is constructed as :

(trusted-region-policy){maximizeθLθold(θ)subject toDKLmax(θold,θ)δ

Here θ(a|s) depends on the available actions states.

We note the problem in Theorem. TRPO is a problem solved in the KL divergence bounded space, but such a problem is intractable, (this is because, the max is applied in the firstly equation, so for every state, it impose a new constraint, and in the reinforced learning, there is often a great number of states, and the policy θ=θ(|s1,2,) ) depends on the states.

So the second constraint is applied by an average on the states :

(3.1.3)DKLρ(θ1,θ2):=Esρ[DKL(πθ1(|s)||πθ2(|s))]

So (trusted-region-policy) becomes following :

(3.1.4){maximizeθLθold(θ)subject toDKLρθold(θold,θ)δ

Here ρ is a state distribution used to average the state-wise KL divergence (the states are sampled according to the ρ, defined in (1.4.1)).

Usually, the ρ in above equation is chosen as the state visitation distribution under the old policy.

ρ=ρθold

i.e., according to the definition,

(sampling-distribution)ρπ(s)=t=0γtP(st=s|π)

Sometimes, the ρπ is also normalized as following :

(3.1.5)dπ(s)=(1γ)t=0γtP(st=s|π)

4. Sample-based estimation

(1) Problem construction

Since the L is the approximated performance defined in (1.5.1), the optimization problem (3.1.4) is written as :

(4.1.1)maximizesρθold(s)aπθAπ(s,a)subject toDKLρθold(θold,θ)δ

we note under a sampling distribution q, the contribution of a single sn can be expressed by the importance sampling estimator[5]. That is, we use distribution aq and importance sampling to compute the average :

(4.1.2)aπθ(a|sn)Aθold(sn,a)=Eaq(sn)[πθ(a|sn)q(a|sn)Aθold(sn,a)]

then the problem (3.1.4) will become :

(4.1.3)maximizeEsρθold,aq[πθ(a|sn)q(a|sn)Qθold(sn,a)]subject toEsρθold[DKL(πθold||πθ)]δ

We note in the (4.1.3), the change from A to Q is valid only as an optimization-equivalence. Considering the (advantage-function),

(4.1.4)Eaπθ[Aθold(s,a)]=Eaπθ[Qθold(s,a)Vθold(s)not depend on θ]

in the optimization process, since we want to maximize, the second term in (4.1.4) is a constant and thus can be dropped.

We also note the sρθold and aq is the single path sample-based estimation for the objective and constraint.

Another estimation is the Vine method, in which we will choose a subset of N states along these trajectories. We can sample K actions rather than using an,kq(|sn).

In the vine estimation, we can choose any q(|sn) with a support that includes the support of πθ(|sn) will produce a consistent estimator. Using use q(|sn)=πθi(|sn) still works well. This method finally yield following equations. But we will not cover them in detail :

Ln(θ)=k=1Kπθ(ak|sn)Q^(sn,ak)

using the importance sampling like 4.1.2, we also can get :

Ln(θ)=k=1Kπθ(an,k|sn)πθold(an,k|sn)Q^(sn,an,k)k=1Kπθ(an,k|sn)πθold

References


  1. Schulman, John, Sergey Levine, Philipp Moritz, Michael I. Jordan, and Pieter Abbeel. “Trust Region Policy Optimization.” arXiv:1502.05477. Preprint, arXiv, April 20, 2017. https://doi.org/10.48550/arXiv.1502.05477 ↩︎

  2. 1. Markov-decision-process ↩︎ ↩︎ ↩︎ ↩︎ ↩︎

  3. Kakade, Sham and Langford, John. Approximately optimal approximate reinforcement learning. In ICML, volume 2, pp. 267–274, 2002. https://people.eecs.berkeley.edu/~pabbeel/cs287-fa09/readings/KakadeLangford-icml2002.pdf ↩︎ ↩︎

  4. 2. Kullback-Leibler divergence ↩︎

  5. 2. Monte-Carlo Sampling and Importance Sampling ↩︎