# Replicating File Segments between Multi-Cloud Nodes in a Smart City: A Machine Learning Approach
## 5 Using Machine Learning for Partial Replication and Selecting the Candidate Node
This equation takes into account the various parameters that influence the task's execution time, such as the file size, disk size and the server's processing power, memory size and network bandwidth. By substituting in the relevant values for each server, we can determine which server offers the shortest duration to execute the task that accesses the replicated file segment. Utilising multivariable linear regression and Equation (54) enables us to select the most efficient server for a given task based on multiple parameters, leading to a significant reduction in task execution time and increased system performance. The topology \(\Xi\) is presented in Equation (1) where it represents the interconnectionsbetween nodes in a system. These nodes are either clouds or edge servers and the possible alternative for node communication is as follows:  
1. Communication between two clouds,
2. Communication between two edge servers,
3. Communication between a cloud and an edge server. Note that in this paper it is assumed that graphs are bi-directional. In other words, the communication cost from node \(n_{1}\) to node \(n_{2}\) is the same code from node \(n_{2}\) to node \(n_{1}\). As mentioned above, topology \(\Xi\) represents connection among all nodes regardless whether they are clouds or edge servers. Topology \(\Xi\) is represented as follows:  
\[\Xi\equiv\langle\Phi,\Omega,\Psi\rangle \tag{8}\]  
Sub-Topology \(\Phi\) represents the interconnections among different clouds. \(\Phi\) is represented as follows:  
\[\Phi\equiv\mathbb{C}\times\mathbb{C} \tag{9}\]  
which is the cross product between the set of clouds and itself, this given an \(n\times n\) square matrix and \(n=\|\mathbb{C}\|\). Sub-Topology matrix \(\Phi\) is filled as follows:  
\[\Phi(i,j)= \begin{cases}\Phi(i,j)=1&\text{if $i=j$}\\ \Phi(j,i)=1&\text{if $c_{i}$ and $c_{j}$ are connected.}\\ \Phi(j,i)=0&\text{if $c_{i}$ and $c_{j}$ are not connected.}\end{cases}  \tag{10}\]  
Equation (10) describes how matrix \(\Phi\) is filled, the first case is when it is a diagonal element of the matrix and in this case, the element is always 1 since every cloud is reachable from itself. The second case is when two clouds \(c_{i}\) and \(c_{j}\) are directly connected together where the element is set to 1. The third and final case is when the element is not a diagonal and two clouds intersecting at this element where there is no direct connection that links the two of them, that is when the element is set to 0. The second sub-topology is \(\Omega\) which represents the connections between edges. This is an \(m\times m\) square matrix and \(m=\|\mathbb{E}\|\). Sub-Topology \(\Omega\) can be formulated as follows:  
\[\Omega\equiv\mathbb{E}\times\mathbb{E} \tag{11}\]  
Sub-Topology matrix \(\Phi\) is filled as follows:  
\[\Omega(i,j)= \begin{cases}\Omega(i,j)=1&\text{if $i=j$}\\ \Omega(j,i)=1&\text{if $e_{i}$ and $e_{j}$ are connected}\\ \Omega(j,i)=0&\text{if $e_{i}$ and $e_{j}$ are not connected}\end{cases}  \tag{12}\]  
Equation (12) describes how matrix \(\Omega\) is filled. The first case is when it is a diagonal element of the matrix and, in this case, that element is always 1 since every edge is reachable from itself. The second case is when two edges \(e_{i}\) and \(e_{j}\) are directly connected together and that is when the element is set to 1. The third and final case is when the element is not a diagonal and two edge servers intersecting at this element where there is no direct connection that links the two of them; that is when the element is set to 0. The third sub-topology is \(\Psi\) which represents the connections between edge servers and clouds, this is an \(n\times m\) matrix where \(n=\|\mathbb{C}\|\) and \(m=\|\mathbb{E}\|\). Sub-Topology \(\Psi\) is formulated as follows:  
\[\Psi=\mathbb{C}\times\mathbb{E}\cup\mathbb{E}\times\mathbb{C} \tag{13}\]Note here that, since the topology is represented as a bipartite graph, the union of the equation is necessary since the order here matters as it defines the flow direction.