Wireless sensor networks (WSN) have gradually integrated into the concept of the Internet of Things (IoT) and become one of the key technologies. This paper studies the optimization algorithm in the field of artificial intelligence (AI) and effectively solves the problem of node location in WSN. Specifically, we propose a hybrid algorithm WOA-QT based on the whale optimization (WOA) and the quasi-affine transformation evolutionary (QUATRE) algorithm. It skillfully combines the strengths of the two algorithms, not only retaining the WOA’s distinctive framework advantages but also having QUATRE’s excellent coevolution ability. In order to further save optimization time, an auxiliary strategy for dynamically shrinking the search space (DSS) is introduced in the algorithm. To ensure the fairness of the evaluation, this paper selects 30 different types of benchmark functions and conducts experiments from multiple angles. The experiment results demonstrate that the optimization quality and efficiency of WOA-QT are very prominent. We use the proposed algorithm to optimize the weighted centroid location (WCL) algorithm based on received signal strength indication (RSSI) and obtain satisfactory positioning accuracy. This reflects the high value of the algorithm in practical applications.

1. Introduction

With the development of the Internet of Things (IoT) to this day, it can be said that the basic task originally conceived has been completed, namely, the interconnection of human, machine, and things [1]. However, people are no longer satisfied with the simple networking and put forward higher requirements. As the rapid expansion of scale, IoT has produced an alarming amount of real-time monitoring data [2]. There is no doubt that scientific management of these data requires a “Super Brain”, and intelligence has become an inevitable choice for the evolution and upgrade. Artificial intelligence (AI) is fully qualified for this role. The history of AI is much longer than that of IoT, but it has been plagued by the difficulty of technical development and the lack of kinetic energy for achievement transformation. In recent years, AI has made breakthrough progress at the technical level, which makes people full of confidence and hope for its future. How to guide AI from the laboratory into various real application scenarios is a challenging task. The booming IoT has provided a broad stage for AI to fully release its potentia, and the naturally existing data sources continuously provide power for it. Relying on the mature platform built by IoT, AI can meet the most urgent demand for technology landing. Although IoT already has a considerable volume in terms of industrial chain and scale, many key technologies still need to be polished and improved. IoT has been thinking for a long time to seek considerable progress and sustainable development, and the empowerment of AI just opens an important window of opportunity for its development. Therefore, the term AIoT (Artificial Intelligence of Things) came into being, which can be understood as the integration of AI and IoT.

AI covers a wide range of technologies, in which the optimization algorithm has received extensive attention from researchers. Among many optimization algorithms, the metaheuristic algorithm is the most active. Some of them are inspired by the evolution phenomenon in nature, represented by genetic algorithm (GA) [3] and differential evolution algorithm (DE) [4]. Some algorithms are inspired by biological collective behavior, including particle swarm optimization (PSO) [5], artificial bee colony algorithm (ABC) [6, 7], Cat swarm optimization (CSO) [8, 9], WOA [10, 11], and symbiotic organism search algorithm [12, 13]. Some are related to physical or mathematical rules, such as black hole (BH) [14, 15] and QUATRE [16, 17]. Unfortunately, there is no one algorithm capable of solving all optimization problems according to the NFL theorem [18]. This has stimulated researchers’ endless enthusiasm, either proposing new algorithms and technologies, or improving existing ones [19, 20], or combining different ones [21]. It is found that the hybrid strategy of the algorithm is worth trying in many cases. This article mixes two algorithms, WOA and QUATRE, and introduces the technology of dynamically shrinking the search space. In the test of the benchmark function, it is found that the hybrid algorithm has made great progress.

As the key core technology of IoT, WSN has been extended from military applications originally to a large number of civil fields, such as environmental and ecological protection, medical and health monitoring, agricultural planting, traffic management, and logistics management [22]. The main research contents of WSN include network topology control and network protocol, node deployment [23, 24], network security [25, 26], location technology, and data fusion and data management. The development of WSN also faces many challenges. For example, how to use the limited communication ability to complete the transmission of sensing data needs further research. And how to maximize the service life of the network through low-power design is also an urgent problem to be solved. This paper introduces the optimization algorithm into the node location problem of WSN and achieves satisfactory location accuracy.

