An Energy‐Aware Technique for Task Allocation in the Internet of Things using Krill Herd Algorithm

—The Internet of Things (IoT) is an innovative technology that connects the digital and physical worlds as well as allows physical devices capable of different capacities to share resources to accomplish tasks. Most IoT objects have limited battery life and are heterogeneous. Assignment of these objects is, therefore, extremely challenging. Energy consumption and reliability are the primary objectives of task allocation algorithms. We present an optimization solution to the IoT task allocation problem based on the krill herd algorithm. The algorithm increases the energy efficiency and stability of the network while providing a reliable task allocation solution. An extensive test of the proposed algorithm has been conducted using the MATLAB simulator. Compared to the most relevant method in the literature, our algorithm provides a higher level of energy efficiency.


I. INTRODUCTION
In recent years, the rapid development of wireless and emerging technologies, particularly the Internet of Things (IoT), Blockchain [1], 5G connectivity [2], cloud computing, smart grids [3], optical networks [4,5], machine learning [6], and artificial intelligence [7,8] has provided many advantages. The IoT has recently been praised as a major technological advancement. As the name implies, it is a system specifically designed to connect computers, electronic and mechanical devices, and items equipped with unique identifiers capable of transmitting data over computer-to-human or human-to-human relationships [9]. Its primary goal is to mobilize network components for active cooperation and to make their resources available for certain applications. Developing the IoT sample requires the coordination and execution of smart items and the ability to interoperate significantly [10]. The concept of interoperability describes how nodes collaborate in a collaborative application using resources, including storage, processing, electrical energy, and object potential, to accomplish a task [11]. A crucial issue in IoT is task allocation, in which tasks can be executed within certain boundaries [12]. The task assignment aims to increase network performance [13]. IoT presents many challenges due to its heterogeneity, scale, properties, continuous processing, and shared sense [14]. The task allocation process cannot be completed in a centralized manner, with frequent scenarios being adjusted [15]. The IoT consists of ubiquitous networking involving many nodes spread across a wide area [16]. The quick changes in the network make it impossible for nodes to determine network topology. Therefore, integrating nodes and reconfiguring them are challenging. IoT task allocation is a common NP-hard problem. Solving this problem requires a meta-heuristic algorithm [17].
Customer service quality is adversely affected by IoT task allocation. Performance and quality of responses will be greatly impacted by how these tasks are performed, or in other words, how resources are allocated to requests. Based on evolutionary algorithms, various methods for allocating tasks in the IoT exist. Among the best ways to improve IoT device performance is to implement better resource allocation algorithms, which would decrease operational costs and reduce communication delays. According to [18], a better task allocation solution can lead to IoT devices providing users or information systems with enhanced services. Finding a final solution to an NP-hard problem takes substantial computation time. By employing an intelligent guessing strategy, metaheuristic algorithms can quickly find optimal solutions to task allocation. Meta-heuristic algorithms are much faster than algorithms that evaluate all possible solutions sequentially. Meta-heuristic algorithms usually produce better results than greedy algorithms.
IoT paradigm realization requires the development of cooperative intelligent objects with key interoperability capabilities. Among these interoperability characteristics is the coordination among nodes in order to develop and deploy applications collaboratively, taking into account the limited resources available for a given task, such as electrical energy, memory, processing, and object capability [19]. IoT task allocation is crucial in finding a perfect match between scheduled tasks of an application and Edge-based devices to ensure instant response and efficient utilization of resources. In order to avoid problems concerning energy consumption and response time, we need a protocol for optimizing the process of allocating processing devices to tasks. This problem is considered an NP-hard problem.
In recent years, some studies have solved the task allocation problem using different meta-heuristic algorithms [20,21]. Although meta-heuristic algorithms usually produce superior results than conventional methods, many areas remain to be improved. Our primary objective is to propose an improved meta-heuristic algorithm for solving the IoT task allocation issue. Our contributions include the following: www.ijacsa.thesai.org number of hops between the first and last node of a task execution) and the capabilities of nodes correspond or near to the task capabilities.
 The krill herd algorithm is used to verify both parameters and determine the best path nodes.
 Assign task allocation capabilities to the nodes on the best path.
The remaining sections of the paper are organized in the following manner. The Section II outlines IoT challenges and reviews previous IoT task allocation methods. A detailed description of the proposed method appears in Section III. The results of the experiments are presented in Section IV. The paper is concluded in Section V.

