## 6 The Framework  
To develop an efficient service selection and composition approach that can provide minimum energy costs and optimal QoS for customers, we propose a new adaptive and dynamic system based on NSGA-II for multi-objective optimization and cooperative agents with more capacities like intelligence, scalability, and efficiency. Our goal is to ensure coordination between different agents of the IoT-Fog-Cloud ERP system. Such a method discovers relevant services based on customer needs while selecting services with high QoS and optimal energy cost, and provides a continuously optimized composite service based on context changes and/or customer preference changes. To achieve this goal, we use CxQSIoT FogCloudSERP ontology, the multi-agent approach, and multi-objective optimization NSGA-II. Using both QoS and energy saving and modified NSGA-II multi-agents improves the solution accuracy, minimizing the execution time and energy consumption, and it is effectively used in remote controlling smart services ERP appliances, monitoring the state of the products with an exact angle measurement.  
We present a new multi-objective function based on both QoS and energy consumption for selecting the optimal personalized composite service and saving energy with satisfactory accuracy and minimal execution time. To exploit this new multi-objective function, we propose two modes: dynamic and adaptive. The dynamic mode consists of three service management layers, IoT, Fog, and Cloud. The adaptive mode allows adaption of some business process parts according to different context changes and customer preferences to integrate IoT and Fog services and compose them with Cloud services. Such dynamic and adaptive modes are believed to efficient and economical, to be (potentially) utilized in several virtual services and their corresponding concrete services. They are stored, respectively, in distributed virtual service registries and concrete service registries of smart interactive devices, Fog servers, and Cloud. We leveraged the advantages of ontology-based agents by forming a well-hierarchical service management model to reduce the discovery time of appropriate services and to target potential service providers.  
The work presented here focuses on a typical scenario, production, and transport process in a wheel production domain, as described in Section 2, and on different agents  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**QoS** & **Iterative Flow** & **Parallel Flow** & **Choice Flow** & **Repeat Flow** \\ \hline Time & \(\sum_{j=1}^{n}Time_{j}\) & \(Max_{j=1}^{n}Time_{j}\) & \(Max_{j=1}^{n}Time_{j}\) & \(Time_{j}*k\) \\ Security & \(Min_{j=1}^{n}Sec_{j}\) & \(Min_{j=1}^{n}Sec_{j}\) & \(Min_{j=1}^{n}Sec_{j}\) & \(Sec_{k}\) \\ Availability & \(\prod_{j=1}^{n}Av_{j}\) & \(\prod_{j=1}^{n}Av_{j}\) & \(Min_{j=1}^{n}Av_{j}\) & \(\left(Av_{j}\right)^{k}\) \\ Cost & \(\sum_{j=1}^{n}Cost_{j}\) & \(\sum_{j=1}^{n}Cost_{j}\) & \(\sum_{j=1}^{n}Cost_{j}\) & \(Cost_{j}\times k\) \\ \hline
**Energy** & \(\sum_{j=1}^{n}Energy_{j}\) & \(\sum_{j=1}^{n}Energy_{j}\) & \(\sum_{j=1}^{n}Energy_{j}\) & \(Energy_{j}\times k\) \\ \hline \hline \end{tabular}
\end{table}
Table 3: QoS and Energy Process Metrics.  
to generate an optimized smart ERP business process, as illustrated in Figures 1 and 2. In this work, we have used the multi-agent platform Jade [40] for cooperative IoT, Fog, and Cloud services composition. The CxQSIoTFogCloudSERP ontology is implemented using Protege [41] to match customer needs to virtual services using inference rules.