The rest of this article is as follows: the second part is the related research work, mainly for the brief introduction of WOA and QUATRE; the third part discusses the combination and improvement strategy of the two algorithms in detail; the fourth part is the statistics and analysis of experimental data based on benchmark functions; the fifth part is to use the algorithm to realize the location in WSN; and the last part is the summary and outlook.

2.1. Whale Optimization Algorithm (WOA)

As a metaheuristic optimization algorithm based on swarm intelligence, WOA is exquisitely designed and full of characteristics. It simulates the hunting behavior of humpback whale groups. Inspired by this hunting method, WOA designed three models: searching for prey, encircling prey, and bubble-net attacking. First, initialize the position of each whale: , which represents an -dimensional candidate solution. Through the cooperation of two stages of exploration and exploitation, the best position is gradually found (i.e., the optimal solution).

Three vectors appear in the algorithm: and . and are defined as follows: where is a random vector between . As the iteration progresses, decreases linearly from 2 to 0. Therefore, , . There is a random number , which is used to indicate the selection probability of the updated mode. The random vector and the random number jointly control the conversion between exploration and exploitation. Vector has different representations at different stages. The operation symbol means multiplying item by item, and means taking the absolute value.

(1) Exploration: searching mode

WOA’s exploration phase mimics the process of whales searching for prey in the ocean. Use a randomly selected search agent to update the solution. To achieve the goal of global search, the search agent is forced to leave the reference whale. The position update formula for exploration is as follows:

is the solution vector at the iteration. represents a random solution in the current population. When and , Equation (2) will be used to update the solution vector.

(2) Exploitation

The exploitation phase of WOA includes two modes: encircling mode and bubble-net attacking mode.

2.1.1. Encircling Mode

Once humpback whales find their prey, they surround them. Since the best position is unknown, it is assumed that the current best solution is the destination or the approximate best position. Other search agents will update their position with reference to the current optimal, as shown in Eq.(3):

denotes the current optimal. When and , the solution will be updated by the above formula.

2.1.2. Bubble-Net Attacking Mode

Bubble-net attacking is the most distinctive hunting method of humpback whales. In addition to swimming around prey, whales also move along a spiral path. WOA creates a spiral equation to simulate through the distance, as shown in the following formula:

Here, the distance between and is recorded as , which can be understood as the distance between the whale and its prey. The constant is used to define the shape of the logarithmic spiral. is a random number between . When , Equation (4) will be used to generate a new solution.

2.2. QUasi-Affine Transformation Evolutionary (QUATRE) Algorithm

QUATRE is a coevolutionary algorithm based on quasi-affine transformation. As a new structure of evolutionary calculation, it can be used to solve the problem of distributed bias in the DE algorithm. The evolution formula is similar to the affine transformation, as shown below:

Suppose there are -dimensional solution vectors , which constitute a population matrix: . There are two matrices: the donor matrix and the coevolutionary matrix . The operator represents the bitwise multiplication of matrix elements. and are mutually inverse matrices, and and they are both binary matrices (matrix elements only take 0 or 1).

2.2.1. The Coevolutionary Matrix

The QUTARE algorithm considers that all search agents in the population have the same status. By the cooperative structure, the search agents cooperate with each other and share information. The initialized matrix is constructed, and then, through a series of transformations, the coevolutionary matrix is obtained.

There are three methods for constructing . The specific choice depends on the size relationship between the population size and the search space dimension . If , is a -dimensional binary lower triangular matrix, as shown in Equation (6). When , needs to be expanded. If , is a matrix of -dimensional binary lower triangular matrices stacked vertically. If , the first rows are handled according to the previous situation, and the rest take the first lines in Equation (6), as shown in Equation (7). Next, can be obtained after two steps of transformation of . First, the elements of each row in are randomly arranged. Then, the elements of each row vector remain unchanged while their positions in the matrix are randomly arranged. So we can get , see

2.2.2. The Donor Matrix

The donor matrix dominates the way of evolution. Similar to the different mutation strategies in DE, there are many ways to generate . The mode used here is called QUATRE/best/1, as shown in

Assume that the population matrix of the generation is , which consists of -dimensional candidate solutions . Each has an evolution guide vector corresponding to it. represents the best individual in the population. and are generated by randomly arranging the row vectors of . is the scaling factor.

