## 6 Conclusions and Future Work  
5G networks with their significantly higher speeds, lower-latency, reliability, capacity, and other benefits offer a powerful communication platform for ubiquitous environments. The complexity of today's ubiquitous environments have become increasingly complex due to the emergence of collaborative edge, fog, and cloud paradigms. However, privacy and security of users and data will pose paramount challenges in the adoption of these ubiquitous environments by governments, industry, and common people. A particular challenge in this context would be to preserve privacy and security while delivering quality of service (QoS) and energy-efficiency. Several works have tried to address one or more of these challenges (QoS, energy efficiency, security, and privacy) in distributed environments. Figure 4: UbiPriSEQ: Performance vs. Task and Data Sizes (**a**) PrivacyMetric, (**b**) SINR, (**c**) Latency, (**d**) Utility. Despite these efforts, a number of challenges exist. Firstly, the focus of the existing approaches is on improving or optimizing one or two of the design parameters; QoS, energy efficiency, security or privacy. Optimizing one or more parameters without measuring and counteracting their impact on other parameters is no more acceptable in the emerging ubiquitous environments. Secondly, existing approaches assume a fixed network configuration and attack models, and use fixed strategies in devising solutions. The ultimate aim is to optimally migrate and place data, analytics, and other computations in these environments such that security, privacy, energy efficiency and QoS demands of these applications and the environments are best satisfied [8; 70; 71; 72; 73]. In this article, we proposed UbiPriSEQ that uses DRL to adaptively, dynamically, and holistically optimize QoS, energy-efficiency, security, and privacy. The Framework is built on a three-layered model and comprises two modules. UbiPriSEQ devises policies and makes decisions related to a number of important parameters including local processing and offloading rates for data and computations, radio channel states, transmit power, task priority, selection of fog nodes for offloading, and data migration. We evaluate UbiPriSEQ and compare it with the CMDP-based approach [44]. The results of our modular approach show clear performance gain over the CMDP-based approach as well as addresses other challenges that the CMDP-based approach does not address (e.g., security). Our UbiPriSEQ framework is novel for several reasons. In contrast to the existing state-of-the-art, we attempt to holistically optimize QoS, energy efficiency, security, and privacy. Also, UbiPriSEQ is designed using a modular approach. It adaptively and dynamically deals with the environment by continuous learning, and does not need a priory complete specification of the environment, security attack models, and other design parameters. Moreover, DRL has not been used before in 5G networks to provide adaptive intelligence. Finally, most existing works use simulated data for performance evaluation while we have used SpMV, a real-life application to study UbiPriSEQ performance, and this has not been reported before. The SpMV operation is central to deep learning algorithms and this per se would create a significant impact. We would like to note here that while the experimental results reported in this paper show that UbiPriSEQ outperforms CMDP [44], the excellence of one scheme over the other cannot be proved by a set of simulated experiments. Although we have given some valid justifications for UbiPriSEQ outperforming CMDP (see the last paragraph in Section 5), this is not a mathematical and absolute proof that UbiPriSEQ is better than CMDP. Many deeper investigations and actual deployments of the proposed work are needed to understand and improve the proposed approach. Nevertheless, we believe that UbiPriSEQ does provide overall a better approach for network design and operations due to its holistic and modular approach.