A. IoT Challenges
IoT presents many technical and management challenges, despite its ability to create a billion-device network. Most of these challenges can be summed up as follows.
 Security and privacy: As the IoT evolves new security and privacy challenges arise due to applications implemented and objects communicating over lossy networks. Due to IoT devices' limited power and processing capacity, it is not easy to apply encryption algorithms [22].
 Availability: As new devices, services, and connected things emerge, accessing the desired node presents a challenge [24].
 Scalability: The architecture of an IoT network can change at any time as new nodes are added. The scalability of nodes needs to be verified by forming a global architecture. The solution should address different aspects of the problem [25].
 Mobility: Device mobility in IoT brings challenges, and IoT must ensure continuous global connectivity without disrupting communications [26].
 Reliability: IoT platforms, applications, and systems must be fully operational, aggregate data from multiple sources, and rely on reliable communication protocols. Constraint nodes should be able to respond quickly to an emergency at any time [27].
 Interoperability: As IoT devices have a wide range of platforms, protocols, and systems, the challenge is interoperating these heterogeneous platforms, protocols, and systems. Interoperability refers to the ability of nodes to exchange information [28].
 Low power energy communication: In IoT devices, low power consumption leads to long life cycles, low leakage currents, low charge-discharge rates, and quick startup times. Utilizing other energy resources or using lightweight algorithms can reduce overall power consumption [29].

B. IoT Task Allocation
Colistra, Pilloni [30] discussed the resource allocation issue for distributed IoT applications and middleware architectures that could provide solutions. Additionally, a consensus protocol was proposed for distributing the execution load among network objects to allocate resources efficiently. A homogeneous allocation of resources among nodes is demonstrated using the proposed protocol. Compared to the optimal allocation obtained with a centralized method, the algorithm converges with about a 6% error based on simulations and real-world experiments.
Khalil, Ozdemir [31] formulated the task allocation problem as an optimization problem with a single objective of reducing energy consumption. They proposed two approaches based on different objectives. These protocols are then injected with heterogeneity-aware heuristics that account for the different energy levels of network entities. To maximize the stability periods, they developed two more protocols, which reduce the interval before each virtual object dies. Different measurements and benchmarking parameters are used to evaluate the proposed protocols, and they are compared with the most relevant algorithms available. Regarding stability and energy consumption, the proposed protocols outperform existing work in the literature.
Low-latency IoT services are provided by fog-aided IoT networks, which offload computationally intensive, timesensitive tasks to fog nodes located in the local area. IoT networks feature enhanced flexibility thanks to battery-limited mobile IoT devices. The QoS of mobile IoT may be degraded due to varying wireless channel conditions. A task allocation algorithm analyzed by Yao and Ansari [32] reduces average task completion latency by distributing tasks to different fog nodes and adapting to different mobile environments constrained by QoS requirements and the power of mobile IoT devices. Integer linear programming is then used to formulate the problem. Collecting mobility patterns and information from the user takes much work. A task allocation algorithm based on online learning was proposed and demonstrated through extensive simulations.
Sensitive delays, efficient resource allocation, and reliable transactions challenge IoT. To address these issues, Xiao, Gao [33] Introduced a blockchain-based IoT architecture that ensures the integrity of resource transactions and service providers' profits. In addition, they proposed the Task Offloading and Resource Allocation (TO-RA) algorithm, which is implemented as smart contracts on the blockchain. Based on blockchain's advantages, the proposed architecture optimizes resource allocation in IoT. To complete task offloading, they proposed a subtask-virtual machine mapping strategy. Then, based on the task offloading strategy, stack cache supplementation was proposed to complete resource allocation and address possible load imbalances in the system. The TO-RA algorithm outperforms conventional approaches regarding efficiency, reliability, and consistency. www.ijacsa.thesai.org The computational model developed by Mebrek and Yassine [34] considers energy consumption and transmission latency when offloading tasks in IoT applications. The competition was modeled as a game in which IoT devices decide how to distribute their tasks based on energy consumption and latency. The authors propose a decentralized task distribution algorithm in which players update their strategies based on the actions of other players. Nash equilibrium is proven to be achieved by the proposed algorithm. The computational model is then evaluated extensively and compared with existing studies. Najafizadeh, Salajegheh [35] proposed a multi-objective simulated annealing algorithm to secure task allocation on cloud and fog nodes. A goal-programming approach is applied in order to discover a compromise solution. Additionally, a new goal referred to as "client-driven access level and schedule" is created regarding the distribution of tasks between fog and cloud nodes. Compared to moth-flame optimization, tabu search, and PSO algorithms, the proposed algorithm showed improved efficiency regarding deadlines by 50%, accuracy by 88%, and service delivery by 10%.
Hussain and Begh [36] implemented Hybrid Flamingo Search with a Genetic Algorithm (HFSGA) to optimize task scheduling for cost minimization. On seven essential benchmark optimization functions, HFSGA is compared with other well-known optimization algorithms. Furthermore, Friedman Rank Tests are conducted to ascertain the results' significance. It produces better results in terms of task completion percentages, makespan, and costs when implemented. As compared to existing algorithms such as round-robin, genetic, PSO, and ACO, this work shows better results.
Weikert, Steup [37] proposed a multi-objective task assignment method in dynamic IoT networks prone to mobility and failure issues. They combined and improved upon task allocation optimization algorithms for error-prone and mobile networks by predicting future node positions and archiving data to enhance diversity. An elitism mechanism preserves satisfactory outcomes. Consequently, this algorithm allocates IoT tasks despite node failures and considers future node positions simultaneously. Various error rates and mobile node counts are used in the evaluation. The investigation revealed enhanced network lifetime, latency, and availability metrics.