3. The Hybrid Algorithms Based on WOA and QUATRE (WOA-QT)

The metaheuristic algorithm has two basic elements: exploration and exploitation. The task of exploration is to trial different solutions in the search space and try to find the global optimal. The task of the exploitation is to search in the local scope and fully tap the optimization opportunities brought by the current optimal. Ideally, if the two stages can cooperate with each other and realize smooth transition, the local optimum can be avoided and the optimal solution can be found finally [27].

WOA has proved to be superior to some advanced optimization algorithms, for example, PSO, DE, GSA, and fast evolutionary programing (FEP) [28]. It provides multiple update modes and strives to balance the relationship between exploration and exploitation. But inevitably, it still faces many problems, such as how to further improve the exploration ability, release the exploitation potential, and avoid local optimization. Local optimal stagnation and slow convergence are its two main disadvantages. In order to improve the ability to escape from the local optimum, this paper introduces the QUATRE algorithm into WOA and use the strategy of dynamically shrinking the search space to improve time efficiency. In this part, we will analyze the causes of the problems in detail and explain the relevant countermeasures.

3.1. The Combination of WOA and QUATRE

Although WOA has two different exploitation models, both of them are highly dependent on the current optimum. When the problem is a multimodal function or a complex function, there is a risk of falling into a local optimum. How to deal with this situation requires careful consideration.

QUATRE is a coevolution algorithm, which uses matrix mode calculation and concise parameters. From the point of view of statistics and probability theory, the moving way of individuals is more reasonable in the process of evolution. In addition, the coevolutionary matrix in the algorithm can perceive the structure of objective function more comprehensively, which makes the search of solution space more effective.

Based on the above considerations, this paper proposes a hybrid algorithm based on WOA and QUATRE. The specific idea is to embed QUATRE in the exploitation stage of WOA. The current optimal solution plays an absolute dominant role in both the encircling mode and the bubble-net attacking mode. The QUATRE algorithm can be used to preprocess the current optimal, and the effect is equivalent to perturb the current optimal solution in accordance with statistics and probability theory to make up for the lack of randomness and diversity. The fusion method of the two algorithms in the encircling mode is as follows:

Here, the current optimal solution is processed by the QUATRE to get , which will replace to guide the position update of the encircling mode in the exploitation stage.

Similarly, in the bubble-net attacking mode, the fusion of the two algorithms is also performed, as shown in the following formula:

replaces to guide the position update of the bubble-net attacking mode during the exploitation phase. In the proposed WOA-QT, Equations (9) and (10) will still have a 50% probability of being selected.

QUATRE has different mutation strategies, which emphasize different focuses of search capabilities [29, 30]. The mode QUATRE/best/1 is concise in form which only uses the current optimal solution and two randomly selected solutions and . dominates the evolution of the population, so that individuals with higher fitness values can be fully utilized to perform good local search, and the convergence speed is faster. Although the combination of the two algorithms has increased the randomness of the population, we choose QUATRE/best/1 as the mutation strategy to avoid overcorrection. Therefore, both the population diversity is ensured and the convergence speed is also taken into account. Therefore, both the population diversity is ensured and the convergence speed is also taken into account.

3.2. Strategy of Dynamically Shrinking Search Space (DSS)

The candidate solution should gradually approach the global optimal solution. The general trend is that the size of search space will decrease as the iteration progresses. However, the search space of WOA is always the size at the time of initialization. It is obviously unreasonable to roam randomly in such a fixed-size space, which may cause delay in the optimization process. In this paper, we propose a mechanism to dynamically shrink the search space, which is used in the exploration phase of WOA. As the optimization proceeds, the upper and lower limits of the selection range of the random solution will change accordingly, so that the size of the search space is gradually reduced, thereby improving search efficiency. The specific method is as follows:

First define four variables: the upper limit of the newly generated search space , the lower limit of the newly generated search space , the largest solution component of the current iteration , and the smallest solution component of the current iteration . The initial values of the above variables are set according to the initial size of the search space. where represents the current number of iterations and is the maximum number of iterations. As the iteration progresses, will decrease approximately linearly according to Equation (11), and will increase approximately linearly according to Equation (12). As a result, the exploration scope is gradually reduced, and the global optimum is constantly approached. The random solution in the exploration process is now generated from a dynamically shrinking search space defined by and . And the contraction speed is not too fast, which can effectively avoid local optimal stagnation.

