0
点赞
收藏
分享

微信扫一扫

【优化选址】基于人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码


 1 简介

近年来,物联网技术,人工智能技术的兴起使传感器网络分布覆盖检测区域的研究以及最大限度地提高传感器网络的覆盖率变得尤为必要.人工蜂群算法在无约束条件的数值优化问题上能取得较好的收敛效果.通过人工蜂群算法对传感网络的节点覆盖进行优化,可以有效减小网络冗余度,延长网络寿命.

【优化选址】基于人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码_matlab代码

【优化选址】基于人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码_matlab代码_02编辑

【优化选址】基于人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码_参考文献_03

【优化选址】基于人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码_matlab代码_04编辑

【优化选址】基于人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码_参考文献_05

【优化选址】基于人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码_参考文献_06编辑

【优化选址】基于人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码_参考文献_07

【优化选址】基于人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码_路径规划_08编辑

2 部分代码

%--------------------------------------------------------------------------
% ABC for WSN
%--------------------------------------------------------------------------
tic;
clear;%clc
close all
h=7;
w=100;
point=100;
%/* Control Parameters of ABC algorithm*/
NP=20; %/* The number of colony size (employed bees+onlooker bees)*/
FoodNumber=NP/2; %/*The number of food sources equals the half of the colony size*/
limit=100; %/*A food source which could not be improved through "limit" trials is abandoned by its employed bee*/
maxCycle=100; %/*The number of cycles for foraging {a stopping criteria}*/
%/* Problem specific variables*/
D=point; %/*The number of parameters of the problem to be optimized*/
ub=w; %/*lower bounds of the parameters. */
lb=0;%/*upper bound of the parameters.*/
runtime=1;%/*Algorithm can be run many times in order to see its robustness*/
Globalmaxs=zeros(1,runtime);
Scout_=zeros(1,runtime);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hwait = waitbar(0,'Please wait...'); % Creates and displays a waitbar
h_=findobj(hwait,'type','patch');
set(h_,'FaceColor','b','EdgeColor','b');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for r=1:runtime
%{
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
step = runtime /100; % Set the parameters of waitbar
if ((runtime-r)/runtime)<=0.05
waitbar(r/ runtime,hwait,'Almost done!');
else
PerStr = fix(r/step);
str=['Process on going>>>',num2str(PerStr),'%'];
waitbar(r/ runtime,hwait,str);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%}
% /*All food sources are initialized */
%/*Variables are initialized in the range [lb,ub]. If each parameter has different range, use arrays lb[j], ub[j] instead of lb and ub */
Range = ub-lb;
Lower = lb;
Foods = rand(FoodNumber,D) * Range + Lower;
Foods1 = rand(FoodNumber,D) * Range + Lower; %------- y
for p=1:FoodNumber
tmp=[Foods(p,:);Foods1(p,:)]; %------ tmp
ObjVal(p)=Coverage(tmp',point,w,h);
end
Fitness=calculateFitness(ObjVal);
%reset trial counters
trial=zeros(1,FoodNumber);
%/*The best food source is memorized*/
BestInd=find(ObjVal==max(ObjVal));
BestInd=BestInd(end);
Globalmax=ObjVal(BestInd);
GlobalParams(r,:)=Foods(BestInd,:);
GlobalParams1(r,:)=Foods1(BestInd,:);
%--------------------------------------------------------------------------
Global_Tmp=GlobalParams(r,:); % For GBest ABC-PTS
Global_Tmp1=GlobalParams1(r,:); % For GBest ABC-PTS
%--------------------------------------------------------------------------
iter=1;
while ((iter <= maxCycle))
%%{
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
step = maxCycle /100; % Set the parameters of waitbar
lculateFitness(ObjValSol);
% /*a greedy selection is applied between the current solution i and its mutant*/
if (FitnessSol<Fitness(i)) %/*If the mutant solution is better than the current solution i, replace the solution with the mutant and reset the trial counter of solution i*/
Foods(i,:)=sol;
Foods1(i,:)=sol1;
Fitness(i)=FitnessSol;
ObjVal(i)=ObjValSol;
trial(i)=0;
else
trial(i)=trial(i)+1; %/*if the solution i can not be improved, increase its trial counter*/
end;
end;
i=i+1;
if (i==(FoodNumber)+1)
i=1;
end;
end;
%%{
%/*The best food source is memorized*/
ind=find(ObjVal==max(ObjVal));
ind=ind(end);
if (ObjVal(ind)>Globalmax)
Globalmax=ObjVal(ind);
GlobalParams(r,:)=Foods(ind,:);
GlobalParams1(r,:)=Foods1(ind,:);
Global_Tmp=GlobalParams(r,:); % For GBest ABC-PTS
Global_Tmp1=GlobalParams1(r,:); % For GBest ABC-PTS
end;
%}
%%%%%%%%%%%% SCOUT BEE PHASE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%/*determine the food sources whose trial counter exceeds the "limit" value.
%In Basic ABC, only one scout is allowed to occur in each cycle*/
ind=find(trial==max(trial));
ind=ind(end);
if (trial(ind)>limit)
trial(ind)=0;
sol=(ub-lb).*rand(1,D)+lb;
sol1=(ub-lb).*rand(1,D)+lb;
tmp3=[sol;sol1];
ObjValSol=Coverage(tmp3',point,w,h);
FitnessSol=calculateFitness(ObjValSol);
Foods(ind,:)=sol;
Foods1(ind,:)=sol1;
Fitness(ind)=FitnessSol;
ObjVal(ind)=ObjValSol;
%----------------------------------------------------------------------
Global_Tmp=sol; % For GBest ABC-PTS update
Global_Tmp1=sol1; % For GBest ABC-PTS update
%----------------------------------------------------------------------
Scout_(r)=Scout_(r)+1;
%----------------------------------------------------------------------
end;
iter=iter+1;
end % End of ABC
Globalmaxs(r)=Globalmax;
end; %end of runs
close(hwait)
mean(Globalmaxs)
ind=find(Globalmaxs==max(Globalmaxs));
tmp5=[ GlobalParams(ind,:); GlobalParams1(ind,:)];
draw(tmp5',point,h)
toc
%save WSN_1000_10.mat
%save WSN_100_100_10 trial Scout_

3 仿真结果

【优化选址】基于人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码_matlab代码_09

【优化选址】基于人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码_路径规划_10编辑

4 参考文献

[1]胡珂. 基于人工蜂群算法在无线传感网络覆盖优化策略中的应用研究[D]. 电子科技大学.

[2]张洁, 苏倩, 韩忠泰. 基于人工蜂群算法的WSN覆盖优化研究[J]. 电脑与电信, 2020.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

【优化选址】基于人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码_路径规划_11

【优化选址】基于人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码_路径规划_12编辑



举报

相关推荐

0 条评论