III. PROPOSED METHOD
This section proposes an algorithm for solving the problem of task allocation. Two parameters determine the assignment of tasks: the ability to execute subtasks by a given node and the path distance required to execute those subtasks. The issue declaration is defined in the first subsection, and the proposed method is described in detail in the second subsection.
A. Problem Statement G = (V, E) represents task allocation as a graph, where nodes denote tasks, while edges indicate routes between tasks. A user's applications are divided into numerous tasks with sequential maintenance connections, and tasks are attached using a directed acyclic graph (DAG). The edges are all of the same form (i→j) and i, j∈N. Nodes represent tasks, and edges represent communications between them. J cannot be executed until the implementation of i is finished, and once all of its parents are complete, j becomes ready. In an edge from i to j, i is the parent node of j, and j is its child. Each DAG node has a weight corresponding to its computation cost, and each edge has a weight corresponding to its connection cost. An example of a DAG is shown in Fig. 1.   Fig. 1. A simplified DAG for IoT task allocation.

B. Network Model
As shown in Fig. 2, the adopted IoT architecture for this study includes four layers: perception, network, service management, and application. Low-level tags, such as RFID and bar codes, make up the perception layer. In this layer, sensors and smart devices collect and process information in real time. In the network layer, several technologies are used to provide the necessary networking features. Sensors and smart devices create a high volume of Internet data objects that the www.ijacsa.thesai.org embedded features in this layer should support. In the service management layer, information is analyzed, security is controlled, processes are modeled, and devices are managed. Sensor data can be alternated or non-intermittently sent. Task allocation is also part of its responsibilities. The application layer classifies programs based on real-time requirements, business models, convergence, and network type.

C. Krill Herd Algorithm for IoT Task Allocation
The krill herd algorithm solves continuous optimization problems using swarm intelligence. According to some studies, it is more efficient than some existing algorithmic approaches. It is simple to implement, robust, and only requires one control parameter (time interval) compared to other swarm-intelligence methods. The krill herd algorithm searches for food by traversing a multidimensional search space, where krills traverse various variables to make decisions. The distance between rich food and krills corresponds to the cost function. Three operational processes determine the location of a krill individual over time, including motion-induced processes, foraging movements, and random physical diffusion. Krill movements are visualized based on two distance measurements: the minimum distance between a krill and food sources and the least distance between each krill and the biggest herd. An n-dimensional decision space can be expressed in Eq. (1), in which i=1 to nk represents the number of krills, Di represents indiscriminate diffusion, Fi represents foraging activity, and Ni represents movement caused by other krill individuals. Krill movement can be expressed as Eq. (2). The variables in Eq. (2) are defined in Table I. (1) The forager's enjoyment of the food area determines the foraging movement using Eq. (3). Also, Eq. (4) is used to calculate the equation for sensing distances. In these equations, refers to the last foraging motion, ω f is inertia weight ranging between 0 and 1, V f is foraging speed, and N is movement induced by every krill. Krill physical diffusion can be calculated by Eq. (5) as a random process, in which δ is a random directional vector [−1 &1], and D max is the maximum diffusion speed.