3.3. Hybrid Algorithm WOA-QT

This section describes the optimization steps of WOA-QT. The pseudo code is shown in Pseudocode 1.

(1) Initialization: generate individuals randomly to form population . Set initial values to parameters in WOA and QUATRE. Specify the maximum number of iterations and parameters related to the size of the search space (including initial upper limit and lower limit , the upper limit and lower limit of search space after each iteration, the maximum solution component and minimum solution component of the current iteration).

(2) Evaluation: calculate each individual’s fitness value . By comparing with each other, determine the individual who currently has the best fitness value.

(3) Update: choose one of the modes to update the individual’s position.

(i) Exploration: whenand, use Equation ((2)) to update the solution. That is to select a random solutionin the current search space (between the upper limitand lower limit).

(ii) Exploitation (A)When and , use Equation (9) to update the solution. This is the WOA encircling mode embedded with QUATRE(B)B. When , use Equation (10) to update the solution. This is the WOA bubble-net attacking mode embedded with QUATRE

(4) Reevaluation: re-evaluate the population to find the best individual . And shrink the size of search space according to the Equations (11) and (12).

(5) Termination: repeat steps (3) to (4). If a predefined function value has been obtained or all iterations have been completed, record the global optimal solution and its best fitness value . The optimization process ends here.

Generate initial population X containing N individuals .
Initialize the parameters related to the algorithm: a, r, b, prob, t, max_iter.
Initialize two matrices in QUATRE:
 the coevolutionary matrix M (Eq. (6) or Eq. (7)).
 the donor matrix B (Eq. (8)).
Initialize the parameters related to the search space size:
ub = ub_new = ub_max.
lb = lb_new = lb_min.
Calculate the fitness value of each solution.
X = the best individual.
While (t < max_iter) and (not obtain the predefined function value).
For each solution.
 Update a, r, b, l, prob, M, B.
  If1 (prob <0.5).
  If2 ().
   Update the position of the current solution using Eq. (9).
  Else if2 ().
   Select a random solution Xrand.
   Update the position of the current solution using Eq. (2).
  End if2.
Else if1 ().
   Update the position of the current solution using Eq. (10).
  End if1.
End for.
 Check if any solution goes beyond the search space and amend it.
 Calculate the fitness value of each solution.
 Update X if there is a better solution.
t = t +1.
 Shrink the search space size using Eq. (11) and (12).
End while.
Return X

4. Experiment Results and Analysis

This part selects 30 benchmark functions for performance evaluation, as shown in Tables 1, 2, and 3. Most of the benchmark functions come from literature [31], including three categories: unimodal, multimodal, and fixed-dimension complex functions. We also separately evaluate the performance in solving low-dimensional and high-dimensional problems. The selected unimodal functions and multimodal functions are scalable functions covering low and high dimensions. All the experiments were compared among WOA-QT, WOA, and QUATRE. Each algorithm runs independently 40 times. The specific experimental scheme is as follows.

4.1. Experiments for Low-Dimensional Unimodal and Multimodal Functions

First, the low-dimensional unimodal functions and multimodal functions are tested, and the dimension is set to 30. The comparative indicators we selected include the minimum (i.e., optimal value), medium, maximum, mean, and standard deviation values of each experiment. Figure 1 shows the convergence curve of each function.

In the test of 10 unimodal functions, we can see that WOA-QT has achieved the first place in the comparison of the optimal values for 9 times (F1-F6, F8-F10). Compared with the other two algorithms, WOA-Q’s optimization accuracy and convergence speed have been significantly improved, showing excellent local search capabilities. In addition, WOA-QT also has an absolute advantage in the comparison of other statistical data, which shows that its performance stability is far better than WOA and QUATRE.

From the experimental results of 10 multimodal functions, we can see that WOA-QT has an absolute advantage in the ranking of all indicators. This shows that it can effectively avoid falling into the local optimal.

4.2. Experiments for High-Dimensional Unimodal and Multimodal Functions

This experiment continues to use the test functions from the previous section but expand the dimension to 500. The conclusion of this experiment is basically consistent with that of the last one. The WOA-QT still maintains good performance in high-dimensional situations. Please see Figure 2 for the function convergence curves.

