# Replicating File Segments between Multi-Cloud Nodes in a Smart City: A Machine Learning Approach
## 2 Problem Statement  
Increasing the performance of cloud responses to user requests is a major requirement for a better and smarter city [21]. The problem that this paper is solving can be summarised as follows: having a multi-cloud system with clouds that are interconnected and with multiple edge servers connected to clouds and/or other edge servers directly or indirectly, and with some clouds or edge servers that have file resources, it is required to replicate parts of files as needed so that they are accessible and reachable with minimum cost to edge servers. As will be seen in Section 5, the cost has different components with different weights depending on the node whether this node is a cloud or an edge server. Mathematically, the problem is defined as follows:  
The system \(\mathbb{S}\) is defined as:  
\[\mathbb{S}=\left\langle\mathbb{C},\mathbb{E},\mathbb{F},\Xi\right\rangle \tag{1}\]  
where:  
\[\mathbb{C}=\left\{c_{1},c_{2},c_{3},\dots,c_{n}\right\} \tag{2}\]  
where \(\mathbb{C}\) is the set of clouds in a multi-cloud system, and \(n=\|\mathbb{C}\|\) and \(c_{i}\) is cloud \(i\) where \(1\leq i\leq n\) and:  
\[\mathbb{E}=\left\{e_{1},e_{2},e_{3},\dots,e_{m}\right\} \tag{3}\]  
where \(\mathbb{E}\) is the set of edge servers connected to this multi-cloud system and \(m=\|\mathbb{E}\|\) and \(e_{j}\) is edge server \(j\) where \(1\leq j\leq m\) and:  
\[\mathbb{F}=\left\{f_{1},f_{2},f_{3},\dots,f_{l}\right\} \tag{4}\]  
where \(\mathbb{F}\) is the set of files that are being shared in the multi-cloud system, \(l=\|\mathbb{F}\|\) and \(f_{k}\) is distinct file \(k\) where \(1\leq k\leq l\) and \(\Xi\) is the topology that describes the inter-connectivity of the system. It is required to replicate segments of the shared files so that the overall cost of file sharing is minimum. The cost of replicating a file segment \(s\) so that certain node \(n_{d}\) accesses it is composed of:  
1. The transmission cost from the source node \(n_{i}\) to replica node \(n_{j}\)
2. The hosting cost of the replica \(n_{j}\)
3. The transmission cost from replica \(n_{j}\) to \(n_{d}\)  
Total cost \(\eta\) is defined to be:  
\[\eta=\beta_{1}\pi+\beta_{2}\rho+\beta_{3}\tau \tag{5}\]  
where \(\pi\) is the data hosting cost, \(\rho\) is the load on the hosting node, and \(\tau\) is the cost of data transfer delay. The difference between \(\pi\) and \(\rho\) is that \(\pi\) represents the cost of replicating certain file or file segment in certain node whereas \(\rho\) is the cost of raising load on certain node. Every node has its own weighting for \(\pi\), \(\rho\) and \(\tau\), and therefore every node learns \(\beta_{1},\beta_{2}\) and \(\beta_{3}\) from historic data. The final objective is to obtain \(cost\) where cost is defined to be:  
\[cost=Minimize\ \eta(c\in\mathbb{C}) \tag{6}\]  
Note that the unit costs for every independent variable in Equation (5) is determined by the host and the weights are learned through historical data. When replicating a file \(f\in\mathbb{F}\), the cost of data transfer and hosting depends on how big a file is. This means that replicating parts of the file could minimise both hosting and data transfer costs.