优化覆盖基于matlab模因算法求解集群无线传感器网络中节能覆盖控制优化问题含Matlab源码 1563期
Posted 紫极神光
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了优化覆盖基于matlab模因算法求解集群无线传感器网络中节能覆盖控制优化问题含Matlab源码 1563期相关的知识,希望对你有一定的参考价值。
一、获取代码方式
获取代码方式1:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
获取代码方式2:
完整代码已上传我的资源: 【优化覆盖】基于matlab模因算法求解集群无线传感器网络中节能覆盖控制优化问题【含Matlab源码 1563期】
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、部分源代码
clear;
clf;
clc;
close all;
global generation_size pop_size sense_node sense_range sensor_selected target_coveraged target_x target_y node_x node_y distance grid_range_x grid_range_y span
sense_range=17.675;
sense_node=400;
packet_bit=2000;
generation_size=20;
pop_size=50;
grid_range_x=200;
grid_range_y=200;
span=0.04;%target span
% sink_x=grid_range_x*span/2;
% sink_y=-grid_range_y*span;
sink_x=50;
sink_y=200; %sink_y=200
%grid_range: to determine the field size, rand_rang: target number
sensor_selected=zeros(pop_size,sense_node,generation_size+1);
% rand_range_x=10;
% rand_range_y=10;
target_x=zeros(grid_range_y*span,grid_range_x*span);
target_y=zeros(grid_range_y*span,grid_range_x*span);
% target_x=zeros(rand_range_y,rand_range_x); %//
% target_y=zeros(rand_range_y,rand_range_x); %//
% node_x=zeros(sense_node); %//
% node_y=zeros(sense_node); %//
% load data1;
% distance=zeros(rand_range_y,rand_range_x,sense_node);
dist_node_target=zeros(grid_range_y*span,grid_range_x*span,sense_node);
% for k=1:sense_node %randomly produce %//
% node_x(k)=fix(rand*grid_range_x*span);
% node_y(k)=fix(rand*grid_range_y*span);
% end
m=0;
n=0;
for k=1:400
node_x(k)=m;
node_y(k)=n;
if m>=95
m=0;
n=n+5;
else
m=m+5;
end
end
% while 1==1
tic
clf;
for i=1:grid_range_y*span % determine the target coordinates
for j=1:grid_range_x*span
target_x(i,j)=6.25+(j-1)*12.5;
target_y(i,j)=6.25+(i-1)*12.5;
end
end
% for i=1:rand_range_y %randomly determine//
% for j=1:rand_range_x
% target_x(i,j)=fix(rand*grid_range_x*span);
% target_y(i,j)=fix(rand*grid_range_y*span);
% end
% end
for i=1:grid_range_x*span %% plot the targets
axis image;
hold on;
subplot(1,2,2),plot(target_x(i,:),target_y(i,:),'*');
hold on;
subplot(1,2,1),plot(target_x(i,:),target_y(i,:),'*');
end
for k=1:sense_node
for i=1:grid_range_y*span
for j=1:grid_range_x*span
distance(i,j,k)=dist(node_x(k),node_y(k),target_x(i,j),target_y(i,j));
end
end
end
target_coveraged=zeros(length(target_x(:,1)),length(target_x(1,:)),pop_size,generation_size+1); % coverage array
[best_fit,best_idx]=algorithm();
init_node_x=[]; % plot the nodes
init_node_y=[];
for i=1:sense_node
init_node_x(length(init_node_x)+1)=node_x(i);
init_node_y(length(init_node_y)+1)=node_y(i);
subplot(1,2,1),text(node_x(i),node_y(i),int2str(i));
end
axis image;
hold on;
subplot(1,2,1),circle(sense_range,init_node_x,init_node_y,'b');
init_targe_coveraged=zeros(length(target_x(:,1)),length(target_x(1,:))); % determine the covered targets in the initial plot
for k=1:sense_node
for i=1:length(target_x(:,1))
for j=1:length(target_x(1,:))
if distance(i,j,k)<=sense_range
init_target_coveraged(i,j)=1;
end
end
end
end
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
《智能优化算法及其MATLAB实例(第2版)》包子阳 余继周 杨杉著 电子工业出版社
以上是关于优化覆盖基于matlab模因算法求解集群无线传感器网络中节能覆盖控制优化问题含Matlab源码 1563期的主要内容,如果未能解决你的问题,请参考以下文章
优化覆盖基于matlab遗传算法求解无线传感器覆盖优化问题含Matlab源码 1320期
优化覆盖基于matlab粒子群算法求解传感器覆盖优化问题含Matlab源码 598期
优化覆盖基于matlab蚁群算法求解无线传感器覆盖优化问题含Matlab源码 1835期
优化覆盖基于matlab人工蜂群算法求解无线网络传感覆盖优化问题含Matlab源码 1097期