4.3. Experimental Results of Fixed-Dimension Complex Function

We also tested 10 fixed-dimension complex functions. It is found that the comprehensive performance of WOA-QT is still the best of the three. Figure 3 shows the function convergence curves obtained in this experiment.

4.4. Analysis of Experiment Results

In this paper, different types of benchmark functions are selected for testing for the sake of the scientificity and fairness of evaluation. It also examines the algorithm’s ability to solve scalable dimensional problems.

When solving the unimodal problem, WOA-QT embodies the outstanding local exploitation ability. In the face of multimodal problems, it can well avoid falling into local optimum. Both optimization accuracy and speed benefit greatly from the effective hybrid mechanism of the two algorithms. In addition, when the dimension of the problem space expands or shrinks, or when the problem is gradually complicated and the amount of calculation increases suddenly, WOA-QT still maintains reliable optimization performance, especially with a satisfactory convergence speed. The high time efficiency proves the effectiveness of the DSS strategy.

5. Node Location in WSN

WSN, RFID, cloud computing, and wireless data communication, etc., together constitute the technical foundation of IoT. Among them, WSN is not only an important information collection subject of the perceptual layer of IoT but also a basic transmission channel of the network layer. WSN plays a vital role in how to realize the intelligent perception, transmission, processing, and application of data in IoT. There are many research topics in WSN, among which node location has always been a research hotspot. Because the monitoring data with unknown location information is usually meaningless, and the location problem is the basis and premise of most applications, the performance of the sensor node location algorithm directly affects its usability. The commonly used evaluation indicators include location accuracy, scale, node density, and power consumption. This paper uses the proposed WOA-QT algorithm to solve the node location problem in WSN. Specifically, it is to intelligentize the node location algorithm to further improve the positioning accuracy.

Although there are many node location algorithms, they can be classified into range-based and range-free. Range-based location algorithm calculates the position of unknown nodes by measuring distance or angle information. Commonly used ranging technologies include Time of Arrival (TOA), Time Difference of Arrival (TDOA), Received Signal Strength of Indicator (RSSI), and Angle of Arrival (AOA). Range-free localization algorithm only determines the node position according to the connectivity of the network and other information without knowing the distance or angle. The commonly used methods are convex programming, DV-hop, centroid location algorithm, and so on.

Different location algorithms have their own advantages and disadvantages. The location algorithm used in this paper integrates RSSI ranging and weighted centroid positioning algorithms (WCL_RSSI), which can improve positioning accuracy to a certain extent. To meet the requirements of further reducing the positioning error, this paper uses the proposed WOA-QT algorithm to optimize WCL_RSSI.

5.1. RSSI Ranging Technology

The principle of the RSSI ranging method is to convert the strength of the received wireless signal energy into the distance between the nodes, and then use it to estimate the location of the unknown node. Because no additional hardware is required, and the cost and power consumption are relatively low, the RSSI method is widely used, especially for large-scale WSN node location problems. However, environmental factors such as distance and obstacles will have a great impact on the transmission of wireless signals, resulting in severe attenuation of the signal’s power strength. This paper selects the log-distance distribution model as the distance measurement model of wireless signal propagation path loss, as shown below:

Assuming that the distance between the node to be located and the signal source is , indicates the signal strength received by the node; is the reference distance, generally ; is the path loss factor that reflects the influence of the environment on signal transmission. The more obstacles in the transmission path, the greater the value of ; is a random variable, obeying normal distribution: . By Equation (13), the distance can be obtained: .

There are beacon nodes in the target area: . is the unknown node. If the distance between and is too far, the signal power will be greatly attenuated, which will seriously affect the location accuracy. Generally speaking, the unknown node and the beacon node are not directly connected, and there may be several intermediate nodes between the two. Therefore, it can be considered that RSSI starts from the beacon node and is finally transmitted to the unknown node in a relay manner. The distance of the connection path between the two is recorded as . If intermediate nodes are passed, then , where can be obtained by Equation (13).

In order to convert to the Euclidean distance between and , this requires knowing the approximate proportional relationship between the two distances. Assume that the connection distance between two beacon nodes and is (can be obtained by RSSI ranging), and the Euclidean distance is

