In this section, the proposed system for dynamic computation offloading is presented.
Problem statement
The problem of computation offloading is addressed in this paper for the IoT-Fog-Cloud system. The problems of response time, delay, and energy utilization of mobile devices are addressed, especially for real-time IoT applications such as Smart City, Self-driven Cars, IoT Retail Shops, Smart Homes, Farming, Wearable, Smart Grids, and Industrial Internet among others. The mobile devices’ heavy data generation especially when it involves video and images and the limitations of mobile devices in terms of processing capability and battery life were considered. We, therefore, present a dynamic tasks scheduling algorithm for IoT-Fog-Cloud task offloading to achieve high network performance in terms of response time, energy utilization, delay, resource utilization, and throughput.
System overview
We consider a network of N IoT devices, J fog devices, and K Virtual Machine (VMs) such that n = {1, 2, 3 … N}, j = {1, 2, 3 … J}, and k = {1, 2, 3 … K} as in Fig. 1. The IoT devices are connected to the Fog nodes through a smart gateway. The Fog nodes are connected to the cloud, thereby creating a hierarchical network continuum to the cloud. When tasks are coming from the IoT, the IoT evaluates the task to determine whether the task can be processed at the IoT, in fog, or the cloud-based on where the response time, energy consumption, and delay will be minimized while throughput and resource utilization of the network is maximized.
IoT layer
The IoT layer generates and measures the tasks based on the data involved in each task. They offload those tasks that involve heavy data size and are highly computational intensive to a higher processing node (fog or cloud). They also receive responses to the processed tasks from fog and cloud. IoT devices offload tasks with heavy data size and high computational intensive because of their limitations of processing capacity and battery life [39, 40].
Network layer
The network node is made up of a gateway and router which sometimes can function as fog devices in a small-scale network [41,42,43]. In this work, the smart gateway is used for data validation. It secures the network by evaluating the data coming from each IoT device using the Neuro-Fuzzy logic model [16]. The Neuro-Fuzzy model checks the incoming data, if invalid data is detected, the data will be discarded while the IoT device that sent the data will be requested to resend the data.
Fog layer
The fog layer comprises fog devices. Fog devices are systems with higher configurations than mobile devices but with lesser than cloud infrastructures. Fog devices can perform all the functionalities of the cloud, though their processing capabilities and storage are lower than that of the cloud systems. They support localized services and data analytics closer to the user [44,45,46]. Fog devices can be installed on the roadside unit or on moving cars.
Cloud layer
The cloud layer is made up of high powerful configuration systems. They have infinite processing and storage capacity. The cloud devices consist of high computational intensive devices, which can be public or private. The public cloud is provided as a service over the internet. The public cloud is based on multi-tenancy architecture. The user doesn’t need to purchase any hardware or software. The acquisition of hardware and software are the responsibilities of the provider. But the user has to pay based on their agreed prizing model. It can be based on pay-as-you-use, yearly, or based on duration, etc.
The private cloud is the cloud infrastructure provided and managed by the corporate enterprise. It is always deployed within the firewall of their network. The user will always have full control of the private cloud. The duration of storage and services do not affect the cost [47, 48].
Optimal device selection
Multiple objectives optimization problems have been attempted by many researchers in different ways [33, 48, 49]. We adopted the available processing capability (APC) of the processing resources in calculating the fitness function to determine where to process the request. Our proposed device selection approach combined the good qualities of genetic algorithm (GA) and particle swarm optimization (PSO) in device selection while dynamically considering the highest APC of the resources. In this subheading, we present the GA part, PSO part, fitness function, and finally the proposed algorithm.
GA part of the proposed algorithm
The proposed algorithm begins by initializing tasks and the available devices as shown in Fig. 2. After initialization of the tasks and available resources, the algorithm will check for the fitness function according to Eq. (3). If the tasks-resource allocation fits the fitness function, the process terminates else, the process will continue with the selection operator, crossover operator, and mutation operator as shown in Figs. 3, 4, and 5 respectively until the maximum iteration set for GA is reached. When the maximum iteration set for GA is reached without convergence, which is determined by the proposed fitness function, GA will pass its output to the PSO part of the proposed algorithm.
PSO part of the eh-GA-PSO algorithm
At the PSO part of the proposed algorithm, the chromosomes will be initialized based on the result from the GA part. The tasks – resources allocation will be checked for the fitness function using Eq. (3).
We considered PSO suitable for this study because mobile devices behave similarly to a swarm [16]. PSO has been applied in similar areas in science and engineering. For instance, in prediction [50], and alignment optimization [51]. In a fog environment, connectivity is through wireless connection sometimes, the resources are dynamic. The changes may be a result of weather, mobility of IoT devices, bandwidth fluctuation, and other factors in the network. Because of these reasons, the workload at the fog node changes frequently. To ensure the reliability of IoT getting responses as when due, there is a need to consider the data involved in a particular request, the bandwidth, and the processing capability at the fog, that can yield the best response time to the IoT request. PSO is a meta-heuristic algorithm that imitates the intelligence of a swarm. It uses communication and learning as its basic principles. Individual particles create their route to the optimal solution and communicate with every member. Every member of the particles gets this information and learns the best course of action to take. They will create a single global optimal solution for the whole swarm. This cooperation and intelligence exhibited by the swarm makes them achieve results faster [52]. As stated earlier, it is assumed that the IoT devices behave like swarms that can change their location thereby affecting the bandwidth and processing capability at the fog node or cloud node. The objective of PSO is to find the optimal solution through individual particles’ cooperation and communication among themselves to find the global optimal solution. Assuming we have a certain number of tasks (I) hereafter referred to as particles and J fog nodes or K cloud VMs referred to as dimensional search space, the individual particles changes their position and velocity according to Eqs. (1 and 2) [52]
$$X\left(t+1\right)=X(t)+V\left(t+1\right)$$
(1)
where X(t + 1) is the position for the particle at t + 1 time, X(t) is the position of the particle at t time and V(t + 1) is the velocity of the particle at t + 1 time.
The new velocity at t + 1 time is calculated in Eq. (2)
$$V\left(t+1\right)=\omega V(t)+{C}_1R\left(0,1\right)\ast \left({X}_{pbest}-X(t)\right)+{C}_2R\left(0,1\right)\ast \left({X}_{gbest}-X(t)\right)$$
(2)
where V(t) is the current velocity for the particle, ω is the inertia weight, C1 and C2 are the weighting coefficients for the personal best and global best positions, respectively. Xpbest is the particle’s best-known position. Xgbest is the global best-known position of the particles, and R is a random number between 0 and 1.
Difference and similarity between PSO and GA
PSO is like a genetic algorithm because both systems are initialized with a population of randomly sampled solutions. But PSO is different from GA because each possible solution is also allocated a randomized velocity and the possible solution are then flown among the problem space [52].
Fitness function for optimal device selection
We considered the availability of fog node devices or VMs by their Available Processing Capability (APC). The APC of all available devices will be ranked with a value (w1) and optimal device selection will be based on Eq. (3)
$$f\left({x}_i\right)={w}_1 ApC\left({x}_i\right)$$
(3)
where xi represents the particular task in consideration and i ranges from 1 to the number of available tasks (I).
The proposed enhanced hybrid genetic algorithm and particle swarm optimization algorithm (eh-GA-PSO)
In this paper, we proposed an Enhanced hybrid Genetic Algorithm and Particle Swarm Optimization Algorithm (eh-GA-PSO). The eh-GA-PSO algorithm aims to schedule the workflow tasks over the available fog and cloud VM resources. The eh-GA-PSO algorithm is used for the allocation of tasks coming from the IoT devices to the optimal fog or VM machines based on where the system can achieve higher network performance in terms of response time, energy utilization, delay, and resource utilization, and throughput. The eh-GA-PSO algorithm is presented in Fig. 6. GA-based algorithms produce better results than other algorithms especially when the iteration size is big. But with a high iteration size, means that the device selection process will take longer to reach the optimal solution [28]. On the other side, PSO-based algorithms always produce better results faster than other algorithms. But the problem of PSO based algorithms is that sometimes their result may not be accurate due to the speedy convergences, which at times make the PSO based algorithms to be trapped in the local optima solution [29,30,31]. Because of the advantages of GA producing a more accurate result and PSO converging faster, we, therefore, proposed the eh-GA-PSO algorithm to eliminate the disadvantages of GA taking too much time to converge and PSO being trapped in the local optima. The eh-GA-PSO uses the available processing capability of the resource to determine the fitness function as presented in Eq. (3). This is achieved by truncating the iteration process of the GA halfway if the fitness function is not yet attained at that level and then feeding the output of GA to PSO. With the half-processed result from GA, PSO will not start with a random selection. Instead, it starts with a nearly optima solution from GA. Because PSO did not start with initial random selection, it will not be trapped in the local optima solution. Secondly, the whole process will converge faster than allowing GA to complete the whole iterations process till convergence.
Proposed Dynamic Tasks Scheduling Algorithm (DTSA)
In this paper, we propose Dynamic tasks scheduling algorithm (DTSA) based on attribute reduction. We proposed an enhanced hybrid Genetic Algorithm and Particle Swarm Optimization for optimal device selection as presented in Fig. 7. Given an offload-able task from an IoT device, the task needs to be processed and a response received within the expected time limit. However, mobile devices are limited in processing capacity, storage, and energy. The energy of the mobile device (IoT device) needs to be maximally utilized. A generalized system model of the proposed attribute reduction-based secured offloading scheme is presented in Fig. 8. The task from the mobile device involves data that can be expressed in the tensor format with a certain r rank − 1 for r ϵ {1, 2 … R}. r = 1 means that the tensor is decomposed into 1 vector for each dimension of the tensor while r = R means that the tensor is decomposed into R vectors for each dimension of the tensor. Canonical Polyadic Decomposition (CPD) decomposes original data to a certain percentage of the original data according to the CPD data decomposition ratio presented in our previous work [53]. The data transmitted over the network through CPD at times result in a slight change in the data accuracy. The essence of decomposing the data is to reduce its size during transmission over the network to reduce the transmission time and improve bandwidth usage. Therefore, to choose the r-value that will guarantee certain accuracy (AC), Eq. (4) is applied.
$$AC=\upalpha \mathrm{ln}(R)+\beta$$
(4)
AC is the accuracy of the data analysis given R rank-1 values and β is the constant for estimating the AC [53]. Figure 7 presents the algorithm used to schedule the tasks generated at the IoT layer among the available devices at the IoT, fog, or cloud layer based on the fitness function of the task. The fitness function of the tasks is calculated in Eq. (3). The objective of the algorithm is to minimize the latency. The latency is calculated in Eq. (5)) [16]. While Eq. (6) is the enhanced latency when attribute reduction is applied during offloading to reduce the data size.
$$L\left({x}_i\right)=\frac{sz_i\times {cx}_i\times {u}_i+ bs\left({x}_i\right)}{F\left({x}_i\right)}$$
(5)
$${L}_R\left({x}_i\right)=\frac{sz_{iR}\times {cx}_i\times {u}_i+ bs\left({x}_i\right)}{F\left({x}_i\right)}$$
(6)
L(xi) ≥ LR(xi) where szi, cxi denotes the size and complexity of the task, sziR is the reduced data size after passing through CPD, Ui denotes the mean latency of the task, bs, and F are the current buffer size and CPU frequency of the fog or VM machines.