Lifelong Self-Adaptation: Self-Adaptation Meets Lifelong Machine Learning

In the past years, machine learning (ML) has become a popular approach to support self-adaptation. While ML techniques enable dealing with several problems in self-adaptation, such as scalable decision-making, they are also subject to inherent challenges. In this paper, we focus on one such challenge that is particularly important for self-adaptation: ML techniques are designed to deal with a set of predefined tasks associated with an operational domain; they have problems to deal with new emerging tasks, such as concept shift in input data that is used for learning. To tackle this challenge, we present \textit{lifelong self-adaptation}: a novel approach to self-adaptation that enhances self-adaptive systems that use ML techniques with a lifelong ML layer. The lifelong ML layer tracks the running system and its environment, associates this knowledge with the current tasks, identifies new tasks based on differentiations, and updates the learning models of the self-adaptive system accordingly. We present a reusable architecture for lifelong self-adaptation and apply it to the case of concept drift caused by unforeseen changes of the input data of a learning model that is used for decision-making in self-adaptation. We validate lifelong self-adaptation for two types of concept drift using two cases.


INTRODUCTION
Self-adaptation equips a software system with a feedback loop that monitors the system and its environment and applies changes to the system when needed to realize a set of adaptation goals [16,59]. Self-adaptation has been pivotal in automating tasks that otherwise need to be realized by operators [23,35], in particular tasks that are related to uncertainties that the system may face during its lifetime [20,30].
Over the past years, we have observed an increasing trend in the use of machine learning (ML in short) to support self-adaptation. A recent systematic literature review [26] shows that the number of articles published on this topic has been doubled every two years since 2014. For instance, ML has been used for efficient decision-making by reducing large adaption spaces [45], for detecting abnormalities in the flow of activities in the environment of the system [37], and for learning changes of the system utility dynamically [24]. While ML techniques enable dealing with several problems in software systems in general and self-adaptive systems in particular, these techniques are subject to several engineering challenges. Examples are the need for specialized expertise when constructing ML solutions, providing reliable and efficient testing of ML techniques, dealing with unexpected events in the real operating environment of the system, and obtaining adequate quality assurances for ML applications [2,38].
In this paper, we focus on one such challenge that is particularly important for self-adaptive systems: dealing with new learning tasks. In essence, ML techniques are designed to deal with a set of predefined tasks that they solve based on data derived from the operational domain of the system. Hence, they have problems to deal with new emerging tasks and changes in the operational domain. A typical example is new learning tasks that emerge due to unforeseen changes of input data over time. Without proper support, such problems require human intervention, which is time consuming and costly. This leads us to the research problem that we tackle in this paper: How to enable self-adaptive systems that use machine learning techniques to deal with new and changing learning tasks during operation?
To tackle this research problem, we propose lifelong selfadaptation: a novel approach to self-adaptation that enhances selfadaptive systems with a lifelong ML layer. The lifelong ML layer tracks the running system and its environment, associates the collected knowledge with the current tasks, identifies new tasks based on differentiations, and updates the learning models of the selfadaptive system accordingly.
Lifelong self-adaptation leverages the principles of lifelong machine learning [15,52] that offers an architectural approach for continual learning of a machine learning system. Lifelong machine learning adds a layer on top of a machine learning system that selectively transfers the knowledge from previously learned tasks to facilitate the learning of new tasks within an existing or new domain [15]. Lifelong machine learning has been successfully combined with a wide variety of learning techniques [15], including supervised [50], interactive [3], and unsupervised learning [49].
Our focus in this paper is on self-adaptive systems that rely on architecture-based adaptation [16,18,36,61], where a self-adaptive system consists of a managed system that operates in the environment and a managing system that manages the managed system to deal with a set of adaptation goals. We focus on managing systems that comply with the MAPE-K reference model, short for Monitor-Analyse-Plan-Execute-Knowledge [35,60]. Our particular focus is on managing systems that use a ML technique to support any of the MAPE-K functions. We make the assumption that dealing arXiv:2204.01834v1 [cs.SE] 4 Apr 2022 with new learning tasks does not require any runtime evolution of the software of the managed and managing system; hence we focus at handling new learning tasks that is realized by evolving the learning models used by the managing system.
We study one concrete instance of new learning tasks in selfadaptation: concept drift. Concept drift [58] refers to an unforeseen change of the input data of a learning model that results in predictions becoming less accurate over time, which may jeopardize the reliability of the system. We look at two types of concept drift: sudden and incremental concept drift.
The concrete contributions of this paper are: (1) A reusable architecture for lifelong self-adaptation; (2) Two concrete instances of the architecture to deal with sudden and incremental concept drift respectively; (3) A validation of the two instances of the architecture using DeltaIoT [32] and a gas delivery system [54] respectively.
The remainder of this paper is structured as follows. In Section 2, we provide a brief introduction of lifelong machine learning that provides the basic framework underlying lifelong selfadaptation. Section 3 then introduces the novel approach for lifelong self-adaptation. Next, we instantiate the architecture of a lifelong self-adaptive system for sudden concept drift in Section 4 using DeltaIoT for the evaluation. Section 5 instantiates the architecture for incremental concept drift using a gas delivery case. In Section 6 we discuss threats to validity, and Section 7 presents related work. Finally, we wrap up and outline opportunities for future research in Section 8.