We define as the path scale factor of the beacon node , as shown below:

Obviously, the distance can be obtained with the following formula:

5.2. Weighted Centroid Location Algorithm Based on RSSI (WCL_RSSI)

It is not hard to see, if only relying on RSSI ranging to locate, the accuracy is poor. Therefore, a weighted centroid location algorithm (WCL) based on RSSI has emerged. The ordinary centroid location algorithm considers that all beacon nodes have equal status. In fact, different beacon nodes have different influences on the location of unknown nodes. The WCL algorithm is to reflect the degree of influence of each beacon node on the position of the centroid (i.e., the unknown node) through the weight factor. The triangle centroid positioning algorithm is used here. The pairwise distance between the unknown node and the three beacon nodes is recorded as (, , and ), which are used to construct the weight coefficient. The relevant formulas are as follows:

, , and represent three beacon nodes, and the coordinate of the centroid of the triangle enclosed by them is the position of unknown nodes .

WCL_RSSI has the advantages of low computational complexity, simple implementation and high location accuracy. Moreover, the location process is less affected by the change of the transmission environment and does not require interaction between nodes [32].

5.3. Apply the Proposed WOA-QT Algorithm to WCL_RSSI

This article uses WOA-QT to improve WCL_RSSI in order to obtain the node position with higher accuracy. In the two-dimensional plane, the solution of the WOA-QT corresponds to the candidate position coordinates of the unknown node, which is denoted as . The Euclidean distance between and the beacon node is . represents the location of unknown node estimated by the WCL_RSSI. Similarly, the distance between and is . Obviously, there is a deviation between and . It should be noted that the connection path between the unknown node and the beacon node has a great influence on the location accuracy. The greater the number of hops, the smaller the positioning error tends to be. The weight of hops needs to be considered when measuring the distance error. Therefore, the evaluation function is as follows:

There are beacon nodes. The hop number between the beacon node and the unknown node is recorded as . Equation (18) expresses the optimization goal, that is, to minimize the root mean square error of the difference between the two distances.

5.4. Simulation Results

Assume that in a two-dimensional area of , 60 beacon nodes are deployed, and the positions of 240 unknown nodes are to be determined. The communication radius of sensor node is 15 meters, and the maximum number of iterations of the algorithm is 400. Table 4 lists the average distance error between the unknown node position estimated by each algorithm and the true position. The simulation experiment involves five algorithms. Simulation results show that WCL_RSSI based on WOA-QT has the smallest error, and the positioning accuracy is improved obviously. In order to visualize the positioning error, Figure 4 marks the distance deviation between the estimated position of each unknown node and its true position.

6. Conclusion

AI and IoT are compatible and symbiotic, who are born to be the best partner. They have broken through the bottlenecks of their respective parallel developments, enabling high-frequency resonance and coordinated development.

In this paper, the optimization algorithm in AI is used to solve the node location problem in WSN which is the key technology of IoT. There are two optimization algorithms involved: WOA and QUATRE. WOA is derived from natural wisdom, and the QUARTRE has the beauty of mathematics. The two algorithms utilize each other and work closely together to form an organic whole. The overall optimization performance is much better than that when the two are separated. The potential of local exploitation is further tapped through the mutual fusion, so that the local stagnation is effectively avoided in the process of searching for the global optimal. Although algorithm hybridization will inevitably bring more calculations, but with the cooperation of the two algorithms and the DSS strategy, the time efficiency of the algorithm has not been affected, and even better in many cases. So the increase in complexity of this algorithm is worthwhile. With the help of optimization technology, the node location accuracy of WSN has been significantly improved. It can be said that a successful AIoT case with application value is realized.

The QUATRE algorithm has many variants. When combined with other algorithms, we can consider how to choose different variants adaptively [33]. In addition, the complexity caused by algorithm hybridization can be considered to use surrogate-assisted technology to ease [34, 35]. In the field of WSN, there are many challenging problems that need to be overcome [36, 37]. It can be combined with other AI technologies such as machine learning [3840] to promote the birth of more application scenarios of AIoT.

Data Availability

1. 30 well-known benchmark functions. 2. Random position location of sensor nodes by computers.

Conflicts of Interest

The authors declare no conflict of interest.