# Edge and Cloud Computing in Smart Cities
## 2 Architectural Models for Edge and Cloud Computing in Smart Cities
### Multi-Tier Hierarchical Architecture
Assuming \(N\) devices, the device layer is formally defined as  
\[D=\{D_{1},D_{2},\ldots,D_{N}\},\quad D_{n}=(P_{n},S_{n},L_{n}), \tag{4}\]  
where each device \(D_{n}\) is characterized by \(P_{n}\) processing capacity, constrained due to hardware and energy limitations, \(S_{n}\) available storage, primarily used for buffering and temporary data retention, and \(L_{n}\) inherent latency, influenced by local computation and network transmission delays. Given these constraints, IoT devices offload computationally demanding tasks to the Edge and Cloud Layers to optimize performance, reduce energy consumption, and enable real-time analytics [22]. Assuming a set of tasks \(\mathcal{T}\), a task \(\tau\in\mathcal{T}\) can be executed either at the edge or the cloud, with partial execution allowed. The optimization model for balancing task execution between the edge and cloud layers is formulated as  
\[\min_{\alpha_{i}}\sum_{i=1}^{K}\Bigl{(}\alpha_{i}T_{E_{i}}+(1-\alpha_{i})T_{C} \Bigr{)}, \tag{5}\]  
where \(\alpha_{i}\in[0,1]\) (execution ratio) determines how much of task \(\tau\) is executed at \(E_{i}\), with the remaining portion offloaded to the cloud [23]. The term \(T_{C}\) used in this equation refers to the total execution time when the task is processed in the cloud, encompassing both the network transmission delay and cloud processing latency. In contrast, the edge processing delay \(T_{E_{i}}\) accounts only for the local execution time at edge node \(E_{i}\), which is generally lower but subject to resource constraints. To ensure balanced workload distribution, constraints are imposed on computational resources at both the edge and cloud layers, which prevent edge nodes from exceeding their capacity  
\[\sum_{\tau\in\mathcal{T}}\alpha_{i}C_{\tau}\leq C_{E_{i}},\quad \forall E_{i}\in E, \tag{6}\] \[\sum_{\tau\in\mathcal{T}}(1-\alpha_{i})C_{\tau}\leq C_{C}. \tag{7}\]  
The term \(C_{E_{i}}\) represents the total computational capacity available at edge node \(E_{i}\), meaning that the total workload assigned to \(E_{i}\) cannot exceed this limit. This ensures that edge nodes are not overloaded, maintaining low-latency processing and preventing performance degradation. Similarly, \(C_{C}\) represents the total computational capacity available in the cloud. Since the cloud has significantly higher processing power, this constraint prevents excessive offloading that could lead to network congestion or increased response times. \(C_{\tau}\) represents the computational demand of task \(\tau\). In these equations, \(\alpha_{i}\) determines the fraction of task \(\tau\) that is executed at edge node \(E_{i}\), while \((1-\alpha_{i})\) represents the fraction offloaded to the cloud. If \(\alpha_{i}=1\), the task is fully executed at the edge, and no workload is sent to the cloud. Conversely, if \(\alpha_{i}=0\), the task is completely offloaded to the cloud. When \(0<\alpha_{i}<1\), the task is partially executed at the edge, with the remaining part offloaded to the cloud, ensuring a hybrid execution strategy. These constraints work together to distribute tasks efficiently, ensuring that edge computing resources are fully utilized without exceeding their processing limits while preventing the cloud from being overwhelmed by offloaded tasks. Additionally, a latency-aware decision function determines the most suitable execution location  
\[F(\tau)= \begin{cases}E_{j},&\text{if }T_{E_{j}}+T_{D\to E_{j}}\leq T_{ \text{C}}\\ C,&\text{otherwise}.\end{cases}  \tag{8}\]  
This decision function ensures that a task is executed at an edge node \(E_{j}\) if the sum of the edge execution time \(T_{E_{j}}\) and the transmission time from the device to the edge \(T_{D\to E_{j}}\) is lower than the total cloud execution time \(T_{C}\), which includes both network delay and cloud processing time. Otherwise, the task is offloaded to the cloud. This dynamic decision mechanism enables the efficient allocation of computational resources based on real-time network conditions and task execution requirements.