🍒🍒🍒欢迎关注🌈🌈🌈
📝个人主页:我爱Matlab
👍点赞➕评论➕收藏 == 养成习惯(一键三连)🌻🌻🌻🍌希望大家多多支持🍓~一起加油 🤗
💬语录:将来的我一定会感谢现在奋斗的自己!
🍁🥬🕒摘要🕒🥬🍁
针对监测区域内含有障碍物的无线传感器网络(Wireless Sensor Networks,WSNs)异构节点部署优化问题,在花朵授粉算法(Flower Pollination Algorithm,FPA)的基础之上,提出了一种改进的 花朵授粉算法(Improved Flower Pollination Algorithm,IFPA)用于改善原有算法收敛速度慢、精度不够高的不足。设计非线性收敛因子以约束原有的缩放因子,采用 Tent 映射以维持迭代后期种群的多样性,而贪心交叉策略则是以较优的个体辅助较差个体搜索。基准函数实验验证了 IFPA 具有较好的收敛性能,而 WSN 部署的仿真实验表明 IFPA 可得到较高的覆盖率,可节约网络部署成本。
✨🔎⚡部分运行结果⚡🔎✨
运行中如果提示安装工具箱,安装即可,例如Symbolic Math Toolbox,如果用2014b,则不需要安装。
无障碍物:
有障碍物:
💂♨️👨🎓Matlab代码👨🎓♨️💂
%三角形和菱形障碍物
geshu_x = [20,25,30,35,40,45,50];
init_y = [54.21,61.09,67.44,73.07,77.24,79.15,82.61]/100;
ga_y = [80.71,87.40,94.69,96.74,98.23,99.17,100]/100;
pso_y = [83.37,92.37,95.13,96.79,98.56,99.31,100]/100;
dea_y = [85.08,93.03,95.79,97.62,99.28,99.50,100]/100;
fa_y = [85.69,93.57,96.96,98.61,99.28,100,100]/100;
ifa_y = [86.02,94.25,97.12,98.73,99.34,100,100]/100;
figure(1);
% plot(geshu_x,init_y,'color','k');
% hold on;
plot(geshu_x,ga_y,'color','r');
hold on;
plot(geshu_x,pso_y,'color','g');
hold on;
plot(geshu_x,dea_y,'color','b');
hold on;
plot(geshu_x,fa_y,'color','c');
hold on;
plot(geshu_x,ifa_y,'color','m');
hold on;
legend('ga','pso','dea','fa','ifa');
hold on;
%%主程序
clc;
clear ;
close all;
%删除相应的文件
global N;
global M;
global L;
global W;
global Grid_cen_x;
global Grid_cen_y;
global Grid_cen_x_and_y;
global ger;
p=0.8;%判断是否是全局优化还是局部优化
L = 50;%长
W = 50;%宽
%假设1平方米一个网格
M = 2500;%网格总数
r_max = 7;%感知半径为5
r_mid = 6;
r_min = 5;
energy_max = 100;%最大的能量
energy_mid = 90;
energy_min = 80;
per_sersons_radius_type = [r_max,r_mid,r_min];
%假设大、中为5,剩下为小
N = 25;%30个传感器节点
sizepop = 50;%种群规模
dimension = 2;% 空间维数 前行放x、y,第三行放半径
ger = 10;% 最大迭代次数
pos_limit = [0, 50]; % 设置位置参数限制
%个数限制
r_max_num = 1;%序号为1-5
r_mid_num = 2;%序号为6-10
r_min_num = N - r_max_num - r_mid_num; %序号为11-N
struct_pop_per = struct('per',[],'radius',[],'energy_init',[],'energy_end',[],'sersons_num',[]);%结构体类型
struct_pops_temp = repmat(struct_pop_per,[1 sizepop]);%临时的一个种群
energy_init_arr = zeros(1,N);
energy_end_arr = zeros(1,N);
radius_arr = zeros(1,N);
%求出梯形的四个点
syms x y;%先定义一个变量
%左上角
k1 = 1;
b1 = 35;
x1_up = solve(k1*x+b1==50,x);%左上角的斜线的上个交点
y1_down = solve(k1*0+b1==y,y);
%左下角
k2 = -1;
b2 = 15;
y2_up = solve(k2*0+b2==y,y);
x2_down = solve(k2*x+b2==0,x);
%右上角
k3 = -1;
b3 = 85;
x3_up = solve(k3*x+b3==50,x);
y3_down = solve(k3*50+b3==y,y);
%右下角
k4 = 1;
b4 = -35;
y4_up = solve(k4*50+b4==y,y);
x4_down = solve(k4*x+b4==0,x);
%以下数据验证完毕,完全正确
point = zeros(8,2);%存储这些点 从左 从上往下
point(1,:) = [x1_up,50];
point(2,:) = [0,y1_down];
point(3,:) = [0,y2_up];
point(4,:) = [x2_down,0];
point(5,:) = [x3_up,50];
point(6,:) = [50,y3_down];
point(7,:) = [50,y4_up];
point(8,:) = [x4_down,0];
%菱形的计算
point_diamond = zeros(2,4);%菱形的四个点,方位是顺时针 第一列为上 二列为右
%求出新菱形形的四个点
syms x y;%先定义一个变量
%左上角
k5 = 1;
b5 = 10;
%别搞什么计算了 直接可以看出来
point_diamond(1,1) = 25;
point_diamond(2,1) = 35;
%右上角
k6 = -1;
b6 = 60;
point_diamond(1,2) = 35;
point_diamond(2,2) = 25;
%右下角
k7 = 1;
b7 = -10;
point_diamond(1,3) = 25;
point_diamond(2,3) = 15;
%左下角
k8 = 1;
b8 = 40;
point_diamond(1,4) = 15;
point_diamond(2,4) = 25;
load struct_pop_public.mat;%加载该种群
struct_pops = struct_pop_public;%得到种群数据
load struct_first_init_public.mat%加载最开始的一个个体数据
struct_first_init = struct_first_init_public;%得到初始化个体数据
%%初始的部署后画图 拿第一个粒子拿去初始画图
📜📢🌈参考文献🌈📢📜
[1]王振东,谢华茂,胡中栋,李大海,王俊岭.改进花朵授粉算法的无线传感器网络部署优化[J].系统仿真学报,2021,33(03):645-656.DOI:10.16182/j.issn1004731x.joss.19-0580.