scieee AI-readable full text Open interactive document viewer

Study of alternatives of federated learning techniques applied to network and service management

Castro Jiménez, Albert

Abstract

The number of intelligent devices that are connected to the network is increasing, requiring more and more computation and instantaneous response time. Fog computing proposed a solution to bring the computational power closer to the edge of the network satisfying the demands of the client. However, a challenge arises the nodes closer to the edge are limited in computational power and unable to satisfy all the incoming requests. An offloading tasks problem is posed as a solution we propose a Fog computing based architecture in which the nodes of the network have artificial intelligence agents running a federated reinforcement learning algorithm to balance the tasks among nodes. This scenario is compared with another in which the agents are only running and deep reinforcement learning algorithm. After running some tests, the results show the environment running a federated learning algorithm works better in situations of huge stress having a rejection rate lower than the environment running deep reinforcement learning, however, in situations of low or medium stress, both models work well. Surprisingly, the scenario running only a deep reinforcement learning algorithm without any exchange of information is able to perform well in a scenario where the available resources are changing in each evaluation and it has been trained just with one concrete size of available resources.

Full text

Study of alternatives of federated learning techniques applied to network and service management Master Thesis submitted to the Faculty of the Escola T`ecnica d’Enginyeria de Telecomunicaci´o de Barcelona Universitat Polit`ecnica de Catalunya by Albert Castro Jim´enez In partial fulfillment of the requirements for the master in MASTER’S DEGREE IN TELECOMMUNICATIONS ENGINEERING Advisor: Professor Juan-Luis Gorricho Barcelona, Date 01/08/2023 Contents List of Figures 3 List of Tables 3 1 Introduction 6 1.1 Statementofpurpose.............................. 6 1.2 Requirements and specifications . . . . . . . . . . . . . . . . . . . . . . . . 6 1.3 GanttDiagram ................................. 6 2 State of the art 8 2.1 Currenttrends ................................. 8 2.2 FogComputing ................................. 9 2.2.1 Architecture............................... 10 2.2.2 Characteristics of Fog Computing . . . . . . . . . . . . . . . . . . . 11 2.3 FederatedLearning............................... 11 2.3.1 Definition and characteristics . . . . . . . . . . . . . . . . . . . . . 11 2.3.2 Architecture............................... 12 2.3.3 Categorization of Federated Learning . . . . . . . . . . . . . . . . . 13 2.4 Federated Reinforcement learning . . . . . . . . . . . . . . . . . . . . . . . 16 2.4.1 Categorization of FRL . . . . . . . . . . . . . . . . . . . . . . . . . 16 3 Project development 18 3.1 Architecture................................... 18 3.2 ProblemFormulation.............................. 19 3.3 Proposedalgorithm............................... 22 3.4 Implementation................................. 25 3.4.1 Environment .............................. 25 3.4.2 Agents.................................. 25 4 Test and Results 27 4.1 Parameter configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 4.2 Results...................................... 28 5 Conclusions and future development 34 References 35 2 List of Figures 1 Project’sGanttdiagram ............................ 7 2 Three-layer architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3 Client-servermodel............................... 13 4 Horizontal Federated Learning . . . . . . . . . . . . . . . . . . . . . . . . . 14 5 Vertical Federated Learning . . . . . . . . . . . . . . . . . . . . . . . . . . 15 6 Federated Transfer Learning . . . . . . . . . . . . . . . . . . . . . . . . . . 15 7 Comparison of horizontal and vertical federated reinforcement learning . . 17 8 Environment architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 9 Edge delegation percentage fed. env. . . . . . . . . . . . . . . . . . . . . . 29 10 Edge delegation percentage indep. env. . . . . . . . . . . . . . . . . . . . . 29 11 Superior delegation percentage fed. env. . . . . . . . . . . . . . . . . . . . 29 12 Superior delegation percentage indep. env. . . . . . . . . . . . . . . . . . . 29 13 Acceptance percentage fed. env. . . . . . . . . . . . . . . . . . . . . . . . . 29 14 Acceptance percentage indep. env. . . . . . . . . . . . . . . . . . . . . . . . 29 15 Occupancy of the queue of each edge agent . . . . . . . . . . . . . . . . . . 30 16 Rejectionrate.................................. 30 17 Datacenter occupancy by edge agents . . . . . . . . . . . . . . . . . . . . . 30 18 Acceptedrequests................................ 31 19 Rejection rate overload situation . . . . . . . . . . . . . . . . . . . . . . . . 33 Listings 1 FedAvg algorithm implementation . . . . . . . . . . . . . . . . . . . . . . . 24 List of Algorithms 1FederatedAveraging algorithm ......................... 23 List of Tables 1 HyperparametersDQN............................. 22 2 GlobalParameters ............................... 27 3 Hyperparameters DQN Edge Agents . . . . . . . . . . . . . . . . . . . . . 28 4 Hyperparameters DQN Sup Agents . . . . . . . . . . . . . . . . . . . . . . 28 5 Mean value per agent Independent env. . . . . . . . . . . . . . . . . . . . . 31 6 Mean value per agent Federated env. . . . . . . . . . . . . . . . . . . . . . 32 7 Mean percentage values per edge agent Independent env. overload situation 32 8 Mean percentage values per edge agent Independent env. overload situation 32 9 Mean percentage values per edge agent Federated env. overload situation . 33 10 Mean percentage values per edge agent Federated env. overload situation . 33 3 Revision history and approval record Revision Date Purpose 0 31/07/2023 Document creation 1 21/08/2023 Document revision DOCUMENT DISTRIBUTION LIST Name e-mail [Student name] Albert Castro Jim´enez [Project Supervisor 1] Juan-Luis Gorricho Written by: Reviewed and approved by: Date 31/07/2023 Date 29/08/2023 Name Albert Castro Jim´enez Name Juan-Luis Gorricho Position Project Author Position Project Supervisor 4 Abstract The number of intelligent devices that are connected to the network is increasing, requiring more and more computation and instantaneous response time. Fog computing proposed a solution to bring the computational power closer to the edge of the network satisfying the demands of the client. However, a challenge arises the nodes closer to the edge are limited in computational power and unable to satisfy all the incoming requests. An offloading tasks problem is posed as a solution we propose a Fog computing based architecture in which the nodes of the network have artificial intelligence agents running a federated reinforcement learning algorithm to balance the tasks among nodes. This scenario is compared with another in which the agents are only running and deep reinforcement learning algorithm. After running some tests, the results show the environment running a federated learning algorithm works better in situations of huge stress having a rejection rate lower than the environment running deep reinforcement learning, however, in situations of low or medium stress, both models work well. Surprisingly, the scenario running only a deep reinforcement learning algorithm without any exchange of information is able to perform well in a scenario where the available resources are changing in each evaluation and it has been trained just with one concrete size of available resources. 5 1 Introduction 1.1 Statement of purpose The purpose of the dissertation is to define common working scenarios in the field of network and service management with the goal of assessing the performance of federated reinforcement learning. Those working scenarios (environments) will be evaluated by comparing different alternatives to deploy them. Basically, we want to know what federated learning provides us with respect to other methods. 1.2 Requirements and specifications In order to carry out this project we have set the following requirements and specifications: 1. Study federated learning concept and principals. 2. Understand and study Fog Network and its benefits. 3. Define a scenario. 4. Implementation of Federated Reinforcement Learning. 5. Selection of implementation alternatives, such as Deep Reinforcement Learning and a heuristic algorithm. 6. Analyze the results obtained. Moreover, my master’s director, professor Juan Luis Gorricho, provide me with software already implemented by him to help me in the phases of development of a scenario to reproduce working a network and service management scenario. In chapter 3 it will be explained in detail where has been used. 1.3 Gantt Diagram This master thesis started with a study phase where I studied some papers provided by the director of the thesis to introduce me to the topic. Then we entered the phase of code development, both scenarios and algorithms. We spent some time iterating on the development and testing phases to correct all the bugs that came up. And finally, we ended up writing this thesis. 6 Phases of the Project - Year 2023 March April May June July August Literature Development Tests Writing Figure 1: Gantt diagram of the project 7 2 State of the art This section aims to outline the current trends being explored by the community and the technologies being used. It will also comment on the problems we face, how the community is tackling them and what we propose to do about them. 2.1 Current trends Huge steps are being taken by the telecommunications community towards the improvement of the performance of the network being able to support higher throughputs, connection devices and reduction of latency. These advancements are leading to a rapid creation of IoT devices (e.g., sensors, smartphones, cameras, vehicles) to be connected challenging the conventional cloud-based central computing paradigm in providing nearly instantaneous response time and computing power.[1], [2]. Moreover, in [1] a fog computing architecture is proposed as a part of the solution to transfer cloud computing power closer to the network edge. Given the proximity of the computing power near the edge of the network, fog networks can guarantee lower latency in consequence faster response time to the request of devices. In addition, fog computing harnesses both edge and cloud resources to address the requirements of IoT devices, which are computing power and latency [3]. However, the use of fog networks poses a problem: the nodes closest to the edge have limited computational power to handle the incoming requests and will not be able to handle them all. Therefore, offloading tasks between nodes will play a key role in ensuring high resource utilisation and low latency. In [1] to address the offloading tasks problem, actor-critic RL framework and communication protocols in multi-agent reinforcement learning (MARL) coordinate the behaviour of cooperative APs and coordinate their decision to provide a joint solution. A drawback that we see is that all the agents must exchange sensitive data to coordinate themselves to give a solution. Here is where Federated learning comes in, by exchanging non-sensitive data in the training phase, such as weights of a neuronal network, to achieve a better joint policy on making decisions without the need to communicate with other nodes. Moreover, the constant communication between nodes increases the amount of traffic in the network which is not desirable. This paper [4] proposes a load-balancing algorithm based on reinforcement learning to minimise latency in Fog networks. The algorithm allows Fog nodes to offload an optimal number of tasks among incoming tasks by selecting an available neighbouring Fog node. The proposed architecture is a centralised controller where the algorithm is executed by controlling and making decisions over a network with N nodes randomly distributed in an area. What we would like to explore is a solution where AI agents could be placed with the nodes at the edge of the network using federated learning to achieve a common policy 8 that can work in different situations even though any AI agent might have never been in a particular situation before. This is possible due to each agent applies its experience to improve the global model. 2.2 Fog Computing Fog computing stands in between the traditional centralised cloud and edge devices, by extending the capabilities of the network placing resources closer to the edge devices being able to deal with more connections and bringing computing power and lower latency constraints for IoT devices. As Fog computing has emerged recently, there is not a standard architecture up until now [5]. Ranesh Kumar et al. [5] conducted a survey exploring the different types of fog architecture proposed by the community. They also commented that an attempt has been made to start an open project offering a standard architecture, however, at the moment you cannot find the website operational but there is a link to the white paper. 1. In the conducted survey [5] multiple research lines are commented. For instance, a sixlayered fog architecture includes (from lowest to highest): •Physical and virtualization layer: Manage physical and virtual devices. •Monitoring layer: Monitors the network and nodes within. And defines the tasks to be performed and which nodes do them. •Pre-processing layer: For data management purposes. •Temporary storage layer: Stores data from the pre-processing layer. •Security layer: Encryption, integrity and privacy is provided by. •Topmost layer: Uploads pre-processed and secure data to the cloud. In addition, a high-level architecture such as Tom. H. Luan et al. [6] show that fog computing extends cloud computing by introducing an intermediate fog layer between mobile devices and the cloud, creating a three-tier hierarchy. The Fog layer consists of geo-distributed Fog servers deployed near mobile devices, providing fast-rate services to mobile users through short-distance wireless connections. 1https://www.iiconsortium.org/pdf/OpenFog Reference Architecture 2 09 17.pdf 9 2.4 Federated Reinforcement learning Federated Reinforcement learning is a novel technique that arises from the application of federated learning in reinforcement learning scenarios. The main goal is to make Nagents work cooperatively to learn a policy or value function that performs uniformly well across different environments[18]. The key point about using federated reinforcement learning in a scenario is that you can have multiple agents interacting with their environments, where, for example, datacenter servers are of different sizes. The knowledge learned by the multiple agents in these different environments can be transferred to all the other agents. This will help in situations of partial server failure where the server size has been reduced, given that the agents have learned a joint policy function or value function that will improve their behaviour even if they have never been trained in such a situation. 2.4.1 Categorization of FRL Based on the environment partition and how the agents interact with them, federated reinforcement learning, a.k.a. FRL, can be divided into two categories.[12] •Horizontal Federated Reinforcement Learning. •Vertical Federated Reinforcement Learning. Horizontal Federated Reinforcement Learning We are in a horizontal federated reinforcement learning scenario when agents face similar decision-making actions and the interaction with each other is minimal in the observed environments. In addition, each participant makes decision-making actions based on the current state of the environment and obtains a reward that is independent of the other agents and environment. We assume that {Fi}N i=1 agents have associated an environment {Ei}N i=1.Gdenotes the collection of environments. The environment Eiof the i-th agent has a similar state transition probability and reward function compared to other environments. However, the state transition and reward of Eidoes not depend on the states and actions of other environments. Therefore, Si=Sj,Ai=Aj,Ei=Ej,∀i, j ∈ {1,2, ..., N},Ei,Ej∈ G, i =j where Siand Sjdenote a similar state space, Aiand Ajdenote a similar action space [12]. Thanks to horizontal federated reinforcement learning, agents can benefit from shared experience when the state space of an environment is huge, allowing them to quickly gain experience from different environments to evaluate unexplored states. Figure 7 shows horizontal federated reinforcement learning. 16 Vertical Federated Reinforcement Learning We are in a vertical federated reinforcement learning scenario when agents have different interactions with the same environment. Moreover, agents can have different observations that are part of the global state.The main goal of vertical federated reinforcement learning is to aggregate the partial features observed by each agent.[12] Formally, each agent {Fi}N i=1 interact with a global environment E. They can have different sets of observations, Oi, thus all the observations together constitute the global state space S. Also, each agent can perform a set of actions denoted as Aiwhich aggregation of them constitutes the action space. Therefore, Oi=Oj,Ai=Aj,Ei=Ej=E, ∪N i=1Oi=S,∪N i=1Ai=A,∀i, j ∈ {1,2, ..., N}, i =j Down below you can see a comparison between horizontal and vertical federated reinforcement learning. Figure 7: Comparison of horizontal and vertical federated reinforcement learning, source [12] 17 3 Project development This chapter aims to outline the architecture, problem definition and elements that compose the reinforcement learning environment developed. Furthermore, the implementation of the aforementioned elements will be presented and the two developed scenarios, one using federated reinforcement learning and the other using an independent reinforcement learning approach. 3.1 Architecture We have considered a hierarchical fog computing network composed of three layers as shown in Figure 8. The end device layer consists of any type of device that generates requests such as sensors, mobile phones, vehicles, etc. The requests generated by end devices will come with a demand for the resources needed to serve them. With this resource demand, we want to represent the amount of computing power needed to process it. Once requests are sent to the closest base station, they enter in the fog layer. Each fog node may have associated one or more base stations and may have a limited amount of resources, simulating the computational power, not enough to handle all the incoming requests. Therefore, these nodes need to balance the load to handle as many incoming requests as possible. In the proposed environment each fog node has an artificially intelligent agent, called edge agent, which is responsible for the decision-making process over the demands that arrive at the node. The edge agents can decide whether to accept the demand, offload the demand to another edge agent or offload the demand to the cloud. If one of the edge agents of the fog layer decides to offload the request to the cloud, it will enter in the cloud layer. In this layer, we have a node with a much higher amount of resources compared to the fog nodes where an artificially intelligent agent is located, called superior agent, responsible for the decision-making process over the incoming request. As the superior agent is the last of the chain, it can only accept or reject requests. Furthermore, whether it is a fog layer node or a cloud layer node, each has a queue of a certain length where requests are queued. In addition, a cluster consists of 2 or more edge agents with the same superior agent. To be clear from now on, we use the term edge agent to refer to the fog node and the AI agent associated. Also, we use the term superior agent to refer to the node and the AI agent associated. The main objective is to serve requests as close as possible to the end device layer by choosing the most suitable decision given the available resources in the agent while obtaining a model flexible enough to work properly in situations where the resources of the agents are completely different. 18 It is important to highlight that the federated learning algorithm is only run in the fog layer, not in the cloud layer. Due to our cluster architecture, it has only one superior agent. Figure 8: Environment architecture 3.2 Problem Formulation The proposed environment aims to solve a load balancing problem which is formulated as a Markov Decision Process, a.k.a. MDP. MDP involves a decision agent that repeatedly observes the current state sof the environment, and makes a decision afrom among those allowed. And then observes a transition to a new state s’ and a reward rthat will affect its subsequent decisions. In our environment, we have two types of agents, edge agents and superior agents, each of which will see a different observation since one is in a higher layer than the other. Our environment is characterized by the following parameters: •Gt, global epochs. •Lt, local epochs. •Tis a set of requests allowed in the system. Each of them is defined by the following parameter, (req size, req value). –req size, resources required to process the request. –req value, the value associated with the request. •Fe={1, ..., Ne}is the number of edge agents in the environment. 19 •Qe, size of the edge agents’ queue. •We, maximum available resources of the edge agents’ datacenter. •Fs={1, ..., Ns}is the number of superior agents in the environment. •Qs, size of the superior agents’ queue. •Ws, maximum available resources of the superior agents’ datacenter. •Prob exit, the probability with which requests leave the datacenter and are considered served. And is defined as Prob exit =1 W 1 num req ·Pnum req i=1 req sizei being Wthe maximum available resources of the agent’s datacenter, depending on whether it is an edge agent,We, or a superior agent,Ws. And being num req the total number of request types. •Prob gen req, the probability of generating a request in the next time slot. Each edge agent is assigned a value from the following randomly selected tuple: Prob gen req = (0.8,0.7,0.6,0.5,0.4,0.3,0.2) •A, the action space. Depending on the type of agent, they will choose from a set, A={Ae, As}. –Ae, denote the set of actions that an edge agent can choose from: ∗Action 0: accept the request. ∗Action 1: delegate to an edge agent. ∗Action 2: delegate to a superior agent. –As, denote the set of actions that a superior agent can choose from: ∗Action 0: accept the request. ∗Action 1: reject the request •S, the state space. The states are defined by the type of agent. –Edge Agent, s= (req size, cap, D, ave coef) ∗req size, demanding resources of the request. ∗cap, free resources in the datacenter after processing the request. ∗D, a flag that requests come with, if True it means is delegated from an agent edge, otherwise it means is new to the system. ∗ave ocup, coefficient between [−1,1] which is the occupancy in the agent’s datacenter minus the average occupancy of all edge agents in the cluster including itself. 20 –Superior Agent, s= (req size, Cap) ∗req size, demanding resources of the request. ∗cap, free resources in the datacenter after processing the request. •R, is the reward when in state sthe agent takes the action a. The reward for an edge agent is also different from that of a superior agent. The goal for edge agents is to process the requests as close as possible to the end device layer and for superior agents, the goal is to accept as many requests as possible. Hence the following rewards have been defined: –Reward Edge Agent ∗If a = action 0 is taken, and there are enough resources to allocate the request, R= 0.25 + req valuej Pnum req i=1 req valuei being num req the total number of request types and jtype of the incoming request. Otherwise, if there are not enough resources, the agent is penalized. R=−1 ∗If a = action 1 is taken, and there are not enough resources to allocate the request and the Dflag is False, R= 0.25 Otherwise, the agent will be penalized. R=−1 ∗If a = action 2 is taken, and there are not enough resources to allocate the request and the Dflag is True, R= 0 Otherwise, the agent will be penalized. R=−1 –Reward Superior Agent ∗If a = action 0 is taken, and there are enough resources to allocate the request, R=req valuej Pnum req i=1 req valuei being num req the total number of request types and jtype of the incoming request. Otherwise, the agent is penalized. R=−1 21 ∗If a = action 1 is taken, and there are not enough resources to allocate the request and the Dflag is False, R= 0 Otherwise, the agent will be penalized. R=−1 meaning that there were enough resources to allocate the request and it has been rejected. 3.3 Proposed algorithm We proposed a federated reinforcement learning algorithm to address the problem defined and achieve the goal proposed. As explained at the beginning of the chapter two environments are implemented one using a federated learning algorithm and the other one using an independent learning strategy to compare each other and see what are the benefits of using a federated algorithm. Furthermore, as we are in a reinforcement learning scenario all the agents, either edge agents or superior agents, are using a Deep Q-learning algorithm learning the optimal Q- values by iteratively adjusting its neural network’s weights using the experiences it collects from the environment. The Deep Q-learning algorithm was suggested by the supervisor who also, provided me with the implementation of the Deep Q-learning algorithm. Regarding the Deep Q-learning class, these are the parameters that must be set. Parameters Description n features Number of features of the input layer, size(s) n actions Number of actions, size(A) αLearning rate γDiscount factor ϵProbability of selection randomly an action batch size Number of sample used to update the network replace target iter Number defining every how many steps the target function must be replaced Table 1: Hyperparameters DQN You can find the implementation of the DQN algorithm in the appendix ??. 22 As mentioned before, there are two environments, the independent and the federated one. In the independent environment, the edge agents run the Deep Q-learning algorithm independently. In the beginning, they are given the same neural network weights and each of the agents starts training on its own. When I use the expression, ”on its own”, what I mean is that no federated learning algorithm is used. Recall that the federated learning algorithm is only run in the fog layer, Fig. 8, which only includes the edge agents. Regarding the federated learning algorithm, I have used the algorithm known as FederatedAveraging algorithm [19]. The FederatedAveraging algorithm works as follows. First of all, there are Kclients, and only a portion of them are selected to contribute to the round. Then the server sends the current model parameters to the selected clients. Once, each of the selected client trains the model on its local data for a certain number of epochs or iterations and make the update of the model. Then, the selected clients send back the weight parameters and make a weighted average of the weights. The amount of computation is controlled by three key parameters: C, the fraction of clients that perform computation on each round; E, the number of training passes each client makes over its local dataset on each round; and B, the local minibatch size used for the client updates [19]. Algorithm 1 Federated Averaging. We assume there are Kclients over which the data is partitioned, with Pkthe set of indexes of data points on client k, with nk=|Pk|. The Kclients are indexed by k;Bis the local minibatch size, Eis the number of local epochs, and ηis the learning rate. 1: initialize wo 2: for each round t= 1,2, . . . do 3: St←(random set of mclients) 4: for each client k∈St in parallel do 5: wk t+1 ←ClientUpdate(k, wt) 6: mt←Pk∈Stnk 7: wt+1 ←Pk∈St nk mtwk t+1 8: 9: ClientUpdate(k, w):{//Run on client K 10: B←(split Pkinto batches of size B 11: for each local epoch ifrom 1 to Edo 12: for batch b∈ B do 13: w←w−η∇l(w, b) 14: return wto server} The next thing I am going to show you is how I have implemented it. First, we start the first loop, which is the number of global epochs, which are the times at which we will perform the averaging step. The second loop corresponds to the local 23 epochs that we have defined for the edge agents. Once these loops are done, we calculate the weighting coefficient based on the data that each of the edge agents has and then we apply the averaging function. Once we have the new average model, it is propagated again to the agents. This piece of code can be found inside the federated environment code which is in the following appendix, D. Listing 1: FedAvg algorithm implementation 1for num global epochs in range (1 , g lobal epochs + 1) : 2for num steps in range (1 , l o c a l e p o c h s + 1) : 3 4 unbalanced request generation validation() 5 6 run agents random ( ( ( num global epochs −1) ∗l o c a l e p o c h s + num steps ) ) 7 8 weights = [ ] 9 pondered weights = [] 10 num request per agents = [] 11 # c o l l e c t the weight of the edge Agents and c a l c u l at e contri but ion per agent 12 for i in range ( num edge agents ) : 13 weights . append ( edge agents [ i ] . g e t t r a i n a b l e v a r () ) 14 num request per agents . append ( edge agents [ i ] . num request () ) 15 co ntr ibu ti o n p er ag ent = [ num iter / sum( num request per agents ) for num iter in num request per agents ] 16 c o n t r i b u t i o n h i s t o r y . append ( c o n tr i bu ti o n p e r a ge nt ) 17 18 for num in range ( num edge agents ) : 19 pondered weights .append( 20 [ t f . multiply ( t f . constant ( con tr ib ut io n per ag en t [num] , dtype=t f . f l o a t 3 2 ) , d) for d in weights [num ] ] ) 21 22 averaged weights = [ t f . add ( t , c ) for t , c in zip(pondered weights [ 0 ] , pondered weights [ 1 ] ) ] 23 for b in range (2 , num edge agents ) : 24 averaged weights = [ t f . add ( t , c ) for t , c in zip ( averaged weights , pondered weights [ b ] ) ] 25 26 result ado a ve rag e = t f . Session ( ) . run ( averaged weights ) 27 g l o b a l per = num global epochs / gl oba l epoch s 28 for agent in edge agents : 29 agent . update model ( r esult ad o ave ra ge ) 30 agent .DQN. s e t l e a r n i n g r a t e ( glob al p er ) 24 3.4 Implementation To simulate the environment described above, we will now present the software architecture that has been created. 3.4.1 Environment There are two main codes: •Environment fed unbalancedload x srv size.py . Here is the environment where the federated learning algorithm is used. •Environment indep unbalancedload x srv size.py . Here is the environment where the independent learning approach is used. Both of the codes work as follows. First of all, the parameters are initialized such as the number of edge agents, superior agents, size of the queue, etc. Next, you will find the initialisation of the edge agents and the superior agents, divided into a training and an evaluation phase, since in the evaluation we need to load the already trained models. Next, you find the training phase where the FederatedAveraging algorithm is implemented in the case of the federated environment or just the generation and execution of agents for the independent learning approach. The rest of the code is functions that we used in between, and code that we used to collect data to evaluate the models. You can find in Appendix D and Appendix E, the complete implementation of the federated and independent environment. 3.4.2 Agents Basically, each of the agents has instanced a DQN class and a datacenter class. To be more concrete, •Edge Agent: –Instance of DataCenter Edge Agent unbalancedload x srv size.py, Appendix H. –Instance of DQN edge Agent.py, Appendix B. •Superior Agent: –Instance of DataCenter Sup Agent unbalancedload x srv size.py, Appendix I. –Instance of DQN.py, Appendix A. Mainly, the agents process the incoming request by selecting the action to be done, then pass the request and action to be done to the datacenter and it returns the next state and the reward obtained. Finally, the agents apply the method learn() of the DQN to perform an update. The main function of the agents is called run(). You can the code of the edge agent in Appendix F and the code of the superior agent in Appendix G. 25 Agent r avg del edge per del sup per accepted per Agent 1 10.88 16.23% 2.34% 81.44% Agent 2 11.10 16.04% 2.42% 81.54% Agent 3 11.27 15.44% 2.51% 82.05% Agent 4 11.52 14.63% 2.48% 82.89% Table 6: Mean value per agent Federated env. Now, an overload situation is presented where all the agents are set with a textitProb gen req = 0.8. With this situation what we want to know is how the model with a huge amount of incoming requests. Tables 7 and 8 show the average values obtained after simulating 10 times an overload situation. Agent r avg del edge per del sup per accepted per Agent 1 10.94 27.47% 0.00% 72.53% Agent 2 10.97 22.97% 3.82% 73.21% Agent 3 10.11 20.91% 1.30% 77.79% Agent 4 11.26 21.67% 4.14% 74.19% Table 7: Mean percentage values per edge agent Independent env. overload situation Node num delegated edge num delegated sup num accepted Agent 1 7917 0 20900 Agent 2 6646 1105 21178 Agent 3 6061 376 22548 Agent 4 6278 1198 21489 Table 8: Mean percentage values per edge agent Independent env. overload situation In addition, tables 10 and 10 show the average values obtained after simulating 10 times an overload situation. 32 Node r avg del edge per del sup per accepted per Agent 1 9.70 22.29% 2.30% 75.41% Agent 2 10.25 19.80% 2.75% 77.45% Agent 3 9.80 21.98% 2.42% 75.59% Agent 4 10.10 19.82% 2.54% 77.64% Table 9: Mean percentage values per edge agent Federated env. overload situation Node num delegated edge num delegated sup num accepted Agent 1 6365 658 21545 Agent 2 5682 792 22227 Agent 3 6288 694 21615 Agent 4 5689 730 22285 Table 10: Mean percentage values per edge agent Federated env. overload situation After taking a closer look at the tables above, is observed that the agents in the federated learning have delegated fewer requests to the other edge agents reducing the amount of requests in the queues, which has led to a higher acceptance percentage than in the independent environment. Moreover, the policy learned by the federated learning is much smoother and more suitable for stressful situations, meaning that as all the edge agents delegate less between them and delegating more requests to the superior agent than the agents of the independent environments reduced the amount of rejection rate of the evaluations that can be seen in the following table. mean 5.86% 75% 6.30% max 8.70% (a) Federated env. mean 7.8% 75% 8.68% max 11.15% (b) Independent env. Figure 19: Rejection rate overload situation 33 5 Conclusions and future development In this thesis, we have studied a fog computing architecture that uses a federated reinforcement learning algorithm in the problem of off-balancing requests through a cluster. After the results obtained on the two scenarios, one environment with the federated reinforcement learning solution and the other environment with a deep reinforcement learning solution, it can be concluded that the use of a federated learning algorithm has not been more beneficial in situations where the stress is small or medium. However, in situations of high stress where there are a large number of incoming requests, the federated learning agents have handled much better this situation, reducing the rejection rate while using three actions in some percentage and accepting more requests in the edge agents which was a goal set at the beginning. Nevertheless, I must point out that I was surprised by the independent environment solution given that the advantage of using a federated learning algorithm is that it allows you to combine the knowledge of other agents. In these environments, when using different sizes of available resources of each agent’s datacenter, we thought that the federated learning algorithm would learn a policy that would make the environment work much better under a varying resource situation. However, the independent environment solution has been able to learn a good policy that has allowed it to adapt to this varying factor. This highlights the power of deep reinforcement learning in these situations. Future lines of action would be to simulate more complex environments where federated learning might be able to come up with a better solution, such as adding priority to requests and the probability of an agent’s failure. 34 References [1] Jungyeon Baek and Georges Kaddoum. Floadnet: Load balancing in fog networks with cooperative multiagent using actor–critic method. IEEE Transactions on Network and Service Management, 20, 2023. [2] Patrick Guillemin, Friedbert Berens, Marco Carugi, Henri Barthel, Alain Dechamps, Richard Rees, Carol Cosgrove-Sacks, Jamie Clark, Marilyn Arndt, Latif Ladid, George Percivall, Bart Lathouwer, Steve Liang, Ovidiu Vermesan, and Peter Friess. Internet of Things – From Research and Innovation to Market Deployment Chapter 4 - Internet of Things Global Standardisation - State of Play. 06 2014. [3] Mohammad Goudarzi, Marimuthu Palaniswami, and Rajkumar Buyya. A distributed deep reinforcement learning technique for application placement in edge and fog computing environments. IEEE Transactions on Mobile Computing, 22(5):2491–2505, 2023. [4] Jung-yeon Baek, Georges Kaddoum, Sahil Garg, Kuljeet Kaur, and Vivianne Gravel. Managing fog networks using reinforcement learning based load balancing algorithm. In 2019 IEEE Wireless Communications and Networking Conference (WCNC), pages 1–7, 2019. [5] Ranesh Naha, Saurabh Garg, and Andrew Chan. Fog computing architecture: Survey and challenges. 11 2018. [6] Tom Luan, Longxiang Gao, Zhi Li, Yang Xiang, and Limin Sun. Fog computing: Focusing on mobile users at the edge. Comput. Sci., 02 2015. [7] Donald Knuth. Knuth: Computers and typesetting. [8] Pengfei Hu, Sahraoui Dhelim, Huansheng Ning, and Tie Qiu. Survey on fog computing: architecture, key technologies, applications and open issues. Journal of Network and Computer Applications, 98:27–42, 2017. [9] Flavio Bonomi, Rodolfo Milito, Jiang Zhu, and Sateesh Addepalli. Fog computing and its role in the internet of things. In Proceedings of the First Edition of the MCC Workshop on Mobile Cloud Computing, MCC ’12, page 13–16, New York, NY, USA, 2012. Association for Computing Machinery. [10] Ashkan Yousefpour, Caleb Fung, Tam Nguyen, Krishna Kadiyala, Fatemeh Jalali, Amirreza Niakanlahiji, Jian Kong, and Jason P. Jue. All one needs to know about fog computing and related edge computing paradigms: A complete survey. Journal of Systems Architecture, 98:289–330, 2019. [11] Subhadeep Sarkar and Sudip Misra. Theoretical modelling of fog computing: a green computing paradigm to support iot applications. IET Networks, 5(2):23–29. [12] Jiaju Qi, Qihao Zhou, Lei Lei, and Kan Zheng. Federated reinforcement learning: Techniques, applications, and open challenges. CoRR, abs/2108.11887, 2021. [13] H. Brendan McMahan, Eider Moore, Daniel Ramage, and Blaise Ag¨uera y Arcas. Federated learning of deep networks using model averaging. CoRR, abs/1602.05629, 2016. [14] Tian Li, Anit Kumar Sahu, Ameet Talwalkar, and Virginia Smith. Federated learning: Challenges, methods, and future directions. CoRR, abs/1908.07873, 2019. 35 [15] Jose L. Salmeron, Irina Ar´evalo, and Antonio Ruiz-Celma. Benchmarking federated strategies in peer-to-peer federated learning for biomedical data. Heliyon, 9(6):e16925, 2023. [16] Qiang Yang, Yang Liu, Tianjian Chen, and Yongxin Tong. Federated machine learning: Concept and applications. CoRR, abs/1902.04885, 2019. [17] Sudipan Saha and Tahir Ahmad. Federated transfer learning: concept and applications. CoRR, abs/2010.15561, 2020. [18] Hao Jin, Yang Peng, Wenhao Yang, Shusen Wang, and Zhihua Zhang. Federated reinforcement learning with environment heterogeneity. In Gustau Camps-Valls, Francisco J. R. Ruiz, and Isabel Valera, editors, Proceedings of The 25th International Conference on Artificial Intelligence and Statistics, volume 151 of Proceedings of Machine Learning Research, pages 18–37. PMLR, 28–30 Mar 2022. [19] H. Brendan McMahan, Eider Moore, Daniel Ramage, and Blaise Ag¨uera y Arcas. Federated learning of deep networks using model averaging. CoRR, abs/1602.05629, 2016. [20] Xiang Li, Kaixuan Huang, Wenhao Yang, Shusen Wang, and Zhihua Zhang. On the convergence of fedavg on non-iid data, 2020. 36