m Optimal deployment of wireless sensor network based on MOEA algorithm matlab simulation

Table of contents

1. Algorithm simulation effect

2. Algorithms involve an overview of theoretical knowledge

3. MATLAB core program

4. Complete algorithm code file


1. Algorithm simulation effect

The matlab2022a simulation results are as follows:

 

 

 

2. Algorithms involve an overview of theoretical knowledge

       Wireless sensor network (Wireless Sensor Network, WSN) is a distributed sensor network, which is composed of a large number of wireless sensor nodes, which can be self-organized, self-adaptive, self-healing, and cooperate to complete tasks through wireless communication. WSN is widely used in fields such as environmental monitoring, agriculture, and medical treatment. In WSN, the deployment of sensor nodes is an important factor affecting network performance. Unreasonable deployment of sensor nodes will lead to problems such as insufficient network coverage and unbalanced energy consumption. Therefore, how to realize the optimal deployment of WSN has become one of the research hotspots in the field of WSN.

      MOEA (Multi-Objective Evolutionary Algorithm) is an algorithm that solves multi-objective optimization problems by simulating the natural evolution process. The MOEA algorithm has the characteristics of global optimization ability, nonlinear and non-convex problem solving ability, parallelization, etc., and has been widely used in solving WSN optimal deployment problems. 1. Problem Description of Optimal Deployment of Wireless Sensor Networks

       The WSN optimal deployment problem refers to how to deploy a limited number of sensor nodes in a given area to achieve optimal network coverage and minimum energy consumption. The WSN optimal deployment problem can be regarded as a multi-objective optimization problem, where the objective function usually includes the following two aspects:

Coverage
      Coverage refers to the ability of a sensor node to cover a target area. In WSN, the coverage usually refers to the percentage of the covered target area or the density of sensor nodes, that is, the ratio of the number of sensor nodes arranged in the target area to the area of ​​the target area. The higher the coverage, the stronger the monitoring, control and management capabilities of the network.

Energy Consumption
      Energy consumption refers to the energy consumed by sensor nodes during operation. In WSN, the energy of sensor nodes is limited, so it is necessary to reduce energy consumption as much as possible to prolong the life of the network. Energy consumption is usually related to factors such as communication distance, transmission power, and data transmission rate of sensor nodes. Therefore, when deploying sensor nodes, it is necessary to consider how to reduce the communication distance and transmission power between sensor nodes to reduce energy consumption.

     In summary, the WSN optimal deployment problem can be regarded as a multi-objective optimization problem, where the objective function includes coverage and energy consumption. Solving the optimal deployment problem will help WSN to achieve efficient, reliable and persistent monitoring and control functions.

2. The principle of MOEA algorithm

      The MOEA algorithm is an algorithm for solving multi-objective optimization problems by simulating the natural evolution process. The basic idea of ​​MOEA is to transform the multi-objective optimization problem into a multi-objective decision-making problem, and generate a set of optimal solutions with multiple objective functions by continuously performing evolutionary operations on the candidate solutions. The basic flow of the MOEA algorithm is as follows:

Initializing the population
      First, the decision variables and objective function of the problem need to be determined. In the WSN optimal deployment problem, the decision variables are the deployment locations and numbers of sensor nodes, and the objective functions are coverage and energy consumption. Next, a set of initial populations needs to be randomly generated, and each individual represents a deployment scheme of sensor nodes.

Evaluating Individual Fitness
      For each individual, it is necessary to evaluate its fitness. In the WSN optimal deployment problem, coverage and energy consumption can be used as individual fitness. Individuals with higher coverage have higher fitness, and individuals with lower energy consumption have higher fitness.

Selecting Individuals
      In the MOEA algorithm, the method of selecting individuals is usually the Non-dominated Sorting (NSGA) method based on multi-objective optimization. The NSGA method divides individuals into different levels according to their fitness, and the individuals of each level are better than all the individuals under the current level. In each level, according to the crowding distance sorting (Crowding Distance Sorting) method, a certain number of individuals are selected as the parents of the next generation population.

Evolutionary operations
      Evolutionary operations include crossover, mutation, and selection. Crossover refers to exchanging some parts of two individuals to produce new individuals. Mutation refers to the random transformation of some parts of an individual to generate new individuals. Selection refers to selecting a certain number of individuals from the parents and offspring as the next generation population.

3. MATLAB core program

.............................................................................
%目标个数
nn       = 2*(N+M);
Num      = 3;  
Xmax     = [W*ones(1,nn)];
Xmin     = [1*ones(1,nn)];

%种群大小   
pop      = 100;          
lamdaMat = generateLamda(pop,Num); 
%邻居规模大小
T        = 4;          
Maxgen   = 1000;
 
%初始化邻居
B        = getNeighbor(lamdaMat,T);
%初始化个体位置
X = repmat(Xmin,pop,1)+rand(pop,nn).*repmat(Xmax-Xmin,pop,1); 
for i=1:pop
    [fitness,f1,f2,f3] = func_obj(X(i,:));
    fit(i,:)  = fitness;
    fit2(i)   = sum(fitness);
end

[V,I] = max(fit2);

z0    = fit(I,:);
X0    = X(I,:);
z     = z0;
 
tic;
%迭代循环
for gen =1:Maxgen
    gen
    for i = 1:pop   
        %繁殖
        index = randperm(T);
        r1    = B(i,index(1));
        r2    = B(i,index(2));
        y     = geneticOp( X(r1,:), X(r2,:),Xmax,Xmin);
        %Improvement
        y     = CheckBound(y,Xmax,Xmin);

        [fity,f1,f2,f3] = func_obj(y);
        for j=1:Num
             z(j) = min(z(j),fity(j));
        end
        %Update of neighboring solution   
 
        [X,fit] = updateNeigh(X,fit,B(i,:),y,z);
    end
    errss(gen)  = mean(fit(:,1)+fit(:,2)+fit(:,3))/3;
    
 
    
    if gen == Maxgen
         
        figure
        for i=1:N
            plot(X1(i),Y1(i),'r.');
            hold on
            circle([X1(i),Y1(i)],R(i),1000,'g');
            hold on 
        end
        for i=1:M
            plot(X2(i),Y2(i),'b.');
            hold on 
        end
        axis([0,W,0,H]);
        title(['部署结果:f1=',num2str(min(fit(:,1))),', f2=',num2str(min(fit(:,2))),', f3=',num2str(min(fit(:,3)))]);
        xlabel('x');
        ylabel('y');
    end
 
end
disp('运行时间:');
toc 

figure;
plot(errss,'LineWidth',2);
grid on
xlabel('迭代次数');
ylabel('MOEA/D迭代过程');

save R0a.mat z0 X0 X fit
12_074_m

4. Complete algorithm code file

V

Guess you like

Origin blog.csdn.net/hlayumi1234567/article/details/130817530