LIFELONG MACHINE LEARNING IN A NUTSHELL
We briefly describe the basic principles of lifelong machine learning that provide the basis for lifelong self-adaptation. Lifelong machine learning is the ability of a machine-learning system to learn new tasks that were not predefined when the system was designed [53]. Technically, lifelong machine learning is a continuous learning process of a learner [15]. Assume that at some point in time, the learner has performed a sequence of learning tasks, T 1 , T 2 , · · · , T , called the previous tasks, that have their corresponding data sets D 1 , D 2 , · · · , D . Tasks can be of different types and from different domains. When faced with task T +1 (called the new or current task) with its data set D +1 , the learner can leverage past knowledge maintained in a knowledge-base to help learn task T +1 . The new task may be given by a stakeholder or it may be discovered automatically by the system. Lifelong machine learning aims to optimize the performance of the learner for the new task (or for an existing task by treating the rest of the tasks as previous tasks). After completing learning task T +1 , the knowledge base is updated with the new gained knowledge, e.g., using intermediate and final results obtained via learning. Updating the knowledge can involve checking consistency, reasoning, and mining meta-knowledge.
For example, consider a lifelong machine learning system for the never-ending language learner [41] (NELL in short). NELL aims at answering questions posed by users in natural language. To that end, it sifts the Web 24/7 extracting facts, e.g., "Paris is a city. " The system is equipped with a set of classifiers and deep learners to categorize nouns and phrases, e.g., "apple" can be classified as "Food" and "Company" falls under an ontology, and detecting relations, e.g., "served-with" in "tea is served with biscuits. " NELL can infer new beliefs from this extracted knowledge, and based on the recently collected web documents, NELL can expand relations between existing noun phrases or the ontology. This expansion can be a change within existing ontological domains, e.g., politics or sociology, or be a new domain like internet-of-things. Hence, the expansion causes an emerging task like classifying new noun phrases for the expanded part of the ontology.
Lifelong machine learning works together with different types of learners. In lifelong supervised learning, every learning task aims at recognizing a particular class or concept. E.g., in cumulative learning, identifying a new class or concept is used to build a new multiclass classifier for all the existing and new classes using the old classifier [21]. Lifelong unsupervised learning focuses on topic modeling and lifelong information extraction, e.g., by mining knowledge from topics resulting from previous tasks to help generating better topics for new tasks [57]. In lifelong semi-supervised learning, the learner enhances the number of relationships in its knowledge base by learning new facts, for instance, in the NELL system [41]. Finally, in lifelong reinforcement learning each environment is treated as a task [51], or a continual-learning agent solves complex tasks by learning easy tasks first [47]. Recently, lifelong learning has gained increasing attention, in particular for autonomous learning agents and robots based on neural networks [44].
One of challenges for lifelong machine learning is dealing with catastrophic forgetting, i.e., the loss of what was previously learned while learning new information, which can lead to system failures [42]. Another challenge for any machine learning pipeline is under-specification, i.e., a significant decrease of the performance of a learning model from training to deployment (or testing) [17]. Promising approaches have been proposed, see e.g., [44] for catastrofic forgetting or [46] for under-specification. Yet, more research is required to transfer these techniques to real-world systems.

LIFELONG SELF-ADAPTATION
We now introduce the novel approach of lifelong self-adaptation that enables self-adaptive systems that use machine learning techniques to deal with new learning tasks during operation. We start with assumptions and requirements for lifelong self-adaptation. Then we present the architecture of a lifelong self-adaptive system, explain how it deals with new tasks, and introduce instances for two types of concept drift.

