I. WSN model

Whale algorithm

2.1. Biological mechanism of whale optimization algorithm

FIG. 1 Schematic diagram of bubble feeding by humpback whales

According to research, certain regions of the whale’s brain have spindle cells similar to humans, and these cells are responsible for human judgment, emotion and social behavior. Whales have twice as many of these cells as adult humans, a major reason for their intelligence. Whales, it turns out, can think, learn, judge, communicate, and even become emotional like humans, but apparently at a much lower level of intelligence.

Whales (mainly killer whales) have also been observed to develop their own dialects. And the most interesting thing about humpbacks is the way they hunt. This foraging behavior is called bubble net foraging. Humpback whales like to hunt krill or small fish close to the surface. This foraging has been observed to be accomplished by creating distinctive bubbles along a circle or “9” shaped path, as shown in Figure 1. Until 2011, this behavior was only studied based on observations at the surface. Further research using sensors captured 300 tag-derived bubble feeding events in nine humpback whales. They found two bubble-related movements and named them “upward spiral” and “double loop.” In the former strategy, humpbacks dive 12 meters, then start creating a spiral bubble around their prey before swimming to the surface. It’s worth noting that bubble net feeding is a unique behavior that can only be observed in humpback whales. In this paper, the mathematical modeling of spiral foam net predation mechanism is introduced to achieve the purpose of optimization.

2.2. Mathematical model and optimization algorithm

1) Surround the prey

Humpback whales can recognize the location of prey and surround it. Since the position of the optimal design in the search space is not a priori known, the WOA algorithm assumes that the current best candidate solution is the target prey or close to the optimal solution. After the best search individual is defined, other search individuals attempt to update their location to the best search individual. This row is represented by the following equation:

​(1)

(2)

Where t represents the current iteration,andIs the coefficient vector, X star is the position vector of the best solution we have so far,As the position vector, | | as the absolute value, for each element method. It is worth mentioning here that X should be updated with each iteration if a better solution exists.

vectorandThe calculation method is as follows:

(3)

(4)

hereIt decreases linearly from 2 to 0 during iteration (exploration and development),Is a random vector in [0,1].

Figure 2 two-dimensional and three-dimensional position vectors and their possible next positions (where X* is the best solution obtained so far)

Figure 2(a) illustrates the principle behind formula (2) with a two-dimensional problem. The location of the search individual (X,Y) can be updated based on the current best recorded location (X*,Y *). Different positions around the best individual can be adjustedand1, 0, 1, 0, 1, 0. Figure 2(b) also describes the possible update locations of the search in 3d space. Note that by defining a random vector, you can reach any position in the search space between the key points shown in Figure 2. Thus Equation 2 allows any searching individual to update its position near the current best solution and simulate encirclement of prey. The same concept can be extended to the n-dimensional search space, where the search individual will move through the hypercube to get the best solution by far.

2) Bubble net attack method

In order to establish a mathematical model of humpback whale bubble net behavior, the following two methods were designed:

(1) Contraction encirclement mechanism: This behavior is through the reduction in Equation (3)To do this,So it becomes a random quantity between minus a and a, and a goes from 2 to 0 during the iteration. Set a random valueIn [-1,1], the new location of the search individual can be defined as any location between the original individual location and the current best individual location. Figure 3(a) shows the possible positions in two-dimensional space where 0≤a≤1 can be realized from (X,Y) to (X*,Y*).

(2) Spiral update position: As shown in FIG. 3(b), this method first calculates the distance between the whale located at (X,Y) and the prey located at (X,Y,Y). Then, a spiral equation is established between the position of whale and prey to simulate the spiral movement of humpback whale as shown in Equation (5):

​(5)

hereRepresents the distance from whale I to prey (the best solution so far obtained), b is a constant in logarithmic spiral shape, l is a random number in [-1,1], and is an element-to-element multiplication.

Figure 3 Bubbly-Net search mechanism implemented in WOA (X is the best solution available so far)

(a) Shrink wrap mechanism and (b) spiral update position

Humpback whales swim around their prey in a progressively shrinking circle, all the while following a spiral path. To simulate this simultaneous behavior, we assume that there is a 50% chance of choosing between a reduced enveloping mechanism and a spiral model to update the whale’s position. The model is as follows:

(6)

Among themIs a random number.

3) Hunting for prey (exploration stage)

Humpback whales search randomly based on each other’s location. It’s a random calculationLess than -1 or greater than 1 forces the seeker to stay away from the reference whale. As opposed to the development phase, we update the location of the search agent in the exploration phase based on randomly selected search individuals rather than the best search individuals found, a mechanism that allows WOA to search globally. The mathematical model is as follows:

(7)

(8)

hereIs the random position of a random whale, as shown in Figure 4Is some possible positions of particular solutions.

FIG. 4 Exploration mechanism in WOA algorithm (X* is a random value)

The WOA algorithm starts with a set of random solutions. In each iteration, the search individual updates its position according to the randomly selected search individual or the best solution obtained, and the parameter A is gradually reduced from 2 to 0 to support exploration and development. when, a random search individual will be selected;, the optimal solution will be selected as the search individual.

According to the value of P, WOA can switch between spiral motion and circular motion, and the WOA algorithm is terminated when the termination criterion is met

Three, code,

Clear CLC %% network parameters L = 50; % region edge length V = 35; % node number Rs = 5; % Perception radius Rc = 10; % communication radius Re = 0.1; % perception error data = 1; % discrete granularity %% SSA parameter N = 30; % population size Dim = 2*V; % dimension ub = L; lb = 0; Max_iter = 300; X = rand(N, dim).*(ub-lb)+lb; For I = 1:N fitness(I) = fun(X(I, :), L, Rs, Re, data); End % initializes the leader's position and fitness value [BESTFITNESS, BestIndex] = Max (fitness); gbest= X(bestindex, :); fitnessgbest = bestfitness; num2str(fitnessgbest)]); X = gbest(1:2:end); y = gbest(2:2:end); Disp (' optimal position: '); for i = 1:V disp([num2str(x(i)), ' ', num2str(y(i))]); End disp([' Optimal coverage: ', num2str(fitnessgbest)]); % % drawing figure; plot(Curve, 'r', 'lineWidth', 2); % Draw iteration graph title('WOA coverage evolution curve ', 'fontsize', 12); Xlabel (' number of iterations ', 'fontsize', 12); Ylabel (' network coverage ', 'fontsize', 12); figure for i = 1:V axis([0 ub 0 ub]); Sita = 0: PI /100:2* PI; % Angle [0, 2* PI] hold on; fill(x(i)+Rs*cos(sita), y(i)+Rs*sin(sita), 'k'); end plot(x, y, 'r+'); Title 'SSA optimized coverage ';Copy the code



6. References

[1] Shi Zhaoya. Research on Coverage Optimization of Wireless Sensor Networks Based on PSO Algorithm [D]. Nanjing University of Science and Technology.

The complete code to download www.cnblogs.com/ttmatlab/p/…