Off-policy Learning with Eligibility Traces: A Survey
Matthieu Geist, Bruno Scherrer
Introduction
We consider the problem of learning a linear approximation of the value function of some fixed policy in a Markov Decision Process (MDP) framework, in the most general situation where learning must be done from a single trajectory possibly generated by some other policy, also known as off-policy learning. Given samples, well-known methods for estimating a value function are temporal difference (TD) learning and Monte Carlo (Sutton and Barto, 1998). TD learning with eligibility traces (Sutton and Barto, 1998), known as TD(), constitutes a nice bridge between both approaches, and by controlling the bias/variance trade-off (Kearns and Singh, 2000), their use can significantly speed up learning. When the value function is approximated through a linear architecture, the depth of the eligibility traces is also known to control the quality of approximation (Tsitsiklis and Van Roy, 1997). Overall, the use of these traces often plays an important practical role.
There has been a significant amount of research on parametric linear approximation of the value function, without eligibility traces (in the on- or off-policy case). We follow the taxonomy proposed by Geist and Pietquin (2013), briefly recalled in Table 1 and further developped in Section 2. Value function approximators can be categorized depending on the cost function they minimize (based on bootstrapping, on a Bellman residual minimization or on a projected fixed point approach) and on how it is minimized (gradient-descent-based or linear least-squares). Most of these algorithms have been extended to take into account eligibility traces, in the on-policy case. Works on extending these approaches (based on eligibility traces) to off-policy learning are scarser. They are summarized in Table 2 (algorithms in black). The first motivation of this article is to argue that it is conceptually simple to extend all the algorithms of Table 1 so that they can be applied to the off-policy setting and use eligibility traces. If this allows rederiving existing algorithms (in black in Table 2), it also leads to new candidate algorithms (in red in Table 2). The second motivation of this work is to discuss the subtle differences between these intimately-related algorithms, and to provide some comparative insights on their empirical behavior (a topic that has to our knowledge not been considered in the literature, even in the simplest on-policy and no-trace situation).
The rest of this article is organized as follows. Section 2 introduces the background of Markov Decision Processes, describes the state-of-the-art algorithms for learning without eligibility traces, and gives the fundamental idea to extend the methods to the off-policy situation with eligibility traces. Section 3 details this extension for the least-squares based approaches: the resulting algorithms are formalized, and we derive recursive and memory-efficient formula for their implementation (this allows online learning without loss of generality, all the more that half of these algorithms are recursive by their very definition), and we discuss their convergence properties. Section 4 does the same job for stochastic gradient based approaches, which offers a smaller computational cost (linear per update, instead of quadratic). Last but not least, Section 5 describes an empirical comparison and Section 6 concludes.
Background
where denotes the expectation induced by policy . The value function satisfies the (linear) Bellman equation:
It can be rewritten as the fixed-point of the Bellman evaluation operator: where for all .
In this article, we are interested in learning an approximation of this value function under some constraints. First, we assume our approximation to be linearly parameterized:
The projection onto the hypothesis space spanned by with respect to the -quadratic norm, which will be central for the understanding of the algorithms, has the following closed-form:
If is different from , it is called an off-policy setting. Notice that all algorithms considered in this paper use this projection operator, that is the projection according to the observed dataIt would certainly be interesting to consider the projection according to the stationary distribution of , the (unobserved) target policy: this would reduce off-policy learning to on-policy learning. However, this would require reweighting samples according to the stationary distribution of the target policy , which is unknown and probably as difficult to estimate as the value function itself. As far as we know, the only work to move in this direction is the off-policy approach of Kolter (2011): samples are weighted such that the projection operator composed with the Bellman operator is non-expansive (so, weaker than finding the projection of the stationary distribution, but offering some guarantees). In this article, we consider only the projection..
so that is an unbiased estimate of .
Projected fixed point approaches aim at finding the fixed-point of the operator being the composition of the projection onto the hypothesis space and of the Bellman operator. In other words, they search for the fixed-point , being the just introduced projection operator. Solving the following fixed-point problem:
with a least-squares approach, corresponds to the Least-Squares Temporal Differences (LSTD) algorithm of Bradtke and Barto (1996). Recently, Sutton et al. (2009) proposed two algorithms reaching the same objective, Temporal Difference with gradient Correction (TDC) and Gradient Temporal Difference 2 (GTD2), by performing a stochastic gradient descent of the function which is minimal (and equal to 0) when .
A related approach consists in building a recursive algorithm that repeatedly mimicks the iteration . In practice, we aim at minimizing
Performing the minimization exactly through a least-squares method leads to the Least-Squares Policy Evaluation (LSPE) algorithm of Bertsekas and Ioffe (1996). If this minimization is approximated by a stochastic gradient descent, this leads to the classical Temporal Difference (TD) algorithm (Sutton and Barto, 1998).
Bootstrapping approaches consist in treating value function approximation after seeing the transition as a supervised learning problem, by replacing the unobserved values at states by some estimate computed from the trajectory until the transition , the best such estimate being . This amounts to minimizing the following function:
Choi and Van Roy (2006) proposed the Fixed-Point Kalman Filter (FPKF), a least-square variation of TD that minmizes exactly the function of Equation (6). If the minimization is approximated by a stochastic gradient descent, this gives – again – the classical TD algorithm (Sutton and Barto, 1998).
Finally, residual approaches aim at minimizing the distance between the value function and its image through the Bellman operator, . Based on a trajectory, this suggests the following function to minimize
which is a biased surrogate of the objective (for instance, see Antos et al. (2006)). This cost function has originally been proposed by Baird (1995) who minimized it using a stochastic gradient approach (this algorithm being referred here as gBRM for gradient-based Bellman Residual Minimization). Both the parametric Gaussian Process Temporal Differences (GPTD) algorithm of Engel (2005) and the linear Kalman Temporal Differences (KTD) algorithm of Geist and Pietquin (2010b) can be shown to minimize the above cost using a least-squares approach, and are thus the very same algorithmThis is only true in the linear case. GPTD and KTD were both introduced in a more general setting: GPTD is nonparametric and KTD is motivated by the goal of handling nonlinearities., that we will refer to as BRM (for Bellman Residual Minimization) in the remaining of this paper.
To sum up, it thus appears that after the transition has been observed, the above mentioned algorithms behave according to the following pattern:
either through a least-squares approach or a stochastic gradient descent. Each of the algorithms mentionned above is obtained by substituting {\color[rgb]{0,0.16,0.90}\theta_{i}}\text{, }{\color[rgb]{0,0.16,0.90}\theta_{i-1}}\text{, }{\color[rgb]{0,0.16,0.90}\theta_{j-1}}\text{ or }{\color[rgb]{0,0.16,0.90}\omega} for {\color[rgb]{0.90,0.16,0}\xi}.
Towards Off-policy Learning with Traces
It is now easy to preview, at least at a high level, how one may extend the previously described algorithms so that they can deal with eligibility traces and off-policy learning. The idea of eligibility traces amounts to looking for the fixed-point of the following variation of the Bellman operator (Bertsekas and Tsitsiklis, 1996)
that makes a geometric average with parameter of the powers of the original Bellman operator . Clearly, any fixed-point of is a fixed-point of and vice-versa. After some simple algebra, one can see that:
This leads to the following well-known temporal difference-based expression in some state
where we recall that means that the expectation is done according to the target policy , and where we \delta_{ik}(s)=E_{\pi}\left[r_{k}+\gamma V(s_{k+1})-V(s_{k})\Big{|}s_{i}=s\right] is the expected temporal-difference (Sutton and Barto, 1998). With , we recover the Bellman evaluation equation. With , this is the definition of the value function as the expected and discounted cumulative reward: .
As before, we assume that we are given a trajectory , except now that it may be generated from some behaviour policy possibly different from the target policy of which we want to estimate the value. We are going to describe how to compute the iterate for several algorithms. For any , unbiased estimates of the temporal difference terms can be computed through importance sampling (Ripley, 1987). Indeed, for all , let us introduce the following weight:
In our trajectory context, for any and , write
with the convention that if , . With these notations,
is an unbiased estimate of , from which we may build an estimate of (we will describe this very construction separately for the least-squares and the stochastic gradient as they slightly differ). Then, by replacing the empirical operator in Equation (8) by , we get the general pattern for off-policy trace-based algorithms:
either through a least-squares approach or a stochastic gradient descent after having instantiated {\color[rgb]{0.90,0.16,0}\xi}={\color[rgb]{0,0.16,0.90}\theta_{i}}\text{, }{\color[rgb]{0,0.16,0.90}\theta_{i-1}}\text{, }{\color[rgb]{0,0.16,0.90}\theta_{j-1}}\text{ or }{\color[rgb]{0,0.16,0.90}\omega}. This process, including in particular the precise definition of the empirical operator , will be further developped in the next two sectionsNote that we let the empirical operator depends on the index of the sample (as before) but also on the step of the algorithm. This will be particularly useful for the derivation of the recursive and memory-efficient least-squares based algorithms that we present in the next section.. Since they are easier to derive, we begin by focusing on least-squares algorithms (right column of Table 2) in Section 3. Then, Section 4 focuses on stochastic gradient descent-based algorithms (left column of Table 2).
Least-squares-based extensions to eligibility traces and off-policy learning
In this section, we first consider the case of least-squares solving of the pattern described in Equation (17). At their step, the algorithms that we are about to describe will compute the parameter by exactly solving the following problem:
where we define the following empirical truncated approximation of :
Though different definitions of this operator may lead to practical implementations, note that only uses samples seen before time : this very feature – considered by all existing works in the literature – will enable us to derive recursive and low-memory algorithms.
Recall that a linear parameterization is chosen here, . We adopt the following notations:
The generic cost function to be solved is therefore:
Before deriving existing and new least-squares-based algorithms, as announced, some technical lemmata are required.
The first lemma allows computing directly the inverse of a rank-one perturbated matrix.
The next lemma is simply a rewriting of imbricated sums. However, it is quite important here as it will allow stepping from the operator (operator which depends on future of ) – forward view of eligibility traces – to the recursion over parameters using eligibility traces (dependence on only past samples) – backward view of eligibility traces – (see (Sutton and Barto, 1998, Ch.7) for further discussion on backward/forward views).
We are now ready to mechanically derive the off-policy algorithms LSTD(), LSPE(), FPKF() and BRM(). This is what we do in the following subsections.
The off-policy LSTD() algorithm corresponds to instantiating Problem (22) with {\color[rgb]{0.90,0.16,0}\xi}={\color[rgb]{0,0.16,0.90}\theta_{i}}:
This can be solved by zeroing the gradient respectively to :
which, through Lemma 2, is equivalent to:
Introducing the (importance based) eligibility vector :
one obtains the following batch estimate:
Thanks to Lemma 1, the inverse can be computed recursively:
This can be used to derive a recursive estimate:
Writing the gain , this gives Algorithm 1.
This algorithm has been proposed and analyzed recently by Yu (2010a). The author proves the following result: if the behavior policy induces an irreducible Markov chain and chooses with positive probability any action that may be chosen by the target policy , and if the compound (linear) operator has a unique fixed-pointIt is not always the case, see Tsitsiklis and Van Roy (1997) for a counter-example., then off-policy LSTD() converges to it almost surely. Formally, it converges to the solution of the so-called projected fixed-point equation:
Using the expression of the projection and the form of the Bellman operator in Equation (10), it can be seen that satisfies (see Yu (2010a) for details)
The core of the analysis of Yu (2010a) consists in showing that and defined in Equation (31) respectively converge to and almost surely. Through Equation (30), this implies the convergence of to .
2 Off-policy LSPE(λ𝜆\lambda)
The off-policy LSPE() algorithm corresponds to the instantiation {\color[rgb]{0.90,0.16,0}\xi}={\color[rgb]{0,0.16,0.90}\theta_{i-1}} in Problem (22):
This can be solved by zeroing the gradient respectively to :
Lemma 2 can be used (recall the definition of the eligibility vector in Equation (29)):
where the second equality follows from Lemma 1. Let and be defined as in the LSTD description in Equation (31). For clarity, we restate their definition along with their recursive writing:
Then, it can be seen that the LSPE() update is:
The overall computation is provided in Algorithm 2.
This algorithm, (briefly) mentioned by Yu (2010a), generalizes the LSPE() algorithm of Bertsekas and Ioffe (1996) to off-policy learning. With respect to LSTD(), which computes (cf. Equation (30)) at each iteration, LSPE() is fundamentally recursive (as it is based on an iterated fixed-point search). Along with the almost sure convergence of and to and (defined in Equation (37)), it can be shown that converges to (see for instance Nedić and Bertsekas (2003)) so that, asymptotically, LSPE() behaves as:
or using the defintion of , , (Equation (37)) and (Equation (10)):
The behavior of this sequence depends on whether the spectral radius of is smaller than or not. Thus, the analyses of Yu (2010a) and Nedić and Bertsekas (2003) (for the convergence of ) imply the following convergence result: under the assumptions required for the convergence of off-policy LSTD(), and the additional assumption that the operator has a spectral radius smaller than 1 (so that it is contracting), LSPE() also converges almost surely to the fixed-point of the compound operator.
There are two sufficient conditions that can ensure such a desired contraction property. The first one is when one considers on-policy learning, as Nedić and Bertsekas (2003) did when they derived the first convergence proof of (on-policy) LSPE(). When the behavior policy is different from the target policy , a sufficient condition for contraction is that be close enough to 1; indeed, when tends to 1, the spectral radius of tends to zero and can potentially balance an expansion of the projection . In the off-policy case, when is sufficiently big, a small value of can make expansive (see Tsitsiklis and Van Roy (1997) for an example in the case ) and off-policy LSPE() will then diverge. Eventually, Equations (35) and (48) show that when , both LSTD() and LSPE() asymptotically coincide (as does not depend on ).
3 Off-policy FPKF(λ𝜆\lambda)
The off-policy FPKF() algorithm corresponds to the instantiation {\color[rgb]{0.90,0.16,0}\xi}={\color[rgb]{0,0.16,0.90}\theta_{j-1}} in Problem (22):
This can be solved by zeroing the gradient respectively to :
where is the matrix introduced for LSPE() in Equation (43). For clarity, we restate its definition here and its recursive writing:
With respect to the previously described algorithms, the difficulty here is that on the right side there is a dependence with all the previous terms for . Using the symmetry of the dot product , it is possible to write a recursive algorithm by introducing the trace matrix that integrates the subsequent values of as follows:
Using Equation (51) and a few algebraic manipulations, we end up with:
This is the parameter update as provided in Algorithm 3.
It generalizes the FPKF algorithm of Choi and Van Roy (2006) that was originally only introduced without traces and in the on-policy case. As LSPE(), this algorithm is fundamentally recursive. However, its overall behavior is quite different. As we discussed for LSPE(), can be shown to tend asymptotically to and FPKF() iterates eventually resemble:
The term in brackets is a random component (that only depends on the last transition) and acts as a learning coefficient that asymptotically tends to 0. In other words, FPKF() has a stochastic approximation flavour. In particular, one can see FPKF(0) as a stochastic approximation of LSPE(0). Indeed, asymptotically, FPKF(0) does the following update
and one can notice that and are samples of and to which and converge through LSPE(0). When , the situation is less clear – up to the fact that since does not depend on , we expect FPKF to asymptotically behave like LSTD and LSPE when tends to .
Due to its much more involved form (notably the matrix trace integrating the values of all the values from the start), it does not seem easy to provide a guarantee for FPKF(), even in the on-policy case. To our knowledge, there does not exist any proof of convergence for stochastic approximation algorithms in the off-policy case with tracesAn analysis of TD(), with a simplifying assumption that forces the algorithm to stay bounded is given by Yu (2010a). An analysis of GQ() is provided by Maei and Sutton (2010), with an assumption on the second moment of the traces, which does not hold in general (see Proposition 2 in (Yu, 2010a)). A full analysis of these algorithms thus remains to be done. See also Sections 4.1 and 4.2., and a related result for FPKF() thus seems difficult. Based on the above-mentioned relation between FPKF(0) and LSPE(0) and the experiments we have run (see Section 5), we conjecture that off-policy FPKF() has the same asymptotic behavior as LSPE(). We leave the formal study of this algorithm for future work.
4 Off-policy BRM(λ𝜆\lambda)
The off-policy BRM() algorithm corresponds to the instantiation {\color[rgb]{0.90,0.16,0}\xi}={\color[rgb]{0,0.16,0.90}\omega} in Problem (22):
This yields the following batch estimate:
The transformation of this batch estimate into a recursive update rule is somewhat tedious (it involves three “trace” variables), and the details are deferred to Appendix A for clarity. The resulting BRM() method is provided in Algorithm 4. Note that at each step, this algorithm involves the inversion of a matrix (involving the identity matrix ), inversion that admits a straightforward analytical solution. The computational complexity of an iteration of BRM() is thus (as for the preceding least-squares-based algorithms).
GPTD and KTD, which are close to BRM, have also been extended with some trace mechanism; however, GPTD() (Engel, 2005)Technically, GPTD() is not exactly a generalization of GPTD as it does not reduce to it when . It is rather a variation., KTD() (Geist and Pietquin, 2010a) and the just described BRM() are different algorithms. Briefly, GPTD() is very close to LSTD() and KTD() uses a different Bellman operatorThe corresponding loss is . With it gives and with it provides .. As BRM() builds a linear system whose solution is updated recursively, it resembles LSTD(). However, the system it builds is different. The following theorem, proved in Appendix B, partially characterizes the behavior of BRM() and its potential limitOur proof is similar to that of Proposition 4 in Bertsekas and Yu (2009b). The overall arguments are the following: Equation (61) implies that the traces can be truncated at some depth , whose influence on the potential limit of the algorithm vanishes when tends to . For all , the -truncated version of the algorithm can easily be analyzed through the ergodic theorem for Markov chains. Making tend to allows tying the convergence of the original arguments to that of the truncated version. Eventually, the formula for the limit of the truncated algorithm is computed and one derives the limit..
Assume that the stochastic matrix of the behavior policy is irreducible and has stationary distribution . Further assume that there exists a coefficient such that
The fundamental idea behind the Bellman Residual approach is to address the computation of the fixed-point of differently from the previous methods. Instead of computing the projected fixed-point as in Equation (35), one considers the following overdetermined system
Stochastic gradient based extensions to eligibility traces and off-policy learning
We have just provided a systematic derivation of all least-squares-based algorithms for learning with eligibility traces in an off-policy manner. When the number of features is very large, the complexity involved by a least-squares approach may be prohibitive. In such a situation, a natural alternative is to consider an approach based on a stochastic gradient descent of the objective function of interest (Bottou and Bousquet, 2011; Sutton et al., 2009; Maei and Sutton, 2010).
In this section, we will describe a systematic derivation of stochastic gradient based algorithms for learning in an off-policy manner with eligibility traces. The principle followed is the same as for the least-squares-based approaches: we shall instantiate the algorithmic pattern of Equation (17) by choosing the value of and update the parameter so as move towards the minimum of in Equation (17) using a stochastic gradient descent. To make the pattern of Equation (17) precise, we need to define the empirical approximate operator we use. We will consider the untruncated operators (written in the followings , with a slight abuse of notation):
where is the total length of the trajectory.
It should be noted that algorithmic derivations will here be a little bit more involved than in the least-squares case. First, with the instantiation , the pattern given in Equation (17) is actually a fixed-point problem onto which one cannot directly perform a stochastic gradient descent (this issue will be addressed in Section 4.2 through the introduction of an auxiliary objective function, following the approach originally proposed by Sutton et al. (2009)). A second difficulty is the following: the just introduced empirical operator depends on all the trajectory after step (on the future of the process), and is for this reason usually coined a forward view estimate. Though it would be possible, in principle, to implement a gradient descent based on this forward view, it would not be very memory nor time efficient. Thus, we will follow a usual trick of the literature by deriving recursive algorithms based on a backward view estimate that is equivalent to the forward view in expectation. To do so, we will repeatedly use the following identity that highlights the fact that the estimate can be written as a forward recursion:
Proof Using notably the identity , we have:
To sum up, the “recipe” that we are about to use to derive off-policy gradient learning algorithms based on eligibility traces will consist of the following steps:
write the empirical generic cost function (17) with the untruncated Bellman operator of Equation (70)
instantiate and derive the gradient-based update rule (with some additional work for , see Section 4.2);
turn the forward view into an equivalent (in expectation) backward view.
The next subsection details the precise derivation of the algorithms.
Because it is the simplest, we begin by considering the bootstrap approach, that is the instantiation . The cost function to be minimized is therefore:
Minimized with a stochastic gradient descent, the related update rule is ( being a standard learning rate and recalling that ):
At this point, one could notice that the exact same update rule would have been obtained with the instantiation . This was to be expected: as only the last term of the sum is considered for the update, we have , therefore .
Equation (77) makes use of a -TD error defined as
For convenience, let also be the standard (off-policy) TD error defined as
The -TD error can be expressed as a forward recursion:
Let be the -TD error and be the standard TD error. Then for all ,
Therefore, we get the following update rule
with . The key idea here is to find some backward recursion such that in expectation, when the Markov chain has reached its steady state, it provides the same result as the forward recursion. Such a backward recursion is given by the following lemma.
Let be the eligibility vector, defined by the following recursion:
Proof For clarity, we omit the dependence with respect to and write below (resp. for (resp. . The result relies on successive applications of Lemma 5. We have:
Moreover, we have that , as expectation is done according to the stationary distribution, therefore:
This suggests to replace Equation (77) by the following update rule,
which is equivalent in expectation when the Markov chain has reached its steady state. This is summarized in Algorithm 5.
This algorithm has first been proposed in the tabular case by Precup et al. (2000). An off-policy TD() algorithm (with function approximation) has been proposed by Precup et al. (2001), but it differs significantly from the algorithm just described (notably it differs in the definition of the traces and the projected Bellman equation, and in the fact that it is constrained to episodic trajectories). Algorithm 5 has actually first been proposed much more recently by Bertsekas and Yu (2009a).
An important issue for the analysis of this algorithm is the fact that the trace may have an infinite variance, due to importance sampling (see Yu (2010b, Sec. 3.1)). As far as we know, the only existing analysis of off-policy TD() (as provided in Algorithm 5) uses an additional contraint which forces the parameters to be bounded: after each parameter update, the resulting parameter vector is projected onto some predefined compact set. This analysis is performed by Yu (2010b, Sec. 4.1). Under the standard assumptions of stochastic approximations and most of the assumptions required for the on-policy TD() algorithm, assuming moreover that is a contraction (which we recall to hold for a big enough ) and that the predefined compact set used to project the parameter vector is a large enough ball containing the fixed point of , the constrained version of off-policy TD() converges to this fixed-point (therefore, the same solution as off-policy LSTD(), LSPE() and FPKF()). We refer to Yu (2010b, Sec. 4.1) for further details. An analysis of the unconstrained version of off-policy TD() described in Algorithm 5 is an interesting topic for future research.
2 Off-policy TDC(λ𝜆\lambda) and off-policy GTD2(λ𝜆\lambda)
In this section, the case is considered. Following the general pattern, at step , we would like to come up with a new parameter that moves (from ) closer to the minimum of the function
This problem is tricky since the function to minimize contains what we want to compute – – as a parameter. For this reason we cannot directly perform a stochastic gradient descent of the right hand side. Instead, we will consider an alternative (but equivalent) formulation of the projected fixed-point minimization , and will move from to by making one step of gradient descent of an estimate of the function
we consider the following objective function:
This is the derivation followed by Sutton et al. (2009) in the case and by Maei and Sutton (2010) in the case (and off-policy learning). Let us introduce the following notation:
Note that since we consider a linear approximation this quantity does not depend on . Noticing that , we can compute :
Let be a quasi-stationary estimate of the last part, that can be recognized as the solution of a least-squares problem (regression of -TD errors on features ):
The identification with the above least-squares solution suggests to use the following stochastic gradient descent to form the quasi-stationary estimate:
This update rule makes use of the -TD error, defined through a forward view. As for the previous algorithm, we can use Proposition 6 to obtain the following backward view update rule that is equivalent (in expectation when the Markov chain reaches its steady state):
Using this quasi-stationary estimate, the gradient can be approximated as:
Therefore, a stochastic gradient descent gives the following update rule for the parameter vector :
Once again the forward view term can be turned into a backward view by using Proposition 6. There remains to work on the term .
First, one can notice that the term satisfies a forward recursion.
Proof This result is simply obtained by applying the gradient to the forward recursion of provided in Lemma 4 (according to ). Using this, the term can be worked out similarly to the term .
Let be the eligibility vector defined in Proposition 6. We have
Proof The proof is similar to that of Proposition 6. Writing and , we have
Using this result and Proposition 6, it is natural to replace Equation (111) by an update based on a backward recursion:
Last but not least, for the estimate to be indeed quasi-stationary, the learning rates should satisfy the following condition (in addition to the classical conditions):
Eqs. (117) and (109) define the off-policy TDC() algorithm, summarized in Algorithm 6. It was originally proposed by Maei and Sutton (2010) under the name GQ(). We call it off-policy TDC() to highlight the fact that it is the extension of the original TDC algorithm of Sutton et al. (2009) to off-policy learning with traces. One can observe – to our knowledge, this was never mentionned in the literature before – that when , the learning rule of TDC(1) reduces to that of TD(1).
Maei and Sutton (2010) show that the algorithm converges with probability 1 to the same solution as the LSTD() algorithm (that is, to ) under some technical assumptions. Contrary to off-policy TD(), this algorithm does not requires to be a contraction in order to be convergent. Unfortunately, one of the assumptions made in the analysis, requiring that the traces have uniformly bounded second moments, is restrictive since in an off-policy setting the traces may easily have an infinite variance (unless the behavior policy is really close to the target policy), as noted by Yu (2010a) (see also Randhawa and Juneja (2004)). A full proof of convergence thus still remains to be done.
Using the same principle (that is, performing a stochastic gradient descent to minimize ), in the case, an alternative to TDC, the GTD2 algorithm was derived by Sutton et al. (2009). As far as we know, it has never been extended to off-policy learning with traces; we do it now. Notice that, given the derivation of GQ(), obtaining this algorithm is pretty straightforward.
To do so, we can start back from Equation (105):
This suggests the following alternative update rule (based on forward recursion):
Using Proposition 8, it is natural to use the following alternative update rule, based on a backward recursion:
The update of remains the same, and put together it gives off-policy GTD2(), summarized in Algorithm 7. The analysis of this new algorithm constitutes a potential topic for future research.
3 Off-policy gBRM(λ𝜆\lambda)
The last considered approach is the residual approach, corresponding to the instantiation . The cost function to be minimized is then:
Following the negative of the gradient of the last term leads to the following update rule:
recalling the notation first defined in Equation (102).
As usual, this update involves a forward view, which we are going to turn into a backward view. The term can be worked thanks to Proposition 6. The term is more difficult to handle, as it is the product of two forward views (until now, we only considered the product of a forward view with a non-recursive term). This can be done thanks to the following original relation (the proof being somewhat tedious, it is deferred to Appendix C):
Write and define
This result (together with Proposition 6) suggests to update parameters as follows:
This gives the off-policy gBRM() algorithm, depicted in Algorithm 8. One can observe that gBRM(1) is equivalent to TD(1) (and thus also TDC(1), cf. the comment before the description of Algorithm 6).
The analysis of this new algorithm is left for future research.
Empirical Study
This section aims at empirically comparing the surveyed algorithms. As they only address the policy evaluation problem, we compare the algorithms in their ability to perform policy evaluation (no control, no policy optimization); however, they may straightforwardly be used in an approximate policy iteration approach (Bertsekas and Tsitsiklis, 1996; Munos, 2003)). In order to assess their quality, we consider finite problems where the exact value function can be computed.
More precisely, we consider Garnet problems (Archibald et al., 1995), which are a class of randomly constructed finite MDPs. They do not correspond to any specific application, but are totally abstract while remaining representative of the kind of MDP that might be encountered in practice. In our experiments, a Garnet is parameterized by 4 parameters and is written : is the number of states, is the number of actions, is a branching factor specifying how many possible next states are possible for each state-action pair ( states are chosen uniformly at random and transition probabilities are set by sampling uniform random cut points between 0 and 1) and is the number of features (for function approximation). The reward is state-dependent: for a given randomly generated Garnet problem, the reward for each state is uniformly sampled between 0 and 1. Features are chosen randomly: is a feature matrix of which each component is randomly and uniformly sampled between 0 and 1, except the first row of which each component is set to 1 (this corresponds to a constant feature). The discount factor is set to in all experiments.
We consider two types of problems, “small” and “big”, respectively corresponding to instances and . We also consider two types of learning: on-policy learning and off-policy learning. In the on-policy setting, for each Garnet a policy to be evaluated is randomly generated (by sampling randomly cut points between and for each state), and trajectories (to be used for learning) are sampled according to this same policy. In the off-policy setting, the policy to be evaluated is randomly generated the same way, but trajectories are sampled according to a uniform policy (that chooses each action with equal probability, that is for any state-action couple).
For all algorithms, we choose . For least-squares-based algorithms (LSTD, LSPE, FPKF and BRM), we set the initial matrices to (the higher this value, the more negligible its effect on estimatesWe observed that this parameter did not play a crucial role in practice.). We run a first set of experiments in order to set all other parameters (eligibility factor and learning rates). We use the following schedule for the learning rates:
More precisely, we generate one problem (MDP and policy) for each possible combination small/big on-policy/off-policy (leading to four problems). For each problem, we generate 10 trajectories of length using the behaviorial policy (which is the randomly generated target policy in the on-policy case and the uniform policy in the off-policy case), to be used by all algorithms. For each meta-parameter, we consider the following ranges of values: , , , and . Then, we compute the parameter estimates considering all algorithms instantiated with each possible combination of the meta-parameters. This gives for each combination a family with the number of transitions encountered in the trajectory. Finally, for each problem and each algorithm, we choose the combination of meta-parameters which minimizes the average error on the second half of the learning curves (we do this to reduce the sensitivity to the initialization and the transient behavior). Formally, we pick the set of parameters that minimizes the following quantity:
We provide the empirical results of this first set of experiments in Table 3 to 6. As a complement, we detail in Figure 1 the sensitivity of all algorithms with respect to the main parameter that controls the eligibility traces. We comment these results below.
Table 3 shows the best meta-parameters for 10 trajectories of a single instance of a small Garnet problem in an on-policy setting, as well as related efficiencies. Numerically, all least-squares-based methods provide equivalent performance, with similar choices of the eligibility factor (which is the only meta-parameter). TD gets its best results with a small (we believe this is the case because the MDP has few states). The new gBRM algorithm and GTD2 algorithm work well, but picking a higher value of . Eventually, TDC performs slightly worse. Figure 1 (top, left) shows that the choice of does not matter, except for FPKF that requires to be efficient; with this value FPKF is almost identical to LSPE(1) and LSTD(1) (cf. the discussion at the end of Section 3.3).
Table 4 shows the best meta-parameters for 10 trajectories of a single instance of a big Garnet problem in an on-policy setting, as well as related performance. These results are consistent with those of the small problem, in the on-policy setting (with slightly different meta-parameters). The main difference are that GTD2 performs here the worse. Figure 1 (top, right) suggests that as the problem’s size grows, the role of the eligibity factor gets more prominent: most algorithms need a relatively high value of to perform the best.
Table 5 reports the best meta-parameters in an off-policy setting for a small problem. In terms of performance, Least-squares approaches are no longer equivalent. LSTD and LSPE get the best results, with the smallest possible value : we believe that this choice is due to the fact that higher eligibility factor increases the variance due to importance sampling. FPKF and BRM need large values of to work well, and suffer much more from the off-policy aspect. Figure 1 (bottom, left) suggests that FPKF and BRM need a high value of (to “catch” the good performance of LSTD/LSPE) but then suffers from the variance due to importance sampling. Regarding gradient-based methods, TD’s performance is good (it is close that of LSTD/LSPE), followed closely by GTD2 (both being better than FPKF/BRM). TDC and gBRM lead to the worse results; as both methods choose , they here turn out to be equivalent to TD(1) (cf. the discussions after Algorithms 6 and 8)In particular, one can observe that the performance of gBRM(1) and TDC(1) in Table 5 are numerically equal.. As for FPKF/BRM with respect to LSTD/LSPE, Figure 1 (bottom, left) further suggests that TDC and gBRM need a high value of in order to get a reasonable performance, but then suffer from the variance of importance sampling.
Eventually, Table 6 shows the meta-parameters and performance in the most difficult situation: the off-policy setting of the big problem. These results are consistent with the off-policy results of the small problem, summarized in Table 5. LSTD and LSPE are the most efficient algorithms and choose the smallest possible value . FPKF and BRM’s performance deteriorate (significantly for the latter). TD behaves reasonably good (it is in particular much better than FPKF) and GTD2 follows closely. The performance of TDC and gBRM are the worse, the latter’s by a significant amount. Figure 1 (bottom, right) is similar to that of the small problem.
The main goal of the series of experiments we have just described was to choose reasonable values for the meta-parameters. We have also used these experiments to quickly comment the relative performance of the algorithms, but this is not statistically significant as this was based on a single (random) problem. Though we will see that the general behavior of the algorithm is globally consistent with what we have seen so far, the series of experiments that we are about to describe aims at providing such a statistically significant performance comparison. For each situation (small and big problems, on- and off-policy), we fix the meta-parameters to the previously reported values and we compare the algorithms on several new instances of the problems. These results are reported on Figures. 2 to 5. For each of the 4 problems, we randomly generate 100 instances (MDP and policy to be evaluated). For each such problem, we generate a trajectory of length . Then, all algorithms learn using this very trajectory. On each figure, we report the average performance (left), measured as the difference between the true value function (computed from the model) and the currently estimated one, , as well as the associated standard deviation (right).
We begin by discussing the results in the on-policy setting. Figure 2 compares all algorithms for 100 randomly generated small problems (that is, each run corresponds to different dynamics, reward function, features and evaluated policy), the meta-parameters being those provided in Table 3. All least-squares approaches provide the best results and are bunched together; this was to be expected, as all algorithms use close to . In these problems, gBRM works better than other gradient-based methods, followed by TD and GTD2/TDC. Figure 3 compares the algorithms for 100 randomly generated big problems, the meta-parameters being those provided in Table 4. These result are similar to those of the small problem in an off-policy setting, except that TDC is now faster than GTD2, that TD is slightly faster than gBRM.
We now consider the off-policy setting. Figure 4 provides the average performance and standard deviation of the algorithms (meta-parameters being those of Table 5) on 100 small problems. Once again, we can see that LSTD/LSPE provide the best results. The two other least-squares methods (FPKF and BRM) are overtaken by the gradient-based TD algorithm. GTD2 is quite slow (slower than TD) and TDC/gBRM (that are identical to TD(1) since they both use ) are the slowest algorithms. Figure 5 provides the same data for the big problems (with the meta-parameters of Table 6). These results are similar to those of the small problems in an off-policy setting. The main differences are 1) that FPKF appears to converge faster than TD but with a bigger standard deviation, and 2) gBRM (that uses ) does not work anymore (it is here equivalent to the standard algorithm by (Baird, 1995) and probably suffers from the well-known associated bias issue).
Overall, our experiments suggest that the two best algorithms are LSTD/LSPE, since they converge much faster in all situations. The gradient-based TD algorithm globally diplays a good behavior and constitutes a good alternative when the number of features is too big for least-squares methods to be implemented. Though some new algorithms/extensions show interesting results (FPKF() is consistently better that the state-of-the-art FPKF by Choi and Van Roy (2006), gBRM works well in the on-policy setting) most of the other algorithms do not seem to be empirically competitive with the trio LSTD/LSPE/TD, especially in off-policy situations. In particular, the algorithm introduced specifically for the off-policy setting (TDC/GTD2) are much slower than TD. Moreover, the condition required for the good behavior of LSPE, FPKF and TD – the contraction of – does not seem to be very restrictive in practice (at least for the Garnet problems we considered): though it is possible to build specific pathological examples where these algorithms divergeA preliminary version of this article (Scherrer and Geist, 2011) contains such examples, and also an example where an adverserial choice of leads to the divergence of LSTD()., this never happened in our experiments.
Conclusion and Future Work
We have considered least-squares and gradient-based algorithms for value estimation in an MDP context. Starting from the on-policy case with no trace, we have recalled that several algorithms (LSTD, LSPE, FPKF and BRM for least-squares approaches, TD, gBRM and TDC/GTD2 for gradient-based approaches) fall in a common algorithmic pattern (Equation (8)). Substituting the original Bellman operator by an operator that deals with traces and off-policy samples naturally leads to the state-of-the-art off-policy trace-based versions of LSTD, LSPE, TD and TDC, and suggests natural extensions of FPKF, BRM, gBRM and GTD2. This way, we surveyed many known and new off-policy eligibility traces-based algorithms for policy evaluation.
We have explained how to derive recursive (memory and time-efficient) implementations of all these algorithms and discussed their known convergence properties (including an original analysis of BRM() for sufficiently small , that implies the so far not known convergence of GPTD/KTD). Interestingly, it appears that the analysis of off-policy traces-based stochastic gradient algorithms under mild assumptions is still an open problem: the only currently known analysis of TD (Yu, 2010a) only applies to a constrained version of the algorithm, and that of TDC (Maei and Sutton, 2010) relies on an assumption on the boundedness of the second moment traces that is restrictive (Yu, 2010a). Filling this theoretical gap, as well as providing complete analyses for the other gradient algorithms and FPFK() and BRM() constitute important future work.
Finally, we have illustrated and compared the behavior of these algorithms; this constitutes the first exhaustive empirical comparison of linear methodsTo our knowledge, there does not even exist any work reporting and comparing empirical results of LSTD(0) and FPKF(0).. Overall, our study suggests that even if the use of eligibility traces generally improves the efficiency of all algorithms, LSTD and LSPE consistently provide the best estimates; and in situations where the computational cost is prohibitive for a least-squares approach (when the number of features is large), TD probably constitutes the best alternative.
References
A Derivation of the recursive formulae for BRM(λ𝜆\lambda)
We here detail the derivation of off-policy BRM(). We will need two technical lemmata. The first one is the Woodbury matrix identity which generalizes the Sherman-Morrison formula (given in Lemma 1).
Let , , and be matrices of correct sizes, then:
The second lemma is a rewriting of imbricated sums:
As stated in Equation (59), we have the following batch estimate for BRM():
To obtain a recursive formula, these two sums have to be reworked through Lemma 11. Let us first focus on the latter:
and with the convention that and , one can write:
and the identity matrix, we have:
We can apply the Woodbury identity given in Lemma 10:
Finally, the recursive BRM() estimate can be computed as follows:
This gives BRM() as provided in Algorithm 4.
B Proof of Theorem 3 (Convergence of BRM(λ𝜆\lambda))
The proof of Theorem 3 follows the general idea of that of Proposition 4 of Bertsekas and Yu (2009b). It is done in 2 steps. First we argue that the limit of the sequence is linked to that of an alternative algorithm for which one cuts the traces at a certain depth . Then, we show that for all depth , this alternative algorithm converges almost surely, we explicitely compute its limit and make tend to infinity to obtain the limit of BRM().
where tends to 0 when tends to infinity. Similarly, using the fact that and writing , one has for all ,
where also tends to 0. Then, it can be seen that:
where tends to 0 when tends to infinity. This implies that:
Let us now explicitely compute this expectation. Write the indicator vector (of which the coordinate equals when the state at time is and otherwise). One has the following relations: . Let us first look at the left part of the above limit:
Write the realization of the process until time . Recalling that is the state at time and is the indicator vector corresponding to , one has for all :
Let us consider the next identity. For ,
Eventually, the last identity is obtained by considering
Similarly, the second term on the right side of Equation (170) satisfies:
with
Gathering this and Equation (179), we see that the limit of expressed in Equation (170) equals:
C Proof of Proposition 9
To prove Proposition 9, we need the following technical lemma.
Forget the notations used so far. Let and be two forward recursions defined as
Assume that for any function we have thatThis is typically true if the index refers to a state sampled according to some stationary distribution, which is the case we are interested in.
Let also , and be the backward recursions defined as:
Proof The proof looks like the one of Proposition 6, but is a little bit more complicated. A key equality, to be applied repeatedly, is:
Another equality to be used repeatedly makes use of the “stationarity” assumption. For any we have:
These two identities can be used to work the term of interest:
The work on the second term is symmetric:
The proof of Proposition 9 is a simple application of the preceding technical lemma. By lemma 5, we have that
The result is then a direct application of lemma 13.