Assumptions for Lifelong Self-Adaptation
The assumptions that underlie the approach for lifelong selfadaptation presented in this paper are: • The self-adaptive system comprises a managed system that realizes the domain goals for users in the environment, and a managing system that interacts with the managed system and realizes the adaptation goals; • The managing system is equipped with a learner that supports the realization of self-adaptation; • The self-adaptive system provides the probes to collect the data that is required for realizing lifelong self-adaptation; this  Figure 1: The architecture of a lifelong self-adaptive system may include an interface to the user to support the lifelong self-adaptation process if needed; • The managing system provides the necessary interface to adapt the learning models.
In addition, we only consider new learning tasks that require evolution of the learning models; runtime evolution of the software of the managed or managing system is out of scope.

Requirements for Lifelong Self-Adaptation
The lifelong self-adaptive systems should: R1 Provide the means to collect and manage the data that is required to deal with new tasks; R2 Be able to discover new tasks based on the collected data; R3 Be able to determine the required evolution of the learning models to deal with the new tasks; R4 Evolve the learning models such that they can deal with the new tasks.
3.3 Architecture of Lifelong Self-Adaptive Systems Figure 1 shows the architecture of a lifelong self-adaptive system. We zoom in on the role of each component and explain the flow of activities to deal with new and changing tasks.
Managed System. Takes input from the environment and realizes the domain goals for the users of the system.
Managing System. Monitors the managed system and environment and executes adaptation actions on the managed system to realize the adaptation goals. The managing system comprises the MAPE components that share knowledge. A learner supports the MAPE functions. The learning models are stored in the knowledge. The system may request an operator for input (active learning).
Lifelong Learning Loop. Adds a meta-layer on top of the managing system, leveraging the principles of lifelong machine learning. This layer tracks the layers beneath and when it detects a new learning task, it will evolve the learning models of the learner accordingly. We elaborate now on the components of the lifelong learning loop and their interactions.
Knowledge Manager. Stores all knowledge that is relevant to the learning tasks of the learner of the managing system (realizing requirement R1). In each adaptation cycle, the knowledge manager collects a knowledge triplet: = ⟨input , state , output ⟩. Input are the properties and uncertainties of the system and its environment (activity 1.1). State refers to data of the managing system relevant to the learning tasks, e.g., settings of the learner (1.2). Output refers to the actions applied by the managing system to the managed system (1.3). Sets of knowledge triplets are labeled with tasks, i.e., ⟨t , {k , k , k }⟩, a responsibility of the task manager. The labeled triplets are stored in the knowledge tasks repository.
Depending on the domain, the knowledge manager may reason about new knowledge or mine the knowledge extracting (or updating) meta-knowledge, such as a cache or an ontology (1.4). The meta-knowledge can be used by the other components of the lifelong learning loop to enhance their performance. The knowledge manager may synthesize parts of the knowledge to manage the amount of stored knowledge (e.g., outdated or redundant tuples may be marked or removed).
Task manager. Is responsible for detecting new learning tasks (realizing R2). The task manager periodically retrieves new knowledge triplets from the knowledge manager (2.1). The duration of a period is domain-specific and can be one or more adaptation cycles of the managing system. The task manager then identifies task labels for the retrieved knowledge triplets. A triplet can be assigned the label of an existing task or a new task. Each new task label represents a (statistically) significant change in the data of the knowledge triplets, e.g., a significant change in the distribution of the data observed from the environment and managed system. Hence, a knowledge triplet can be associated with multiple task labels, depending on the overlap of their corresponding data (distributions). The task manager then returns the knowledge triplets with the assigned task labels to the knowledge manager that updates the knowledge accordingly (2.2). Finally, the task manager informs the knowledge-based learner about the new tasks (2.3).
Knowledge-based learner. Decides how to evolve the learning models of the learner of the managing system based on the collected knowledge and associated tasks (realizing R3), and then enacts the evolution of the learning models (realizing R4). To collect the knowledge it needs for the detected learning tasks, the knowledge-based learner queries the task-based knowledge miner (3.1) that returns task-specific data (3.2); the working of the task-based knowledge miner is explained below. The knowledge-based learner then uses the collected data to evolve the learning models of the managing system (3.3). This evolution is domain-specific and depends on the type of learner at hand, e.g., tuning or retraining the learning models for existing tasks, or generating and training new learning models for newly detected tasks. Finally, the knowledge-based learner updates the learning models (3.4).
Task-based knowledge miner. Is responsible for collecting the data that is required for evolving the learning models for given learning task by the knowledge-based learner (supports realizing R3). As a basis, the task-based knowledge miner retrieves the knowledge triplets associated with the given task from the knowledge tasks repository, possibly exploiting meta-knowledge, such as a cache (3.1.1). Additionally, the task-based knowledge miner can mine the knowledge repositories of the knowledge manager, e.g., to retrieve knowledge of learning tasks that are related to the task requested by the knowledge-based learner. Optionally, the task-based knowledge miner may collect knowledge from stakeholders, for instance to confirm labels of knowledge triplets (3.1.2). Finally, the miner uses new knowledge to update the knowledge maintained in the repositories by the knowledge manager (3.1.3), e.g., it may update meta-knowledge about related tasks or add data to the knowledge provided by stakeholders. For the use cases in the next sections, we do not consider advanced reasoning and mining by the task-based knowledge miner.

