 Update set of solutions $P_{known}$ from $M''_{X}$
         \item $P_{X}$ = fitness selection from $P_{X}\cup M''_{X}$
    \end{enumerate}
    \EndWhile
   
    
    \State\textbf{Return:} Pareto set approximation $P_{known}$
    

\end{algorithmic}
\end{algorithm}

The GA is presented in Algorithm 1. Our solution checks if containers can be deployed on available client devices. Next, a random sample of solutions $P_0$ is initialized by selecting clients to deploy. Afterwards, the obtained solution is evaluated and repaired for any violations of the constraints. The violations are repaired as shown in Algorithm 2. Reparation is performed by moving containers to other client devices if the machine learning exceeds
(1) the resource capacity of a client
(2) the client’s staying period in a particular area
(3) the "high movement" threshold decided by the server.
Non-dominated ($Pareto$) solution is generated in Step 4 of the (GA). Afterward, normal selection, crossover,
and mutation operators are applied, infeasible solutions are repaired, and finally, the
Pareto set is updated if improvements are possible. This process is repeated in multiple iterations. In our GA algorithm, we use binary tournament selection in order to choose individuals from populations. The crossover method used is the one-point crossover where the crossover is probabilistically applied for each parent, controlled by a hyper-parameter. Moreover, for the mutation phase, the bit string mutation is used. The approach gives every gene a mutation probability of $1/L$, where L is the number of clients for deployment. This approach protects the algorithm from falling in the local optimum, maximizes the diversity and it gives a fair opportunity for clients with a low probability rate to engage with the mutation. The flow of activities can be seen in Figure \ref{fig10}.



The complexity time of this algorithm can be divided into multiple parts. First, we have the total number of populations, then initialize the base population, fix constraints, calculate the fitness, selection of parent, cross-over, and mutation. Let $G$, $M$, and $N$ be the number of generations, chromosomes, and the number of nodes respectively. In addition to that,  let $C_{selection} = O(N)$, $C_{crossover} = O(N\times M)$ and $C_{mutation}=O(N\times M)$ be the complexity time of selection, cross-over and mutation process respectively. Moreover, Let $C_{fitness}$ and  $C_{fix-violation}$ be the complexity time of calculating the cost (fitness value) and to fix if any violations to our constraints respectively.
Therefore, the overall complexity time will be:
O(G$\times$($C_{selection}$ + $C_{crossover}$ +$C_{mutation}$ +$C_{fitness}$ + $C_{fix-violation}$)).



\begin{algorithm}
\caption{Infeasible solution reparation}\label{alg:cap1}
 \textbf{Data:} Infeasible Solution $K$
 
 \textbf{Result:} Feasible Solution
\begin{algorithmic}
\State feasible = False; i = 0
\While{$i \le n$ and feasible == False} 
\If{$K_{i}$ is overloaded} \Comment{check if overloaded}
\State deploy the container on another capable client
\State in the same area location
\EndIf

\If{$K_{i}.availability \le T$} \Comment{check staying time}
\State deploy the container on another not
\State chosen client with high movements record
\EndIf

\If{$NN$ (nb of clients with high movement)$ \ge PE$}
\While{$NN \ge PE$}   \Comment{nb of high movement clients}
\State swap (high move $C$, not high move $C$)
\EndWhile

\EndIf


\EndWhile
\State\textbf{Return:} Repaired solution
\end{algorithmic}
\end{algorithm}





\section{EXPERIMENTS AND SIMULATION RESULTS}
In this section, we provide first a description of the data set used, the FL setup, the centralized model, the distribution of data over the clients, and the baseline approaches. Afterward, we state our results followed by a discussion and interpretation.

\subsection{Dataset}

The MOBILE DATA CHALLENGE (MDC) \cite{mario14} dataset is used in our learning. It consists of continuous records illustrating the movements of clients recorded over a period of time. We extracted from this dataset several features to help us predict the next place the clients are heading to. Global Positioning System (GPS) features were used to cluster 20 places and 6 area locations in a specific region on the map. Each area location contains different places. Time features were extracted and represented in several features like: day, month, year, weekend or weekday. We added an important feature to track the duration of a visit to a place by those users by calculating The duration of stay. Furthermore, frequency and rate of visits are extracted to track the locations of presence every month. Finally, the label class is added, corresponding to the next place a client visited in a specific duration of time.  

\subsection{Federated Learning Setup}
In order to run FL processes, we used Localfed \cite{marioo15}, which is a FL framework based on the FedML framework \cite{fedmll}. Localfed is known for its feasibility in applying FL applications using built-in components. These components are implemented in Python. It requires different parameters to control the behavior of the model. The trainer manager is responsible to define how the trainers are running, along with passing some parameters to define the number of epochs and loss. The aggregator instance is responsible to merge the collected models into a global model. The metrics component is responsible to test the model accuracy and loss on testing data after each round. Moreover, Trainers-data-dict defines the data of each client saved in dictionaries. After that, we define some parameters like the number of rounds, desired accuracy, train, and test data ratios.

Other components were added by us like Data Distribution and Base Model. The Data Distribution component was added to efficiently distribute the data to the clients. Since we are dealing with real-life dataset and specifically user-based. We assigned to each client the data of one user available in the dataset. This was done to simulate real-life scenario in which clients/users have the data on their side. The Base Model component is added in order to run any machine learning (ML) model under FL. 

\subsection{Centralized Model}
Before having a global model to be shared with the clients, we built a centralized model where the full training data has been used together. After many rounds of tuning hyper-parameters, Deep Neural Network \cite{neuraln} is used with three hidden layers of size 128 and 256. "Relu" and "softmax" activation functions are used. The input layer size is equal to the number of features we have and the output layer size is equal to the number of places in the dataset. The Adam optimizer is used with “categorical-cross entropy” loss function.

\subsection{Distribution of Data Over Clients}
There are 100 users in the dataset. Each client in our FL model is assigned the data of one user in the dataset. The data records fall between 200 and 1500 records. Since the problem is a multi-class classification task, the target feature defines the next place a user is going to by placing the Id number of this place. This partition follows a Non-iid data distribution since clients have different data partitions and class labels. 
In each learning round, the portion of deployed clients $C$ is decided by the optimization model. The set $C$ is not static since having less number of clients at early stages and more later is better for the learning process \cite{mario5}. This concept is implemented in our optimization model, so the number of deployed clients in each FL round is decided by the "Client Deployment" component represented in section IV.
\begin{figure}[]
	\centering
	\includegraphics[width=0.5\textwidth]{roundss.png}
	\caption{Completed vs discarded rounds in 50 FL rounds}
	\label{roundss}
\end{figure}


\subsection{Experiments and results}
We compared our approach to some of previous work:

\begin{enumerate}
    \item The static environment where constrained devices are (1) available in pre-defined locations and (2) not available to serve \cite{mario1}.
    \item The original FL selection problem (VanillaFL) \cite{mario12}, where clients participating in each round are randomly chosen.
    \item The centralized global model \cite{neuraln}.
\end{enumerate}

To prove the efficiency of our architecture, we conduct multiple scenarios answering multiple questions: 
\begin{enumerate}
    \item How does the availability of learning devices affect the learning process.
    \item How does the on-demand client deployment help the process of learning?
    \item How many rounds did the global model take to converge?
    \item