Full text
Vol.:(0123456789) Machine Learning (2022) 111:4217–4247 https://doi.org/10.1007/s10994-022-06242-4 1 3 A taxonomy forsimilarity metrics betweenMarkov decision processes JavierGarcía1 · ÁlvaroVisús2· FernandoFernández2 Received: 14 July 2021 / Revised: 13 May 2022 / Accepted: 8 September 2022 / Published online: 14 October 2022 © The Author(s) 2022 Abstract Although the notion of task similarity is potentially interesting in a wide range of areas such as curriculum learning or automated planning, it has mostly been tied to transfer learning. Transfer is based on the idea of reusing the knowledge acquired in the learning of a set of source tasks to a new learning process in a target task, assuming that the target and source tasks are close enough. In recent years, transfer learning has succeeded in making reinforcement learning (RL) algorithms more efficient (e.g., by reducing the number of samples needed to achieve (near-)optimal performance). Transfer in RL is based on the core concept of similarity: whenever the tasks are similar, the transferred knowledge can be reused to solve the target task and significantly improve the learning performance. Therefore, the selection of good metrics to measure these similarities is a critical aspect when building transfer RL algorithms, especially when this knowledge is transferred from simulation to the real world. In the literature, there are many metrics to measure the similarity between MDPs, hence, many definitions of similarity or its complement distance have been considered. In this paper, we propose a categorization of these metrics and analyze the definitions of similarity proposed so far, taking into account such categorization. We also follow this taxonomy to survey the existing literature, as well as suggesting future directions for the construction of new metrics. Keywords Markov decision processes· Similarity metrics· Transfer learning Editor: Kurt Driessens. * Javier García franciscojavier[email protected] Álvaro Visús a[email protected] Fernando Fernández ffer[email protected] 1 Departamento de Electrónica y Computación, Universidad de Santiago de Compostela, SantiagodeCompostela, Spain 2 Departamento de Informática, Universidad Carlos III de Madrid, Leganés, Spain
4218 Machine Learning (2022) 111:4217–4247 1 3 1 Introduction Markov decision processes (MDPs) are a common way of encoding decision-making problems in Reinforcement Learning (RL) tasks(Sutton and Barto, 2011). In RL, an MDP is considered to be solved when a policy (i.e., a way of behaving for each state) has been discovered which maximizes the long-term expected return. However, although RL is known as an effective machine learning technique, it might perform poorly in complex problems, leading to a slow rate of convergence. This issue magnifies when facing realistic continuous problems where the curse of dimensionality is inevitable. Transfer learning in RL is a successful technique to remedy such a problem. Specifically, rather than learning a new policy for every MDP, a policy could be learned on one MDP, then transferred to another, similar MDP, and either used as is, or treated as a starting point from which to learn the new policy. Clearly, this transfer cannot be done successfully between any two MDPs, but only in the case they are similar. Therefore, in this context, one question arises: when are two MDPs similar? In this paper, we consider the concept of similar to be related to the notion of “positive transfer”(Taylor and Stone, 2009). Formally, positive transfer happens when the knowledge in the source task contributes to the improved performance of learning in the target task, and it is considered a negative transfer otherwise, i.e., when the transfer hurts the learning performance when compared with learning from scratch. Additionally, the greater the improvement in the target task, i.e., the greater the positive transfer, the more similar the tasks have to be considered. It is important to be aware of the fact that, based on this description, the concept of similarity might not be related to the structural similarities between the MDPs. So the correct selection of metrics that allows us to measure the similarity between MDPs is a critical issue in transfer learning, precisely to avoid the negative transfer. Obviously, the use of the positive transfer to measure the similarity between two tasks has a major drawback: the similarity measure between MDPs is obtained after the transfer has been run, when really the ideal would be to compute this similarity before it, particularly if the point is to use the task similarity measure to choose a task to use in transfer. This issue magnifies when the transfer happens between simulation and the real world, where it is imperative for the efficient and safe deployment of previously learned knowledge. The literature in transfer learning has proposed different metrics to measure the level of similarity between MDPs, hence, different definitions of the concept of similarity have been considered so far. This paper surveys the existing task similarity metrics and contributes a taxonomy that, in its roots, classifies them into two clearly distinct categories: model-based, and performance-based metrics. We consider such a distinction as a core contribution, allowing us to categorize metrics in a novel and useful way. Model-based metrics are based on the structural similarities between the MDP models. Such model-based metrics can be computed in different ways depending on what elements of the MDP models come into play to compute the similarity(Ammar etal., 2014; Taylor etal., 2008c; Milner, 1982; Castro and Precup, 2011; Svetlik etal., 2017). The major strength of these approaches lies in that they can be computed a priori, i.e., before the transfer happens. Therefore, they are independent of the transfer algorithm that is later used to transfer knowledge from one task to another. However, most of them require to know in advance the exact MDP models or accurate approximations of them. Instead, performance-based metrics are computed by comparing the performance of the learning agents in the source task and the target task. Such a performance
4219 Machine Learning (2022) 111:4217–4247 1 3 comparison can be done in two different ways: by comparing the resulting policies from learning in the source task and the target task (Carroll and Seppi, 2005; Karimpanal and Bouffanais, 2018) or, from a transfer point of view, by measuring the transfer gain, i.e., the positive transfer(Mahmud etal., 2013; Sinapov etal., 2015; Fernández and Veloso, 2013). Many metrics can be used to measure such a transfer gain (e.g., jumpstart, asymptotic performance, total reward)(Taylor and Stone, 2009). In some ways, this transfer gain could be the best method for measuring similarity between two tasks (Carroll and Seppi, 2005). Unfortunately, it is often difficult to compute all of these performance-based measures before actually solving the target task, since most of them require to be computed a posteriori, i.e., after the learning processes. However, there are a few exceptions to this rule, within which, for example, the similarity is computed on-line, i.e., during solving the target task(Fernández and Veloso, 2013). Therefore, it is important to bear in mind that, despite their different nature, both model-based and performance-based metrics allow us to measure the similarity between tasks. This survey aims to categorize and discuss the main lines of current research within the computation of similarity metrics between MDPs. Our main purpose is to highlight the advantages and disadvantages of the surveyed metrics, making it easier to identify crossing points and open problems for which research communities could merge their expertise to work on, bridging the gap between the literature and the application of all of these metrics in real-world complex problems. To the best of our knowledge, this is the first survey focused on similarity metrics between MDPs. Previously, Lan etal. (2021) published an extraordinary paper surveying and proposing new similarity metrics, but it is focused on metrics between states and not between MDPs, which is the real purpose of this paper. In other words, Lan etal. (2021) focus on state similarity, whilst this paper focuses on task similarity. Nevertheless, the metrics presented by Lan etal. (2021) are discussed here as a good starting point to compose similarity metrics between MDPs. We hope our taxonomy applies to a wide range of researchers, not just those interested in transfer learning. For example, the proposed metrics could also be a critical step forward to sort the samples and tasks in Curriculum Learning(Narvekar etal., 2020), or could be used to measure the distance between simulation and the real world in a Sim-to-Real context(Zhao etal., 2020). They could also be used to understand the similarities within a set of tasks in Multitask Learning(Shui etal., 2019), or Automated Planning (Fernández etal, 2011). Since different audiences are expected to read this survey, the following guide provides forward references to key insights and sections for target groups with different needs and motivations: – If you are familiarized with the main concepts of RL and transfer learning, you can skip Sect.2 and go directly to Sect.3. – If you are interested in just an overview of the similarity metrics and how they are organized, go to Sect.3. – If you are interested in a deep understanding of the different approaches, you will need to read Sects.4 and 5 . – If you want a comparative analysis about what is the best method to use for a specific task, you will find your answer in Sect.6. – If you are interested in this area and willing to go forward, see Sect.7 to see the future directions.
4220 Machine Learning (2022) 111:4217–4247 1 3 2 Background This section introduces key concepts required to better understand the rest of the paper. First, some background in RL is introduced (Sect. 2.1), then the main concepts of RL transfer are visited (Sect.2.2), and finally the concepts of similarity and distance (Sect.2.3). 2.1 Reinforcement learning Typically, RL tasks are described as Markov Decision Processes (MDPs) represented by tuples in the form M=⟨S,A,T,R⟩ , where S is the state space, A is the action space, T∶S×A → S is the transition function between states, and R∶S×A → ℝ is the reward function(Sutton and Barto, 2011). At each step, the agent is able to observe the current state, and choose an action according to its policy 𝜋∶S → A . The goal of the RL agent is to learn an optimal policy 𝜋∗ that maximizes the return J(𝜋) : where rk is the immediate reward obtained by the agent on step k, 𝛾 is the discount factor, which determines how relevant the future is (with 0≤𝛾≤1 ), and K is a final time step for finite-horizon models (including the possibility of K=∞ and 0 ≤ 𝛾<1 for infinite-horizon models). On the one hand, if the task is an episodic task, the interaction between the agent and the environment tends to be divided into episodes. In finite- and infinite-horizon episodic tasks, an episode always ends when reaching a terminal state but, for finite-horizon tasks, it also ends when a fixed number of steps K has passed. On the other hand, a task can be infinity-horizon continuing, which means the task will never end. With the goal of learning the policy 𝜋 , Temporal Differences methods(Sutton and Barto, 2011) estimate the sum of rewards represented in Eq.(1). The function that estimates the sum of rewards, i.e., the return for each state s given the policy 𝜋 is called the value-function V𝜋(s)=E[J(𝜋)|s0=s] . Similarly, the action-value function Q𝜋(s,a)=E[J(𝜋)|s0=s,a0=a] is the estimation of the value of performing a given action a at a state s being 𝜋 the policy followed. The corresponding value function and action-value function for the optimal policy 𝜋∗ are denoted respectively V∗ and Q∗ . The Q-learning algorithm(Watkins, 1989) is one of the most widely used for computing the action-value function. In small domains with a small number of states and actions, the Q𝜋 function and 𝜋 can be fully represented with a lookup table. However, as the state and action spaces grow, a different approach is required. One way to extend the Q𝜋 function to continuous state-action space, is to discretize the environment in order to reduce such space(García etal., 2010), thus the use of a tabular representation of Q𝜋 is still possible. However, in such continuous scenarios, both V𝜋 and Q𝜋 functions are typically estimated using a universal function approximation such as an artificial neural network(Wiering and van Otterlo, 2014). In this case, the value function is expressed as a linear V𝜋(s)=𝜃T𝜙(s) or non-linear V𝜋(s)=V𝜋(𝜙(s),𝜃) combination of a parameter vector 𝜃 and a feature vector 𝜙(s) . Equivalently, the Q𝜋 function can also be expressed in terms of 𝜃 and 𝜙 (VanHasselt, 2012). (1) J (𝜋)= K ∑ k=0 𝛾kr k
4221 Machine Learning (2022) 111:4217–4247 1 3 2.2 Transfer learning forreinforcement learning In the transfer learning scenario we assume there is an agent who previously has addressed a set of source tasks represented as a sequence of MDPs, M1,…,Mn . If these tasks are somehow “similar” to a new task Mn+1 , then it seems reasonable the agent uses the acquired knowledge solving M1,…,Mn to solve the new task Mn+1 faster than it would be able to from scratch. Transfer learning is the problem of how to obtain, represent and, ultimately, use the previous knowledge of an agent(Torrey and Shavlik, 2010; Taylor and Stone, 2009). However, transferring knowledge is not an easy endeavour. On the one hand, we can distinguish different transfer settings depending on whether the source and the target tasks share or not the state and action spaces, the transition probabilities and the reward functions. It is common to assume that the tasks share the state space and the action set, but differing the transition probabilities and/or reward functions. However, in case the tasks do not share the state and/or the action spaces, it is required to build mapping functions, XS(st)=ss , XA(at)=as , able to map a state st or action at in the target task to a state ss or action as in the source task. Such mapping functions require not only knowing if two tasks are related, but how they are related, which means an added difficulty. On the other hand, it is required to select what type of information is going to be transferred. Different types of information have been transferred so far ranging from instance transfer (a set of samples collected in the source task) to policy transfer (i.e., the policy 𝜋 learned in the source task). Nor is this a simple task, because depending on how much and how the source and the target tasks are related, it could be transferred one type of information or another. Finally, the most “similar” task among M1,…,Mn to solve Mn+1 should be selected in the hope that it produces the most positive transfer. For this purpose, similarity metrics could be used, which translate into a measurable quantity of how related two tasks are. 2.3 Similarity anddistance metrics Similarity metrics are a very important part of transfer learning, as they provide a measure of distance between tasks. A similarity function s( ⋅ , ⋅ ) , or its complementary distance function d( ⋅ , ⋅ ) , is a mathematical function that assigns a numerical value to each pair of concepts or objects in a given domain. This value measures how similar these two concepts or objects are: if they are very similar, it is assigned a very low distance, and if they are very dissimilar, it is assigned a larger distance(Ontañón, 2020). Intuitively, for each distance function d( ⋅ , ⋅ ) we can define its associated similarity function s( ⋅ , ⋅ )=u∕(1+d( ⋅ , ⋅ )) , where u is the maximum similarity value, usually u=1 . For simplicity, in this survey we use the distance function d( ⋅ , ⋅ ) to formulate the distance between MDPs, knowing that this distance also captures the similarity between tasks. 3 Taxonomy ofsimilarity metrics forMDPs We consider there are two tasks, Mi and Mj , described formally by the tuples Mi=⟨Si,Ai,Ti,Ri⟩ and Mj=⟨Sj,Aj,Tj,Rj⟩ , where they could share (or not) the state space, the action space, or the transition and reward dynamics.
4222 Machine Learning (2022) 111:4217–4247 1 3 Definition 1 Given two tasks Mi and Mj , we define a task distance metric as a heuristic function d(Mi,Mj) → [0, ∞) , such that if d(Mi,Mj)<d(Mk,Mj) , then Mi is considered more similar to Mj than Mk .1 Definition1 allows us to use the function d( ⋅ , ⋅ ) to obtain a partial order between tasks in such a way that we can select the more similar one. Ideally, the concept of similarity should be related to the concept of positive transfer: the smaller the distance d(Mi,Mj) , the greater the positive transfer. However, in most of the cases, similarity metrics do not provide guarantees for this ideal behavior. Additionally, d(Mi,Mj) should be computed before or, at least, during the transfer experiment, in order to select an adequate task to use in transfer. However, the literature proposes different ways to compute d(Mi,Mj) . In this paper, we consider two main trends for the computation of the distance metric d(Mi,Mj) . Such trends are depicted in Table1. The first one measures the structural or model similarities between the given MDPs. The second measures the similarities by using the performance of the learning agent in both the source and the target tasks. Model-Based Metrics As regards to the first, they measure the degree of similarity between a source and a target task by using their corresponding MDP models (i.e., states, actions, transition and rewards dynamics). There are several alternatives to these modelbased metrics depending on what components of the MDPs are taken into account. In this survey, we categorize these metrics in four groups: (i) transition and reward dynamics, (ii) transitions, (iii) state and actions and (iv) states: • Transition and reward dynamics They require complete knowledge of the MDP models both of the source task and the target task. We distinguish three ways of computing similarity metrics using such a complete knowledge: (i) by a sort of metrics based on state abstraction (or state aggregation) techniques(Li etal., 2006; Ferns etal., 2004, 2012; Castro, 2020), (ii) by compliance metrics(Lazaric etal., 2008; Lazaric, 2008; Fachantidis etal., 2015; Fachantidis, 2016) and (iii) by metrics based on the construction of MDP graphs(Kuhlmann and Stone, 2007; Wang etal., 2019). – State abstraction In RL, it is a common practice to aggregate states in order to obtain an abstract description of the problem, i.e., a more compact and easier representation of the task to work with(Giunchiglia and Walsh, 1992; Li etal., 2006). These approaches are based on the same common principle: if a number of states are considered to be similar, they can be aggregated as a single one. This same principle can be also used to compute the similarity between two states belonging to different MDPs. In fact, the cumulative similarity between each pair of these states could be used to compute a sort of similarity metric between the MDPs. In this paper, we survey two of these methods which actually have been used for transfer in RL: bisimulation(Ferns etal., 2004, 2012; Castro and Precup, 2011; Song etal., 2016), and homomorphism(Ravindran and Barto, 2002; Sorg and Singh, 2009), where both of them require complete knowledge or accurate approximations of the MDP models to compute the similarity between states. Although only bisimulation 1 It should be noted that in the context of task similarity such a measure of distance need does not need to be a “metric” in the mathematical sense of this term, but it needs to allow us to define a partial order between tasks.
4223 Machine Learning (2022) 111:4217–4247 1 3 Table 1 Taxonomy and summary of the similarity metrics considered in this survey
4224 Machine Learning (2022) 111:4217–4247 1 3 and homomorphism are discussed in detail in this paper, we consider other state abstraction techniques might be also used as similarity metrics between MDPs. – Compliance The compliance measure is defined as the probability of a sample ⟨s,a,s′ ,r⟩ in the target task of being generated in the source task(Lazaric etal., 2008; Fachantidis, 2016; Fachantidis etal., 2015). Therefore, it is easy to deduce that the compliance between the entire target task and the entire source task allows us to measure the similarity between the two tasks. – MDP graphs. They are based on the construction of graphs that represent the transition and the reward functions both of the source task and the target task(Kuhlmann and Stone, 2007; Liu and Stone, 2006; Wang etal., 2019). Then, they find structural similarities between tasks based on graph-similarity or graph-matching algorithms. Such approaches are based on an interesting idea for similarity computation: the alternative representation of tasks through descriptive structures that allow an easy comparison between them. • Transitions The metrics considered in this category use tuples in the form ⟨s , a , s′⟩ to measure the similarity between MDPs(Taylor etal., 2008c; Ammar etal., 2014). By using such tuples, they model the behavioral dynamics of the two MDPs to be compared, and then they try to find differences between them. • Rewards The metrics considered in this category use tuples in the form ⟨s , a , r⟩ to measure the similarity between MDPs. This set includes different techniques (Carroll and Seppi, 2005; Tao etal, 2021; Gleave etal, 2020). • State & actions These metrics use pairs in the form ⟨s,a⟩ both in the source task and the target task to compute the similarity between MDPs. Such pairs can be used in different ways resulting in different similarity metrics (Carroll and Seppi, 2005; Taylor etal, 2008b; Narayan and Leong, 2019). • States Finally, metrics in this category use the state space both in the source and the target task to compute the similarity between them(Svetlik etal., 2017). Another area of research that is relevant in this category is that of case-based reasoning (CBR)(Aamodt and Plaza, 1994). RL approaches based on CBR use a similarity function between the states in the target task and the states stored in a case base corresponding to a previous source task(CelibertoJr etal., 2011). Such similarity function could be used to measure the similarity between the state spaces, hence, the similarity between the two tasks. Performance Based. As regards the second major category in the proposed taxonomy, performance-based metrics are based on the performance of the agents in the source task and the target task, where this performance can be related to the policies themselves learned by the agents in these tasks, or to the transfer gain an agent obtains reusing the knowledge of a source task in a target task. So, we distinguish two different approaches to overcoming the problem of computing such performance-based similarities: (i) by the policy similarity and (ii) by the transfer gain obtained transferring the knowledge from a source task to the target task. – Policy similarity They are based on the use of the learned value function V𝜋 or the action-value function Q𝜋 , or equivalently, on the behavioral policies 𝜋 obtained in the source task and the target task. Therefore, these metrics require the full (or partial) learning of these policies before the computation of the similarity between tasks. Such a comparison can be conducted in two different ways depending on what is being compared: (i) the policy values, or (ii) the policy parameters.
4225 Machine Learning (2022) 111:4217–4247 1 3 – Policy values In this case, the comparison is conducted by observing the specific values of the Q𝜋 -function or the V𝜋 -function corresponding to the source and the target tasks (Carroll and Seppi, 2005; Zhou and Yang, 2020). Therefore, in this case, it is really being measured the degree of similarity of the policies obtained in both tasks. – Policy parameters. In RL, the value function V𝜋 or the action-value function Q𝜋 usually are represented as a parameter vector 𝜃 . Intuitively, the metrics within this category compare the particular weights of the parameter vectors corresponding to the value functions of the source task and the target task in order to measure the similarity between them(Karimpanal and Bouffanais, 2018). Therefore, these metrics are only applicable with parametric representations of policies, and not with tabular representations. Such an approach opens the door to the comparison of other policy representations(Ferrante etal., 2008). – Transfer gain In these techniques, the level of similarity is an approximation to the advantage gained by using the knowledge in one source task to speed the learning of another target task (Carroll and Seppi, 2005; Carroll, 2005; Taylor and Stone, 2009). So, it is important to bear in mind that these metrics actually require that the transfer experiment be entirely or partially run before measuring the degree of similarity between tasks. Many metrics to measure such a transfer gain are possible, including jumpstart, asymptotic performance, total reward (see(Taylor and Stone, 2009) for a complete listing of metrics for transfer gain). However, regardless of the particular technique used to compute such a transfer gain, the higher the transfer gain, the greater the similarity between the tasks. In this paper, we distinguish two approaches within this category depending on whether the transfer gain is computed after or during the transfer process: (i) off-line transfer gain, and (ii) on-line transfer gain. – Off-line transfer gain The transfer gain is estimated as the difference in performance between the learning process with and without transfer (Carroll, 2005; Mahmud etal., 2013; Sinapov etal., 2015). Therefore, it is important to be aware of the fact that, in these approaches, the gain is computed once the learning processes are considered to be finished. – On-line transfer gain On the contrary, in these approaches, the gain is estimated on-line at the same time that the policy in the target task is computed(Azar etal., 2013; Fernández and Veloso, 2013; Li and Zhang, 2017). In this way, it is possible to decide on-line which is the closest task within a library composed of past tasks, so that the knowledge of the selected closest task can have a greater influence on learning about the policy in the new task. 4 Model‑based metrics This section presents in detail the model-based metrics considered in this paper, i.e., the metrics that evaluate the similarity between tasks using the components of their respective MDPs. As presented in Sect.2.1, the structure of an MDP is formally described by a tuple ⟨S,A,T,R⟩ . Different model-based metrics result depending on what components of the MDPs take part in the computation of the similarity. Therefore, this survey categorizes the model-based metrics in five groups: (i) transition and reward dynamics, (ii) transitions, (iii) rewards, (iv) state and actions and (v) states.
4232 Machine Learning (2022) 111:4217–4247 1 3 is composed of two steps. First, transitions from an offline dataset are used to convert reward functions to a canonical form. This canonical form is invariant to reward transformations that do not affect the optimal policy. Second, the correlation between reward values on transition samples is computed, yielding a metric capturing reward function similarity. A significant drawback of this approach is that it evaluates the rewards on transitions between all state-state combinations, regardless of whether such state-state combinations are possible in a transition or not, which in practice leads to unreliable reward values as these are outside the distribution of the transitions. For this reason, some recent works have focused on improving the EPIC metric by making it consider only feasible state transitions(Wulfe etal., 2022). In any case, although the metrics in this category may function correctly in some particular cases, in others it is not a good approximation of the similarity between tasks(Carroll and Seppi, 2005). As a way of example, imagine two mazes, with the goal in different locations, but with everything else left the same. In both tasks, the agent receives a reward of 1 if it reaches the goal, -1 if it hits an obstacle, and 0 elsewhere. These metrics will consider as equally similar to two mazes where the goals are in close positions or in very different positions. These metrics cannot capture the distance that a goal is moved. However, it can easily capture the fact that new obstacles or goals have been added to the tasks. Similarity metrics based on the reward functions can be computed before the policy is learned but in general they are less sensitive to policy trends than those based on policy values(Carroll and Seppi, 2005). 4.4 State andaction spaces In this case, the distance between MDPs is computed as the distance between the stateaction pairs ⟨s , a⟩ both in the source and the target tasks. Definition 10 Given two MDPs Mi and Mj , and their corresponding state-action spaces, Si×Ai and Sj×Aj , we define the distance as d(Mi , Mj)= d ( S i× A i ,S j× A j) . For instance, Narayan and Leong (2019) compute this distance as the difference between the corresponding state-action transition distributions between the two tasks. In particular, the proposed metric is based on the Jensen-Shannon Distance (JSD) which measures the difference between two probability distributions(Nielsen, 2019). The distance d(Mi,Mj) is computed as the averaged JSD over all the state-action pairs in order to composite a distance between both tasks. Instead, Taylor etal (2008b) compute the Euclidean distance between state-action pairs in the source and the target tasks. This work is not focused on the construction of a distance measure between MDPs, but such Euclidean distances between all the state-action pairs could be composited to obtain a sort of similarity metric. 4.5 States When comparing closely related tasks, it may be sufficient to use only the state space. The metrics in this category use precisely the state space in both the source and the target tasks to compute the similarity between them.
4233 Machine Learning (2022) 111:4217–4247 1 3 Definition 11 Given two MDPs Mi and Mj , we can define the distance between them as d(Mi,Mj)=d(Si,Sj) , where d(Si,Sj) measures the distance between Si and Sj . Svetlik etal. (2017) propose to compute d(Si,Sj) as described in Eq.(10): Equation10 compute d(Si,Sj) as the relation between the applicability of the value function (measured as the number of states in Mi that also appears in Mj ), and the experience required to learn in Mj (measured as the difference of size between Sj and Si ). Another area of research that is relevant in this category is that of case-based reasoning (CBR)(Aamodt and Plaza, 1994). CBR uses the knowledge of previous cases to solve new problems, by comparing the actual state to the previous ones, and finding the closest. This results in an action that was already used to solve a very similar case, and therefore it must be useful. RL approaches based on CBR use a similarity function between the states in the target task and the states stored in a case base corresponding to a previous source task(CelibertoJr etal., 2011; Bianchi etal., 2009). Such similarity function could be used to measure the similarity between the state spaces, hence, the similarity between the two tasks. 5 Performance‑based metrics The metrics proposed in the second major category of this survey evaluate the similarity between tasks by either comparing policies, or by comparing the performance of the agent in the source and the target tasks. So, we distinguish two different approaches to overcoming the problem of computing such performance-based similarities: (i) by the policy similarity and (ii) by the transfer gain obtained transferring the knowledge from a source task to the target task. 5.1 Policy similarity These approaches measure the similarity between MDPs by comparing the learned value function V𝜋 or the action-value function Q𝜋 , hence, the behavioral policies 𝜋 obtained in the source and the target tasks. Therefore, these metrics require the full (or partial) learning of these policies before the computation of the similarity between tasks. Such a comparison can be conducted in two different ways depending on what is being compared: (i) the policy values, or (ii) the policy parameters. 5.1.1 Policy values One approach to compare the similarity between MDPs is by comparing the specific q-val- ues or v-values of their respective value or action-value functions. The approaches in this category aim to capture the difference between the policy trends in two MDPs. The more the policies of the two tasks overlap, the more similar the two tasks become. (10) d (Si,Sj)= |S i |∩|S j | 1+ | S j| − | S i|
4234 Machine Learning (2022) 111:4217–4247 1 3 Definition 12 Given two tasks Mi and Mj and the q-values of Q𝜋i and Q𝜋j learned in these tasks, we define d(Mi,Mj)=d(Q𝜋 i ,Q𝜋 j ) . This metric is transformed into d(Mi,Mj)=d(V𝜋 i ,V𝜋 j ) if V𝜋i and V𝜋j are computed instead. Carroll and Seppi (2005) propose to compute d(V𝜋 i ,V𝜋 j ) as the number of states in Mi and Mj with identical maximum v-value. The most obvious problem with this distance is that it is overly restrictive: it requires two states with exactly the same v-value to consider an overlap, which is not often realistic. Carroll and Seppi (2005) also propose to compute d(Q𝜋 i ,Q𝜋 j ) as described in Eq.(11): where n is the total number of state-action pairs in the source and the target task, and which is less restrictive than d(V𝜋 i ,V𝜋 j ) . Carroll and Seppi (2005) demonstrate that these similarity metrics are only accurate after the q-values or v-values have been learned. Additionally, similarity metrics based on the number of states with maximum v-value requires the task to be more thoroughly learned than those based on the mean squared error of the q-values. Instead,(Zhou and Yang, 2020) compute d(Q𝜋 i ,Q𝜋 j ) deriving latent structures of tasks and finding matches between Q𝜋i and Q𝜋j . Finally, Serrano etal.(2021) compute the similarity between tasks with different but discrete state-action spaces by analyzing the differences between Q𝜋i and Q𝜋j . In particular, they identify pairs of state-action pairs that perform similar roles in their respective task, based on their Q-values. Other works also make use of the action-value function Q𝜋 to compute whether two states are similar, but they focus on state abstractions (i.e., on aggregating similar states belonging to the same MDP) and not on the definition of similarity metrics between different MDPs. For instance, Li etal. (2006) present some abstractions which consider that two states s1,s2∈S in an MDP M , can be aggregated if the condition in Eq.(12) is fulfilled. In Eq.(12), if 𝜂=0 we can obtain different forms of exact abstractions depending on the choice of f: Q𝜋 ( Q𝜋 -irrelevance), Q∗ ( Q∗ -irrelevance), or maxAQ∗ ( a∗ -irrelevance). However, similarly to the distance d(V𝜋 i ,V𝜋 j ) proposed by Carroll and Seppi (2005), exact abstractions fail to find opportunities for abstraction in tasks where no two situations are exactly alike. For this reason, Abel etal. (2016) investigate approximate state abstractions, which treat nearly-identical situations as equivalent, and where 𝜂≥0 and f is Q∗ . From these abstractions, we can construct discrete metrics from any state aggregation as d(s1,s2)=0 if Eq.(12) is fulfilled, and d(s1,s2)=1 otherwise. In a similar line of research, Lan etal. (2021) present different value-based metrics for computing the similarity between states. The metric d(s1,s2)=maxa∈A|Q∗(s1,a)−Q∗(s2,a)| is a representative of such value-based metrics. It shares the same fundamentals of the policy irrelevance abstraction proposed by Jong and Stone (2005) which consider that two states can be aggregated if they have the same optimal action. Although all of these metrics have been proposed as distances between two states, they could also be used to calculate the distance between two MDPs as described in Sect.4.1.1. (11) d (Q𝜋i,Q𝜋j)= 1 n ∑ s∈S ∑ a∈A (Q𝜋i(s,a)−Q𝜋j(s,a)) 2 (12) ∀a|f(s1,a)−f(s2,a)|≤𝜂
4235 Machine Learning (2022) 111:4217–4247 1 3 5.1.2 Policy approximation parameters This section considers the value function is approximated by V𝜋(𝜙(s),𝜃)≈V𝜋(s) , where 𝜃 denotes an adaptable parameter vector, 𝜙(s) is the feature vector of state s, and V𝜋 may be a linear (e.g., linear combination of features) or a non-linear function (e.g., a neural network)(VanHasselt, 2012). The action-value function Q𝜋 can be expressed in similar parameterized terms, Q𝜋(𝜙(s,a),𝜃)≈Q𝜋(s,a) . The metrics within this category compare the particular weights of the parameter vectors 𝜃 corresponding to the value functions V𝜋 or Q𝜋 of the source task and the target task in order to measure the similarity between them. Such metrics reflect the authors intuition that two tasks are more likely to be similar to each other if they have similar parameter vectors. Definition 13 Given two tasks Mi and Mj and the parameterize functions Q𝜃 i ≈Q𝜋i and Q𝜃 j ≈Q𝜋j learned in these tasks, we consider d(Mi,Mj)=d(𝜃i,𝜃j) .3 The same definition applies if it is used the value functions V𝜋i and V𝜋j instead of the action-value functions Q𝜋i and Q𝜋j . For instance, Karimpanal and Bouffanais (2018) compute the distance d(𝜃i,𝜃j) as described in Eq.(13): i.e., by using the cosine similarity between two non-zero vectors. Karimpanal and Bouffanais (2018) demonstrate the better the estimate of the agent’s parameter vector, the more accurate the distance d(Mi , Mj) . The cosine similarity has some advantages, such as boundedness and the ability to handle parameter vectors 𝜃 with largely different magnitudes. However, Karimpanal and Bouffanais (2018) focused on linear function approximation. Computing the similarity between parameter vectors presents particular challenges for non-linear function approximations, such as neural networks, where neurons could learn the same information at different positions in different runs, and still have identical behaviors. Therefore, the design of d(𝜃i,𝜃j) should consider that two parameter vectors are similar if they lead to similar behaviors, regardless of the magnitude of the weights, or possible shuffled vectors. Some metrics have been proposed to measure the distance between neural networks(Ashmore, 2015), but they require further investigation in the context of task similarity. Anyway, we consider that this alternative representation of policies as parameter vectors opens the door to the comparison of other policy representations(Ferrante etal., 2008). 5.2 Transfer gain One possible metric to measure the similarity between two MDPs is an approximation to the advantage gained by using one source task to speed up the learning of another target task, which is commonly known as transfer gain (Carroll and Seppi, 2005; Carroll, 2005; Taylor and Stone, 2009). (13) c 𝜃i,𝜃j = 𝜽 i⋅ 𝜽 j | 𝜃 i|| 𝜃 j| 3 For simplicity, we write Q𝜃 as an abbreviation for Q𝜋(𝜙(s,a),𝜃) .
4236 Machine Learning (2022) 111:4217–4247 1 3 Definition 14 Given two tasks Mi and Mj , and g(Mi , Mj) which denotes the gain of transferring the knowledge learned in Mi to Mj , we can consider d(Mi,Mj) as inversely related to g(Mi , Mj) . Many forms to measure the advantage g(Mi , Mj) are possible. Some of them are graphically represented in Fig.2: • Jumpstart The performance at the initial steps of the learning process of an agent learning Mj may be improved by transfer from Mi . • Asymptotic performance The final learned performance of an agent learning Mj may also be improved by transfer from Mi . • Total reward The total reward accumulated by an agent learning Mj with transfer from Mi , may be improved if it uses transfer, compared to learning without transfer. • Average reward The average reward received within some window of time by an agent learning Mj with transfer from Mi may also be improved. • Time to convergence It is expected for a transfer learner to reach the asymptotic performance earlier than another non-transfer learner. Regardless of the particular technique used to compute g(Mi , Mj) , the higher the transfer gain, the greater the similarity between the tasks. While there is a general consensus that g(Mi , Mj) is the best similarity metric between tasks (Carroll, 2005; Carroll and Seppi, 2005), since it allows to accurately measure positive transfer, it actually also requires that the transfer experiment be entirely or partially run before measuring the degree of similarity between tasks. This fact precludes its use in tasks where it is mandatory to know the similarity between tasks before the transfer experiment takes place. In this paper, we distinguish two approaches within this category depending on whether the transfer gain is computed after or during the transfer process: (i) off-line transfer gain, and (ii) on-line transfer gain. Fig. 2 Different metrics for measuring the transfer gain, g(Mi , Mj) . This graph show benefits to the jumpstart, time to convergence, total reward, average reward received within some window of time, and asymptotic performance
4237 Machine Learning (2022) 111:4217–4247 1 3 5.2.1 Off‑line transfer gain In this case, the transfer gain g(Mi,Mj) is estimated as the difference in performance between the learning process with and without transfer, and once the learning processes are considered to be finished(Carroll, 2005; Mahmud etal., 2013; Sinapov etal., 2015; Zhan etal., 2016). Such gain g(Mi,Mj) can be computed as the jumpstart(Sinapov etal., 2015; Carroll, 2005), the time to convergence(Carroll, 2005), the asymptotic performance(Mahmud etal., 2013), although other metrics such as the total reward or the transfer ratio could be also used(Taylor and Stone, 2009). 5.2.2 On‑line transfer gain On the contrary, in these approaches, the transfer gain is estimated on-line while the policy in the target task is computed(Fernández and Veloso, 2013; Azar etal., 2013; Li and Zhang, 2017). It is important to bear in mind that the on-line computation of this gain only makes sense if during the learning process we have several transfer sources to choose from. At the beginning of the learning process, these approaches have at their disposal the knowledge learned in solving a set of previous tasks {M1,…,Mn} to learn the new task Mj . During learning, they compute g(Mi,Mj) of each past task Mi∈{M1,…,Mn} . To do that, they transfer the knowledge acquired solving Mi to Mj during a limited number of episodes m. Then, g(Mi,Mj) is computed as the average reward obtained during those m episodes(Fernández and Veloso, 2013; Azar etal., 2013). Once all gains are computed, it is possible to decide on-line which is the closest task to Mj within {M1,…,Mn} , so that the knowledge of the selected closest task can have a greater influence on learning about the policy in Mj . 6 Discussion From a transfer point of view, the ultimate goal of all similarity metrics is in some way to predict the relative advantage that would be gained by using a source task in a target task. The more similar the source and the target tasks are, the greater the positive transfer. However, there is probably no one best universal metric that works with all transfer techniques and problems. Since each metric can capture different types of similarity and each transfer technique induces different bias in the learning process, the question of selecting the best metric turns into finding the correct metric for a transfer technique to be applied to a particular problem. For this reason, in order to facilitate the selection of the best metric for a particular task, this section analyzes the distance metrics surveyed in this paper across five dimensions (Table2): (i) nature of the state-action space (denoted by Spaces in Table2), (ii) the required knowledge to compute the distance metric (denoted by Knowl.), (iii) allowed differences between the tasks (Differ.), (iv) the type of information that is transferred from the source tasks and the target tasks (Transfer), and (v) when the computation take places (Comp.). Table3 provides a key for the abbreviations in Table2. Furthermore, Table2 and the proposed discussion will serve to analyze the pros and cons of the categories surveyed.
4238 Machine Learning (2022) 111:4217–4247 1 3 6.1 State‑action space Obviously, the selection of the metric depends on the nature of the state-action space. Some approaches require a finite set of states and actions. This is particularly true in the Table 2 This table lists most of the metrics discussed in this survey and classifies each in terms of five dimensions. Use Table3 as key Citation Spaces Knowl. Differ. Transfer Comp. Category Section4: model-based Ferns etal. (2004)s/at,r - - bBisimulation Castro and Precup (2010)s/at,r s,t,r 𝜋 b Song etal. (2016)s/at,r s,t,r 𝜋 b Ferns etal. (2012)S/at,r - - b Castro etal. (2021)S/aI - - b Ravindran and Barto (2002)s/at,r - - bHomomorphism Ravindran and Barto (2003)s/at,r s,a,t,r 𝜋p b Sorg and Singh (2009)S/at,r s,a,t,r Q b Taylor etal. (2008a)s/at,r - - b Lazaric etal. (2008)S/At,r t,r I bCompliance Fachantidis (2016)S/At,r s,a,t,r I b Fachantidis etal. (2015)S/At,r s,a,t,r I b Wang etal. (2019)s/at,r t,r - bMDP graphs Liu and Stone (2006)s/at,r t,r V b Kuhlmann and Stone (2007)s/at,r t,r V b Ammar etal. (2014)S/AI s,a,t,r Q , 𝜃 bTransitions Taylor etal. (2008c)S/at s,a,t,r Q b Castro (2020)S/aI - - b Carroll and Seppi (2005)s/ar t,r Q , 𝜋 bRewards Tao etal. (2021)S/Ar t,r 𝜋 b Gleave etal. (2020)S/Ar t,r - b Narayan and Leong (2019)S/a s×a s,a,t,r 𝜋 b S & A Spaces Taylor etal. (2008b)S/a s×a s,a,t,r 𝜋 b Svetlik etal. (2017)s/a|s| s 𝜋 bStates CelibertoJr etal. (2011)S/As s,a,t,r 𝜋 b Section5: Performance-based Carroll (2005)s/a Q t,r Q , 𝜋 bPolicy values Zhou and Yang (2020)S/a Q rQ b Serrano etal. (2021) s/a Qs,a Q b Karimpanal and Bouffanais (2018)S/a Q r 𝜃 bPolicy param. Carroll and Seppi (2005)s/a ∑r , c t,r Q , 𝜋 aOffline transfer Mahmud etal. (2013)s/a V t,r 𝜋 a Sinapov etal. (2015)S/aj s Q a Fernández and Veloso (2013)S/a ∑r t,r 𝜋 dOnline transfer Fernández etal. (2010)S/a ∑ rs,a,t,r 𝜋 d Li and Zhang (2017)S/a ∑ rt,r 𝜋 d Azar etal. (2013)S/a ∑r t,r 𝜋 d
4239 Machine Learning (2022) 111:4217–4247 1 3 case of bisimulation and homomorphishm metrics. These metrics are expensive to compute and typically require enumerating all the states pairs even when using on-the-fly approximations(Comanici etal., 2012), sampling-based approximations(Ferns etal., 2012; Castro and Precup, 2010) or approximations using the structure in the state space(Bacci etal., 2013). Such full state enumeration is impractical for large state spaces, and impossible for continuous state spaces. Additionally, these metrics can be overly pessimistic in the sense that they consider worst-case differences between states, which is overly restrictive for many problems(Castro and Precup, 2010). Although there have been positive steps to circumvent these drawbacks(Castro, 2020; Zhang etal., 2021; Castro etal., 2021), bisimulation-based approaches compute distances between states (belonging to the same MDP or not), and few works have been proposed to compose these distances into a single distance between MDPs(Song etal., 2016). For this reason, significant work needs to be done to determine if such approaches are feasible in practice for this task. Metrics based on MDP graphs have similar limitations on the size of the state and action spaces(Wang and Liang, 2019; Kuhlmann and Stone, 2007; Liu and Stone, 2006). Although they are based on an interesting principle, at the moment all of these graph-based approaches have limited applications. On the one hand, they require MDPs with a finite number of states and actions that can be adequately represented as a graph. On the other hand, graphs are required to be small since the computation of graph similarity metrics is computationally demanding. Regarding the latter, the computation of these measures can be accelerated via parallelism, but such approaches need to be investigated in the context of similarity between MDPs. Table 3 Key that provides a reference to the abbreviations in Table2 Spaces Transfer s/S Finite/large state space 𝜋 Policies a/A Finite/large action space 𝜋p Partial policies (e.g., options) QAction-value function Knowl. VValue function t Transition function 𝜃 Policy parameters r Reward function I Experience instances I Experiences instances – For a purpose other than transfer (e.g., s×a State-action pairs state aggregation) s States |s| States and size of the state spaces Comp. Q/VAction-value or value function b Before transfer ∑r Average reward within some window of time a After transfer cTime to convergence d During transfer j Jumpstart Differ. s/a State/action spaces t/r Transition/reward functions - For a purpose other than similarity between tasks (e.g., state aggregation)
4240 Machine Learning (2022) 111:4217–4247 1 3 6.2 Required knowledge Another issue that needs to be addressed is what and how much information is required to compute the similarity between tasks. As can be seen in Table2, most model-based approaches require prior full information (or accurate approximations) about the transition and reward dynamics (Castro and Precup, 2010; Lazaric et al., 2008; Wang and Liang, 2019), or about the size of the state space(Svetlik etal., 2017). In this sense, performance-based metrics have a clear advantage over model-based ones: in general, performance-based metrics require less a priori information about the task to be solved, although as a counterpoint they need to fully or partially run the transfer experiment to obtain accurate approximations of the Q-function (Carroll, 2005; Carroll and Seppi, 2005; Zhou and Yang, 2020; Karimpanal and Bouffanais, 2018) or the V-function (Mahmud etal., 2013). In other cases, only the average cumulative reward obtained during a predetermined time window by the ongoing policy is required(Sinapov etal., 2015; Li and Zhang, 2017; Azar etal., 2013; Fernández and Veloso, 2013), which allows the fast computation of the similarity between tasks without the need to fully run the transfer experiment. In this dimension, the model-based approaches based on the structural comparison of the instances in the form ⟨s , a , s′⟩ gathered from the two tasks are highly attractive(Ammar etal., 2014). On the one hand, they are not computationally expensive because they do not need to approximate the dynamics of the environment, nor do they need to learn a behavior policy, just to gather instances in both tasks. On the other hand, the collection of these instances can be done with a random policy, but also with a safe suboptimal one. The latter is particularly interesting if we are dealing with tasks where random behaviors are not allowed or where a single bad action can lead to catastrophic consequences. In this same line of research, the approaches that only use partial information from the instances to carry out similar comparisons, such as state-action pairs ⟨s,a⟩ (Narayan and Leong, 2019; Taylor etal., 2008b), or simply the states ⟨s⟩ (Svetlik etal., 2017; CelibertoJr etal., 2011), are also interesting. However, in these cases, it is required a strong relationship between the tasks to be compared, which is either learned(Narayan and Leong, 2019; Taylor etal., 2008b) or taken for granted(Svetlik etal., 2017). As an example of the latter, Svetlik etal. (2017) assume that the only difference allowed between tasks is between the state spaces. 6.3 Allowed tasks differences Regarding the allowed tasks differences, distance metrics can be computed between tasks that have different transition and/or reward functions(Ferns etal., 2004; Castro and Precup, 2010; Song et al., 2016; Lazaric et al., 2008), and/or state-action spaces(Fachantidis etal., 2015; Fernández and Veloso, 2013). Most of the methods in Table2 require that both tasks have the same state-action space(Lazaric etal., 2008; Azar etal., 2013). However, the latter can be partially alleviated by the construction of inter-task mapping functions between state and/or action variables that allows translating a state si∈Si in one task to its equivalent state sj∈Sj in another tasks, XS(si)=sj , and an action ai∈Ai to its equivalent aj∈Aj , XA(ai)=aj . In some cases, the mappings functions XS and XA are explicitly provided(Fernández etal., 2010), but in other cases they are learned(Fachantidis etal., 2015; Taylor etal., 2008c). However, current
4241 Machine Learning (2022) 111:4217–4247 1 3 approaches for autonomously learning such mapping functions require domain knowledge or are inefficient. In this context, bisimulation and homomorphism metrics offer an interesting alternative to perform such a mapping between tasks. The mapping between the states of two MDPs is defined implicitly by the distance metric d( ⋅ , ⋅ ) as described in Definition2: for each state in one MDP, finding the most similar state in the other MDP is equivalent to mapping the states from one MDP to the other. Instead, homomorphisms allow correspondences to be defined between state-action pairs, rather than just states (Definition3). Therefore, one possibility is to allow the mapping to be determined automatically from bisimulation or homomorphism(Castro and Precup, 2010; Sorg and Singh, 2009). 6.4 Transferred knowledge Different kinds of knowledge may transfer better or worse depending on the similarity between the tasks. The surveyed papers in Table2 primarily transfer two types of knowledge: policies(Castro and Precup, 2010; Tao etal., 2021), and value functions(Sorg and Singh, 2009; Carroll, 2005; Ammar etal., 2014), and the type of knowledge transferred does not seem to depend on the way of computing the similarity between tasks. It should be noted that some approaches in Table2 are not explicitly used for measuring the similarity between tasks. This is the case of some bisimulation and homomorphism approaches which are focused on state aggregation, but, as discussed in Sect.4.1.1, they can be also used to measure the similarity between MDPs. 6.5 Computation This leads us to the following issue: the computation moment. Ideally, the computation of the similarity metric should be before or, at least, during the transfer. Off-line transfer gain approaches are undoubtedly the best method for measuring similarity between two tasks: they produce such a measure after the transfer experiment has been run, in such a way that we can compute the real gain. However, if the point is to use the task similarity measure to choose a task to use in transfer, these metrics are useless. In this case, model-based metrics have an advantage over performance-based metrics: they allow to compute the metrics before the transfer process. These metrics can be used to choose the most similar MDP before the transfer, but as far as we know there are no theoretical guarantees that the most similar MDP is similar enough to produce a positive transfer. By contrast, the metrics based on the on-line transfer gain are at the point halfway between both. They allow computing the similarity metric during transfer, so that depending on the similarity of the source task, it will introduce a greater or lesser exploration bias in the learning process of the new task. 7 Future directions The previous discussion points out several future directions. On the one hand, since there is no best metric, it would be useful to use several of them. For instance, modelbased metrics can be used to return a useful approximation of task similarity before the tasks are learned, although this measure can be adapted on-line during the learning