I. WSN model

Antlion algorithm

Principle 1.

ALO algorithm simulates the hunting mechanism of antlions in nature. They get their name from their unique hunting behavior and their favorite prey. The antlion moves along a circular path, using its huge jaws to dig a cone-shaped pit in the sand. After digging the trap, hide in the bottom of the cone (as a sitting predator) and wait for the insects (preferably ants) trapped in the pit, as shown in Figure 1. The main steps were carried out, such as random walking of ants, setting traps, trapping ants with traps, catching prey and rebuilding traps.

FIG. 1 The hunting behavior of antlions

2. Algorithm steps

2.1 Foraging ants walked randomly

FIG. 2 Random walking of ants (3 times)

To simulate the antlion’s hunting ability, roulette was used. As shown in Figure 3, assume that the ant is trapped in only one selected ant lion. In the optimization process of ant colony algorithm, a roulette wheel operator is used to select ant colonies according to their fitness. This mechanism provides a higher chance for better-suited antlions to prey on ants.

FIG. 3 Random walking of ants in antlion traps

2.2 Setting Traps

2.3 Use traps to trap ants

2.4 Capture prey and rebuild the cave

3. The pseudo code

Figure 4 ALO algorithm pseudocode

Three, code,

% Script cuckoo algorithm, solve the minimum function % clear all; close all ; clc ; N = 25; %Number of nests(The scale of solution) D = 10; % Dimensionality of solution T = 200 ; % Number of iterations Xmax = 20 ; Xmin = -20 ; Pa = 0.25; % Probability of building a new nest(After host bird find exotic bird eggs) nestPop = rand(N,D)*(Xmax-Xmin)+Xmin ; % Random initial solutions for t=1:T levy_nestPop = func_levy(nestPop,Xmax,Xmin) ; % Generate new solutions by Levy flights nestPop = func_bestNestPop(nestPop,levy_nestPop); % Choose a best nest among new and old nests rand_nestPop = func_newBuildNest(nestPop,Pa,Xmax,Xmin); % Abandon(Pa) worse nests and build new nests by (Preference random walk ) nestPop = func_bestNestPop(nestPop,rand_nestPop) ; % Choose a best nest among new and old nests [~,index] = max(func_fitness(nestPop)) ; % Best nests trace(t) = func_objValue(nestPop(index,:)) ; end figure plot(trace); Xlabel (' number of iterations '); Ylabel (' fitness value '); Title (' Fitness evolution curve ');Copy the code

Iv. References

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