Lifelong Self-Adaptation for Concept Drift
The concrete problem of new learning tasks we tackle with lifelong self-adaptation in this paper is concept drift. Concept drift refers to a change of the statistical characteristics of data over time [6,58], which may deteriorate the performance of the learning models that use that data to learn. Our focus is on co-variate drift, a common form of concept drift, that arises when the distributions of labeled data attributes change over time and the distribution of target values remains invariant relative to the attributes [22,58]. We study two types of drift: sudden co-variate drift and incremental co-variate drift. The next sections instantiate the architecture for lifelong self-adaptation for these types and apply each solution to a case.

LIFELONG SELF-ADAPTATION TO DEAL WITH SUDDEN CO-VARIATE DRIFT
To explain how lifelong self-adaption deals with sudden co-variate drift we use the DeltaIoT artifact [32]. Figure 2 shows the setup of the IoT network that consists of 15 battery-powered sensor motes that measure parameters in the environment and send the data via a wireless multi-hop network to a central gateway where users can use the data. The communication in the network is timesynchronized [40], i.e., neighboring motes are allocated slots where they can send and receive messages over a wireless link as shown in the figure.
[  The quality properties of interest in this paper are packet loss and energy consumption. Figure 3 shows the utility preferences of the stakeholders for the qualities of interest.  The utility of a network configuration is defined as: with and the utility for energy consumption and packet loss respectively, and 0.2 and 0.8 the weights associated with the quality properties. Users give max preference to an energy consumption below 13 mC (milli Coulomb) and zero preference to energy consumption above 13.4 mC. The utility for packet loss decreases linearly between 0% and 100%.
The quality properties are affected by uncertainties. We consider two types: network interference caused by environmental conditions such as weather fluctuations, and load of messages generated by motes that fluctuate based on different factors such as the presence of people in the environment. The network interference affects the Signal-to-Noise Ratio (SNR) [29] that determines packet loss.
To maximize the utility, we add a managing system at the gateway that monitors the managed system and its environment and adapts the networks settings in each cycle. The power setting of each node can be set (0 and 15), which will affect the SNR and hence the packet loss, and the distribution of the messages along the network links can be set (for motes with two links there settings are: 0/100, 20/80, 40/60, 60/40, 80/20, 100/0). In total, there are 216 possible configurations.
The managing system decides about whether or not to adapt the system after each communication cycle (8 minutes in our scenario). To select a configuration, the managing system uses a learner that predicts the quality attributes of the adaptation options (i.e., the possible configurations), leveraging on [45]. Concretely, we use two settings for the evaluation: a basic setting with a stochastic gradient descent (SGD) regressor [48], and an additional setting that allows switching between a SGD and a Hoeffding Adaptive Tree (HAT) [8]. An SGD regressor estimates the gradient of the loss for each data sample and uses that to update the learning model with a decreasing learning rate. A HAT regressor is an adaptive Hoeffding decision tree that incrementally grows in different branches by detecting different distributions in data. The regressors use feature vectors that comprise the data of an adaptation option (power settings and links' distributions) and the monitored uncertainties (SNR's of links and loads of messages). Based on these predictions, the configuration with the highest utility is selected and used to adapt the network configuration.

Problem
The problem is now that the distributions of input data that is used by the regressors may drift over time. Figure 4 shows how the global network interference changes when sudden concept drift occurs. Such a concept drift may for instance occur due to construction works in the neighbourhood of the IoT network where some machinery may periodically produce extra noise affecting the SNR of the network links [19]. Figure 5 shows the distribution of the signed difference between the packet loss predicted by a SGD regressor (without lifelong selfadaptation) and the true best options that are based on the true values of the quality properties. We used here a scenario of 1500 adaptation cycles without and with drift.
The median of the signed error increases from 0.70% to 3.36% and the mean from 0.98% to 6.84%, pointing to a significant increase in packet loss. The underlying problem is that concept drift introduces new emerging learning tasks that the regressors cannot handle. To tackle this problem, we add a lifelong learning loop on top of the Different scenarios Signed packet loss error (%) Figure 5: Distributions of the signed differences of packet loss between the true best options and the adaptation options selected by a SGD regressor with and without drift.
managing system (instantiating the lifelong learning loop shown in Figure 1).

Lifelong Learning Loop Instance
The lifelong learning loop is triggered every 20 adaptation cycles of the managing system (empirically determined).

Knowledge
Manager. Collects 20 new knowledge triplets per cycle of the lifelong learning loop. Input of the triplets are packet loss and energy consumption of the system (i.e., system properties), and SNR's for all links and the load of messages for each mote (i.e., uncertainties). State is meta-data about learner, including the configuration of the learner such as the scaler used, the input vectors that include the adaptation options, and the corresponding target values predicted by the learning model. Output are the adaptation actions applied for the selected adaptation option. In this instance, the knowledge manager does not maintain any meta-knowledge.

Task Manager.
Detects new tasks (i.e., new distribution of features in the input data of knowledge triplets). We use autoencoders [4,34,62]. An auto-encoder is an artificial neural network that learns to encode unlabeled data. Suppose at some point in time, the system has knowledge about a set of previously detected tasks denoted by T 1 , . . . , T . These tasks have corresponding data sets D 1 , . . . , D , each data set consisting of knowledge triplets 1 , and their corresponding auto-encoders AE 1 , . . . , AE . When triggered, the task manager determines the statistical similarity 2 between the outputs of each AE on the inputs of the newly observed knowledge triplets and the outputs of AE on D . If this similarity is below a given threshold 3 for all auto-encoders, the task manager introduces a new task T +1 with the new triplets as D +1 . Then the task manager instantiates the auto-encoder AE +1 (i.e., selecting the hyper-parameters: number of layers, neurons, etc.) for which we use a Bayesian optimizer [43]. If the similarity is greater than the threshold for at least one auto-encoder, the task manager assigns label T to corresponding triplets based on the highest achieved similarity of AE . In the evaluation settings, we consider only the case where a task manager detects one new task per cycle.

Knowledge-Based Learner.
Evolves the learning models. The function the knowledge-based learner is shown in Algorithm 1. When informed about a detected (new) task (Line 1), the knowledge-based learner queries appropriate knowledge specific to the task from the task-based knowledge miner (Line 2, see the next part). Based on the collected data, the knowledge-based learner determines the best learning models (Line 3 until Line 10). The knowledge-based learner optimizes the hyper-parameters of each learning model using a Bayesian optimizer (Line ??). The knowledge-based learner then trains the best model based on the collected training data (Line 8). When all learning models are trained, they are updated in the knowledge repository of the feedback loop (Line 11).

Task-Based Knowledge Miner.
Fetches the sets of knowledge triplets from the knowledge manager for the tasks queried by the knowledge-based learner. We limit the fetched data 4 to keep the training time of the knowledge-based learner at a constant and appropriate level. The current instance of the task-based knowledge miner applies no special mining.

Evaluation Results
We validated the instance of the lifelong self-adaptation architecture using the DeltaIoT simulator. We used the setup presented above (see Figure 2) and applied a scenario over 1500 adaptation cycles, representing 10 days wall clock time, with and without concept drift (see Figure 4). The evaluation was done on a computer with an i7-3770 @ 3.40GHz processor and 16GB RAM. All material of the evaluation is available at the project website [25]. 1 To speed up detection, we use 100 triplets; empirically determined. 2 We use the p-value from a non-parametric Mann-Whitney-U test [39]. 3 We use p=0.025 to ensure high confidence of the decision. Note that if we denote p-values in ascending order 1 , 2 , . . . , , the threshold will be adjusted by Holm's correction method [31] to − +1 for . 4 We use the last 1000 task-specific data; empirically determined.  We compared five approaches: (1) an optimal approach that selects the best adaptation option by maximizing the expected utility based on the true values of the quality attributes in each adaptation cycle (referred to as Baseline), (2) a state-of-the-art approach [11] that uses a regressor that retrains learning models (SGDs) in each adaptation cycle with all previously collected data (State-of-the-art), (3) incremental learning with a SGD regressor but without a lifelong learning loop (SGD without LLL), (4) lifelong self-adaptation with a lifelong learning loop and a SGD regressor (SGD with LLL), and finally (5) lifelong self-adaptation with a lifelong learning loop that can switch the learner of the managing system between a SGD regressor and HAT (SGD + HAT with LLL). This last approach allows comparing the effect of incorporating HAT, a learning method that is known to be suitable for dealing with concept drift of input data.
We investigated the following two evaluation questions: (1) To what extent can lifelong self-adaptation deal with concept drift of input data for its learner on the quality properties and system utility compared to the baseline? (2) How does lifelong self-adaptation compare with the stateof-the-art approach presented in [15]? 1 Impact on quality properties and system utility. Figure 6 summarizes the results for packet loss of the network with the different approaches. The results show that all approaches perform equally well for a scenario without concept drift (boxplots on the left hand side). For the scenario with concept drift (boxplots on the right hand side), the median of packet loss for the baseline approach (optimal approach based on the true values of quality properties) increases from 5.25% to 8.84%, indicating an inherent impact of the additional network interference. However, for a managing system that uses a SGD regressor (without a lifelong learning loop) the values increase from 6.23% to 19.56%. These results confirm earlier findings of Chen [11] when applying incremental learning methods under concept drift in different domains, such as service-based systems and cloud. The dramatic increase of packet loss (combined with the effects on energy consumption) results in a substantial decrease of 12% in the median of the expected utility of the IoT network (for detailed results of energy consumption and utility, see the project website [25]). In contrast, when applying lifelong self-adaptation (LLL), the results are similar to the baseline: the median of packet loss is slightly higher, 2.69% for SGD with LLL and 1.18% for SGD + HAT with LLL (compared to 10.72% for SGD without a lifelong learning loop). The expected utility for the lifelong learning approaches is only marginally smaller compared to the baseline: 1% and 2% for SGD with LLL and SGD + HAT with LLL respectively (compared to 12% for SGD without LLL). We observe that the performance of the two lifelong self-adaptation approaches are very similar, so the effect of including HAT as alternative for SGD is negligible.
In answer to the first evaluation question, we conclude that lifelong self-adaptation can effectively deal with sudden concept drift of input data for its learner on the qualities and system utility and performs similar to the baseline.

Comparison with
State-of-the-art Approach. When we compare the two approaches for lifelong self-adaptation (SGD with LLL and SGD + HAT with LLL) with the state-of-the-art approach [11], we observe a very similar performance in the realization of the quality properties and overall utility of the system. Hence, a valid question is what the competitive advantage of lifelong self-adaptation would be compared to the state-of-the-art. The answer to this question is twofold. On the one hand, lifelong self-adaptation offers a clean conceptual approach to deal with new learning tasks (in our case tasks related to concept drift of input data of the learner). The lifelong learning loop is drift-aware and provides first-class support to identify and deal with concept drift. On the other hand, the state-of-the-art approach we used in this paper exploits all the previously collected knowledge to train the learner, while lifelong self-adaptation relies on incremental training where the size of the training data can be set based on the characteristics of the domain at hand. Figure 8 shows the cumulative training time over the 1500 adaptation cycles for the state-of-the-art approach and SGD with LLL. We observe that the training time of the state-of-the-art approach grows much faster. Consequently, the state-of-the-art method consumes more computational resources for training the learning models. In the DeltaIoT setting, a cycle of the lifelong learning loop for SGD with LLL is only a fraction of the time window that is available to make an adaption decision at all times (i.e., 9.5 minutes). On the other hand, after 6500 cycles, the time required to complete an update of the learning models with the state-of-the-art approach would exceed the available time window for adaptation. Clearly, the state-of-the-art approach in its basic form is not scalable over longer periods of time. In answer to the second evaluation question, we conclude that lifelong self-adaptation performs similar to the state-of-the-art approach [15]. Yet, lifelong self-adaptation provides a clean conceptual approach to deal with new learning tasks that emerge from concept drift of the input data used by the learner of the managing system, and the approach scales well over time in contrast to the the state-of-the-art approach [15].

Detection of new tasks.
Finally, we looked at how many new tasks the lifelong learning loop detected in the evaluation scenario. Figure 9 shows that in total 18 different new tasks were detected over the period of 1500 cycles. In the period from cycle 1 to cycle 600, the learning models are trained for the tasks at hand. This period includes a first period of drift (from cycle 100 to cycle 350, see Figure 4). From cycle 600 to cycle 750, when no concept drift occurs, the system evolves the learning models for some of the learning tasks based on relevant changes detected in the distributions of input data. Then from cycle 750 until cycle 1100, the system faces a new wave of drift and consequently a number of new learning tasks are identified. In the remainder of the scenario until cycle 1500 no concept drift occurs anymore. During this period, the system evolves the learning models for some of the learning tasks. Two additional tasks are detected and learned at the end of the cycle due to some gradual changes in the interference that were significant enough to define new learning tasks.

LIFELONG SELF-ADAPTATION TO DEAL WITH INCREMENTAL CO-VARIATE DRIFT
To explain how lifelong self-adaption deals with sudden co-variate drift we use a case in the domain of gas delivery. Figure 10 shows a schematic overview of the setting that is inspired by [55]. The schedule of the system determines the type of gas that needs to be produced and the user requirements for a given period of time. Different types of gas can be generated by routing different portions of pressurized chemicals to the tanker. The gas delivery manager manages the mass flow controllers MFC1-3 to generate gas according to the schedule. Yet, there is uncertainty about the type of gas that is produced, which needs to be resolved before gas is routed to the users. To that end, the feedback loop collects sensor data from an array of 16 sensors at the gas tank and stores the data in the knowledge repository. The classifier, a multi-class support vector machine (SVC) 5 , labels the sensor data with a gas type, yielding tuples ⟨sensor data, generated gas type⟩. Periodically, the operator checks the labels and corrects them if needed (batches of 100). The classifier uses this input to improve its performance over time. Based on the gas type of the current data tuple and the gas requirements of the users, the planner determines the delivery of gas to the users. The executor then enacts these settings to the gas delivery manager that sets the valves of the mass flow controllers MFC4 to MFC7 routing the gas to the right users.

Problem
A problem with this setting is the potential degradation of the surface of the sensors due to ageing or contamination, causing sensor drift, a challenging problem in chemical sensing [55]. Figure 11 5 SVC combines several binary support vector machines based on a given strategy [5]. Example strategies consider decision boundaries between training examples of every two classes ("one vs. one" strategy) or training examples of each class against all others ("one vs. all" strategy).
shows the moving average (400 cycles window) of the data obtained from one of the sensors, illustrating the drift of data over time. This type of drift, characterized as incremental co-variate drift, may affect the performance of the learner over time. To deal with this problem, we add a lifelong learning loop on top of the feedback loop, see Figure 10.

Lifelong Learning Loop Instance
We empirically determined that lifelong learning is triggered best every 20 adaptation cycles of the managing system.

Knowledge
Manager. Collects 20 new knowledge triplets per cycle of the lifelong learning loop. Here, input of the triplets are features of the sensor array data. State is meta-data about learner, including the configuration of the learner and sets of pairs of sensory data with labels checked per 100 cycles by the operator. Output are the adaptation actions applied based on the classification label of the sensory data. In this instance, the knowledge manager does not maintain any meta-knowledge.

Task
Manager. Uses the same algorithm of the task manager in the first validation case. Yet, the similarity threshold is relaxed to 0.05 (in contrast to 0.025 in the first case).

Knowledge-Based
Learner. Evolves the learning models using an algorithm similar to Algorithm 1. Based on the data received from the task-based knowledge miner, the knowledge-based learner determines the best learning model (optimizing the loss value for the learner with a Bayesian optimizer). Then, it trains the best model and updates the classification model in the knowledge repository of the managing system.

Task-Based Knowledge Miner.
Fetches the sets of knowledge triplets from the knowledge manager for the tasks queried by the knowledge-based learner. Due to uncertainties in the gas composition, the labels of the input in the state of these triplets may not necessarily be correct. To that end, for new detected tasks, the taskbased knowledge miner selects the top five 6 inputs (out of 20 newly observed triplets) with the highest uncertainty. 7 Then, task-based knowledge miner asks the operator to check these labels and once it receives the corrections, sends them to the knowledge manager to use them for improving the performance of the learner. If the detected task is not new, the task-based knowledge miner fetches a sample of knowledge triplets for the detected task. 8 The state of the triplets contains correctly labeled data that can be used by the knowledge-based learner for updating the learning model.

Evaluation Results
To validate lifelong self-adaptation for incremental co-variate drift, we implemented a simplified simulation of the gas delivery setup shown in Figure 10. Concretely, we implemented the feedback loop, the lifelong learning loop, and the part that provides gas to users. The remainder of the system and the environment are represented as an extensive set of data [1]. This data set was generated over  Figure 10: Gas delivery setup for the evaluation three years in a controlled setting; it contains the sensor data and the correct labels for the operator (ground truth). The classifier of the feedback loop was realized as an ensemble of classifiers based on support vector machines. The weighted combination of these classifiers were trained at different points in time to solve a gas discrimination problem with high accuracy. We used the same computer setup as for the first case for the evaluation.
We compared three learners: (1) a SVC trained offline (Reference), (2) a SVC with online training that uses the data of the previous batch of monitored data (State-of-the-art [54]), and (3) the SVC of (2) with a lifelong learning loop. We measured the classification accuracy using the ground truth that is provided with the data set [1]. Figure 12 shows the results over 13.7k cycles, grouped in three zones. The results show low values for accuracy with the reference approach in all zones. While the state-of-the-art approach scores similar to the approach with a lifelong loop in the first zone, its accuracy gradually decreases afterwards. The mean value of the accuracy over the complete run was 0.35 for the reference approach, 0.77 for the state-of-the-art, and 0.88 for the lifelong selfadaptation approach. The results show that lifelong self-adaptation can effectively deal with incremental concept drift. concept drift, so we cannot generalize the findings for other types of problems that require dealing with new learning tasks (external validity). Additional research is required to study the usefulness of the architecture for other challenges with new learning tasks in self-adaptive systems. Additionally, we validated the architecture for each type of concept drift with a single application. Evaluation in different domains is required to increase the validity of the results for the types of concept drift considered in this paper. We have evaluated the instances of the architecture for particular settings. The type and number of new learning tasks these settings generate may have an effect on the difficulty of the problems (internal validity). We mitigated this threat by instantiating the architecture for two different domains. However, additional evaluation in other domains is required to increase the validity of the results for the types of concept drift studied. For practical reasons, we used simulation for the evaluation with data that contains uncertainty. The results may be different if the study would be repeated (reliability). We minimized this threat by considering data extracted from real systems, and we evaluated the cases over long periods of time. We also provide a replication package for the study [25].

RELATED WORK
We look at a selection of work at the crossing of machine learning and self-adaptation, focusing on concept drift and performance of machine learning in self-adaptive systems.
Dealing with Concept Drift in Self-Adaptation. T. Chen [12] studied two methods to deal with concept drift in self-adaptation with learning: retraining a new model in each cycle using all available data, and retraining the existing model using the newly arrival data sample. In contrast to general beliefs about the choices between the two, the author examines both modeling methods for distinct domains of adaptive software and identifies evidence-based factors that can be used to make well-informed decisions. Bierzynski et al. [7] present the architecture of a self-learning lighting system that equips a MAPE-K loop with a learner that learns activities and user preferences. Another feedback loop on top of the learner determines when the predictions of a learning model start to drift and then adapts the learning model accordingly. A concrete instance based on micro-services is proposed and compared with other architectural styles. Vieira et al. [56] propose Driftage, a multi-agent framework for concept drift detection that uses a MAPE-K loop. The monitor and analyzer agents capture and predict concept drifts on data, and the planner and executor agents determine whether the detected concept drift should be alerted. The approach is applied to health monitoring of muscle cells. Casimiro et al. [9] propose a framework for self-adaptive systems with machine-learned components. The authors outline a set of adaptation tactics to deal with misbehavior of the machine-learned components, the required changes to the MAPE-K loop for dealing with them, and the challenges associated with developing this framework. In contrast to these approaches, we provide a domainindependent architecture to deal with new emerging tasks in learning modules used by self-adaptive systems. The work of [12] and [9] offer valuable solutions that can be used when instantiating the architecture for lifelong self-adaptation.
Improving the Performance of Machine Learning for Self-Adaptation. Jamshidi et al. [33] propose L2S (Learning to Sample), an efficient approach for transferring knowledge across execution environments to simplify the configuration, e.g., hardware, software release. The approach progressively concentrates on interesting regions of the configuration space. Chen and Bahsoon [13] present a modeling approach for creating quality prediction models that use data from the environment and control settings as inputs. The approach leverages adaptive multi-learners, selecting the best model for prediction on the fly, and is evaluated in a cloud environment. Chen et al. [14] apply a similar approach to deal with the problem if resource allocation for cloud-based software services. Chen et al. [10] propose the idea of "experience transfer" from one system to another similar system, and demonstrate this for system configuration tuning, where experiences are dependencies between configuration parameters.
These related approaches target the efficiency of machine learning methods in the context of self-adaptation. Our work complements these approaches focusing on enhancing learning to handle new learning tasks as required for concept drift.

CONCLUSIONS AND FUTURE WORK
Self-adaptive systems are characterized by their ability to deal with uncertainty. Machine learning techniques on the other hand, which are increasingly used in self-adaptive systems, face challenges with uncertainties that were not considered as learning tasks during design. To deal with new learning tasks, we presented lifelong self-adaptation, a novel approach to self-adaptation that enhances self-adaptive systems that use machine learning techniques with a lifelong learning layer. We presented an architecture for lifelong self-adaptation and applied it to deal with two types of concept drift in two domains. The evaluation results show that lifelong self-adaptation effectively resolves the problems of concept drift.
In future work, we plan to study and apply lifelong selfadaptation for other types of concept drift, in particular class drift and novel class appearance. Then, we plan to investigate how lifelong self-adaptation can be used to deal with new and changing adaptation goals, which is a particularly challenging example of uncertainties for self-adaptive systems.