Table of contents
1. Algorithm simulation effect
2. Algorithms involve an overview of theoretical knowledge
4. Complete algorithm code file
1. Algorithm simulation effect
The matlab2022a simulation results are as follows:
2. Algorithms involve an overview of theoretical knowledge
With the continuous development of smart homes and automated buildings, infrared sensors have been widely used in indoor environment monitoring, security, intelligent control and other fields. When deploying an infrared sensor indoors, the choice of its location has a crucial impact on the performance and signal quality of the sensor. Therefore, how to determine the best deployment position of infrared sensors has become a hot research topic.
1. Research Background
Infrared sensor is a sensor widely used in indoor environment monitoring, security, intelligent control and other fields. In practical applications, the position selection of the infrared sensor has a crucial impact on the performance and signal quality of the sensor. Therefore, how to determine the best deployment position of infrared sensors has become a hot research topic.
Traditional methods of infrared sensor deployment are largely based on experience and trial-and-error. There are many problems in this method, such as requiring a lot of time and labor costs, not being able to guarantee the optimality of deployment, not being able to take into account the influence of different environments and different sensors, etc. Therefore, how to use modern optimization algorithms to optimize the deployment position of infrared sensors is one of the current research hotspots.
2. GA Genetic Optimization Algorithm
GA genetic optimization algorithm is an optimization algorithm based on the principle of biological evolution. It searches the optimal solution from the solution space by simulating the evolution process in nature. The basic idea is to express the solution of the problem to be optimized as a set of genetic codes, and then operate on the genetic codes through genetic operations (selection, crossover, mutation), so as to continuously evolve better solutions.
GA genetic optimization algorithm includes the following steps:
Initial population: Randomly generate a set of initial populations, each individual corresponds to a solution to a problem.
Fitness function: For each individual, calculate its fitness value. The larger the fitness value, the better the individual.
Selection operation: According to the fitness value, select excellent individuals as parents to further breed the next generation of individuals.
Crossover operation: Combine the genes of parent individuals to generate new individuals.
Mutation operation: perform random mutation on new individuals, introduce a certain degree of randomness, and avoid falling into local optimum.
Termination condition: After the predetermined termination condition is reached, the optimal solution is output.
3. 3D Indoor Infrared Sensor Deployment Strategy Based on GA Optimization
In order to solve the optimization problem of infrared sensor deployment, this paper proposes a 3D indoor infrared sensor deployment strategy based on GA genetic optimization algorithm. The main flow of the strategy is as follows:
Establishing an indoor 3D model: First, it is necessary to establish an indoor 3D model, including room size, layout, walls, furniture and other information. It can be modeled with 3D modeling software or scanned in real time with a 3D scanner.
Determine the number and type of sensors: Determine the number and type of infrared sensors to be deployed based on actual needs.
Initial population: Divide the indoor space into several areas, and randomly generate a set of initial populations, each individual corresponds to a sensor deployment scheme, that is, each individual represents the position and orientation of all sensors.
Fitness function: For each individual, calculate its fitness value. The calculation of the fitness value needs to take into account the following aspects:
Coverage: The sensor deployment scheme needs to cover as many areas of the indoor space as possible to ensure that the sensors can detect all targets.
Overlap: Sensor deployment schemes need to avoid overlap between sensors to avoid duplicate detections.
Acquisition rate: The sensor deployment scheme needs to increase the acquisition rate of the target as much as possible, that is, the probability of detecting the target.
Selection operation: According to the fitness value, select excellent individuals as parents to further breed the next generation of individuals. In this paper, the roulette selection algorithm is used for the selection operation.
Crossover operation: Combine the genes of parent individuals to generate new individuals. In this paper, a single-point crossover algorithm is used for the crossover operation.
Mutation operation: perform random mutation on new individuals, introduce a certain degree of randomness, and avoid falling into local optimum. In this paper, the random mutation algorithm is used for the mutation operation.
Termination condition: After the predetermined termination condition is reached, the optimal solution is output. In this paper, the number of iterations is used as the termination condition.
3. MATLAB core program
..........................................................................
%优化变量得到的三维坐标值
X1 = XYZ1(1,:);
Y1 = XYZ1(2,:);
Z1 = XYZ1(3,:);
%避开障碍物
Idx1 = [];
for i=1:Nr1
for j = 1:length(X1)
%判断传感器的坐标点区域和传感器是否有交集,有交集那么说明碰到障碍物了,则去除这些错误的部署点
if abs(X1(j)-(X3(i)+L(i)/2))<=L(i)/2 & abs(Y1(j)-(Y3(i)+W(i)/2))<=W(i)/2 & abs(Z1(j)-(Z3(i)+H(i)/2))<=H(i)/2
Idx1 = [Idx1,j];
end
end
end
idx2 = unique(Idx1);
X1(idx2) = [];
Y1(idx2) = [];
Z1(idx2) = [];
NUM1_new = NUM1-length(find(idx2<=NUM1));
NUM2_new = length(X1)-NUM1_new;
Idx1 = [];
for i=1:Nr2
for j = 1:length(X1)
%判断传感器的坐标点区域和传感器是否有交集,有交集那么说明碰到障碍物了,则去除这些错误的部署点
if ((X1(j) - X4(i))^2 + (Y1(j) - Y4(i))^2 + (Z1(j) - Z4(i))^2) <= R4(i)^2
Idx1 = [Idx1,j];
end
end
end
idx2 = unique(Idx1);
X1(idx2) = [];
Y1(idx2) = [];
Z1(idx2) = [];
NUM1_new = NUM1-length(find(idx2<=NUM1));
NUM2_new = length(X1)-NUM1_new;
%上面两个步骤,去掉了和障碍物有重叠的部署位置
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%第一个,覆盖率
Sar=0;
for i = 1:SCALE
for j = 1:SCALE
for kk = 1:SCALE
Nums = 0;
for k = 1:(NUM1_new+NUM2_new)
if k<=NUM1_new%类似半个无顶的球体覆盖率计算,那么Z轴的取值范围,这里只考虑90旋转或者180旋转,任意角度情况不考虑,否则非常复杂
if ((X1(k) - i)^2 + (Y1(k) - j)^2 + (Z1(k) - kk)^2) < Rad1^2 & (abs(Z1(k)-kk)<=Rad1*sin(Dgree))%30度的弧形
Nums=Nums+1;
end
end
if k>NUM1_new & k<=(NUM1_new+NUM2_new)%正方形覆盖率计算
if abs(X1(k) - i)<=Rad2 & abs(Y1(k) - j)<=Rad2 & abs(Z1(k) - kk)<=Rad2
Nums=Nums+1;
end
end
end
if Nums > 0
Sar=Sar+1;
end
end
end
end
fobj1 = 1-Sar/SCALE/SCALE/SCALE;%整体减去被覆盖到的点,就是非覆盖率,因为优化算法是往最小值找的,所以需要减去覆盖率,得到非覆盖率,越小越好
%第二个安装难度,这里做一个定义,和障碍物越近,那么难度越大因为涉及到信号的传输和障碍物的避让问题
fobj2_= [];
for i=1:(NUM1_new+NUM2_new)
if i<=NUM1_new
d1=[];
d2=[];
for j=1:Nr1
tmps = sqrt((X1(i) - X3(j))^2 + (Y1(i) - Y3(j))^2)+ (Z1(i) - Z3(j))^2; %计算距离
if tmps < Rad1%满足条件的则保持到d1数据库
d1=[d1,1/(tmps+1)];
end
end
for j=1:Nr2
tmps = sqrt((X1(i) - X4(j))^2 + (Y1(i) - Y4(j))^2 + (Z1(i) - Z4(j))^2); %计算距离
if tmps < Rad1%满足条件的则保持到d2数据库
d2=[d2,1/(tmps+1)];
end
end
if isempty([d1,d2])==1
fobj2_(i)=0;
else
fobj2_(i)=mean([d1,d2]);
end
end
if i>NUM1_new
d1=[];
d2=[];
for j=1:Nr1
tmps = sqrt((X1(i) - X3(j))^2 + (Y1(i) - Y3(j))^2 + (Z1(i) - Z3(j))^2); %计算距离
if tmps < Rad2%满足条件的则保持到d1数据库
d1=[d1,1/(tmps+1)];
end
end
for j=1:Nr2
tmps = sqrt((X1(i) - X4(j))^2 + (Y1(i) - Y4(j))^2 + (Z1(i) - Z4(j))^2); %计算距离
if tmps < Rad2%满足条件的则保持到d2数据库
d2=[d2,1/(tmps+1)];
end
end
if isempty([d1,d2])==1
fobj2_(i)=0;
else
fobj2_(i)=mean([d1,d2]);
end
end
end
...........................................................................
f1=Sar/SCALE/SCALE/SCALE;
f2=mean(fobj2_);
f3=(NUM1_new+NUM2_new)/(N1+N2);%最优传感器数量
fitness = 0.6*fobj1 + 0.1*fobj2+0.3*f3;%获得最终的加权值
09_057_m
4. Complete algorithm code file
V