, (
) ̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅ ̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅ - Eq. (6) calculates the position vector, where UB and LB are upper and lower bounds, C t is constant between 0 and 2, and NV is the variable amount.
Good results will be obtained when the estimation vector values appear to be optimal. Eq. (7) and (8) provide genetic and mutation operators.
The krill herd algorithm solves the IoT task allocation problem by mapping the solution to the location of the krill group. Assuming T = (T 1 , T 2 , ..., T m ) and R = (R 1 , R 2 , ..., R n ), allocation results can be described by matrix x = [x ij ], i, j = (1, 2, ..., n), when T i is allocated on R j , xij = 1. Alternatively, if the x ij value is 0, they can be used to determine a krill group's position. It simulates induced movement and feeding to determine the optimal location of krill groups so that IoT tasks can be allocated optimally. IoT task allocation using the krill herd algorithm involves the following steps:  Set parameters for krill herd, such as the maximum number of iterations and the number of krill groups.
 The initial krill group position is generated based on the location of IoT resources. Each position of the krill corresponds to a scheme for allocating IoT resources.
 Obtaining the fitness function for each krill and evaluating the merits and demerits of each krill.
 The speed and position of krills are updated randomly to generate a new population of krills.
 If the termination condition of the algorithm is not satisfied, then proceed to step (4).
 The optimal allocation of IoT tasks is determined by the optimal location of the krill population.

IV. EXPERIMENTAL RESULTS
In this section, a comparative analysis of the suggested task allocation method is presented based on the application DAG as well as connection costs (Fig. 1). The use of MATLAB is attributed to its ability to calculate matrix and calculation functions, perform practical functions, and exchange data with different programming languages. It focuses on computational methods and provides high-level programming capabilities. Mathematical issues in joint academic mathematics are presented in MATLAB. Therefore, MATLAB R2012a is used to simulate the proposed method.
We used the dataset from [38] as a basis for this study. A task allocation policy in the IoT directly impacts application performance and the best use of resources. Identifying the optimal way to assign tasks in the IoT is a significant challenge. The procedure for assigning tasks in the IoT environment is as follows. At first, tasks and resources are mapped based on this task and resource data. Consequently, by mapping resources among tasks, applicators can ensure task www.ijacsa.thesai.org yield and QoS. In the end, the submitting user receives an overview of the consequences.
The convergence diagram for the method is shown in Fig. 3. Results show that about 180 generations of the proposed algorithm led to the correct answer. To prove that the proposed algorithm meets the repeatability criteria, it was repeated 20 times, 40 times, 60 times, 80 times, and 100 times. The stability diagram of the proposed algorithm is shown in Fig. 4. It is clear that successive iterations do not produce significantly different results. Consequently, the proposed algorithm is repeatable and robust.
Energy consumption is directly affected by IoT task allocation. Data centers in IoT structures can reduce their energy consumption by moving low-or idle-load servers to other servers, shutting them down, and shifting idle workloads to other servers. Fig. 5 shows the energy consumption of different algorithms for different task counts. According to the results, the suggested algorithm offers greater energy efficiency than others by increasing the number of tasks.

V. CONCLUSION
The primary objective of most IoT networks is to enable devices with varying capabilities to share their resources and cooperate in order to accomplish a desired function. The majority of IoT objects are heterogeneous in nature and have limited computational and energy capabilities. Consequently, assigning tasks to these objects presents a significant challenge. Most of the existing works in the literature use heuristic optimization techniques to address different aspects of the task allocation problem without taking into account the heterogeneity of the objects or the limits of their resources. This paper aimed to demonstrate the feasibility of developing meta-heuristic algorithms to assign and schedule IoT tasks. Based on the krill herd algorithm, a new method is proposed for scheduling tasks that minimize network latency and ensure energy efficiency. Our solution outperformed other algorithms, such as PSO and simulated annealing, when choosing optimal assignment decision policies for task assignments and scheduling. Further, our approach ensured low-latency communication and energy efficiency by optimizing both local and global processes. We intend to examine the similarity between the task capabilities in future work in order to predict the execution path of the tasks. To achieve even better results, we plan to explore how the task capabilities can be better coordinated by comparing them against one another.