👨🎓个人主页:研学社的博客
💥💥💞💞欢迎来到本博客❤️❤️💥💥
🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。
⛳️座右铭:行百里者,半于九十。
📋📋📋本文目录如下:🎁🎁🎁
目录
💥1 概述
使用 Mamdani 模糊推理系统 (FIS) 改进无线传感器网络路由和数据包传递。FIS 根据消息重要性和网络情况(流量等)决定在所有找到的路由之间选择最佳路由。
📚2 运行结果
部分代码:
%% Making Network:
global position N
N=50; % Number of Nodes in network
position=randsrc(2,N,1:1000); % set position of each node in network 1000x1000 meters
S=1; % Source Node
D=50; % Destination Node
Net=zeros(N);
range=250; % Radio propagation range of each node (meter)
plot(position(1,:),position(2,:),'ro');
title('Network');
xlabel('x (m)');
ylabel('y (m)');
grid();
hold on
for i=1:N
for j=1:N
if i~=j && dist(position(:,i)',position(:,j))<=range
Net(i,j)=1; %Connection between 2 nodes (i,j)
line([position(1,i),position(1,j)],[position(2,i),position(2,j)]);
end
end
end
plot(position(1,S),position(2,S),'ks');
plot(position(1,D),position(2,D),'g^');
%% Route Discovery:
for i=1:30
path=S;
tik=zeros(1,N);
tik(S)=1;
while (1)
a=find(Net(path(end),:)==1);
b=a(tik(a)==0);
if isempty(b)==1
break;
end
next=randsrc(1,1,b);
if tik(next)==0
path=[path,next];
tik(next)=1;
end
if path(end)==D
routePool{i}=path;
break;
end
end
end
j=1;
for i=1:numel(routePool)
if isempty(routePool{i})==0
Pool{j}=routePool{i};
j=j+1;
end
end
for i=1:numel(Pool)-1
for k=i+1:numel(Pool)
if numel(Pool{i})== numel(Pool{k})
if sum(Pool{i}==Pool{k})==numel(Pool{k})
Pool{k}=[];
end
end
end
end
routePool=Pool;
clear Pool;
j=1;
for i=1:numel(routePool)
if isempty(routePool{i})==0
Pool{j}=routePool{i};
j=j+1;
end
end
for k=1:numel(Pool)
figure, plot(position(1,:),position(2,:),'ro');
hold on;
for i=1:numel(Pool{k})-1
line([position(1,Pool{k}(i)),position(1,Pool{k}(i+1))],[position(2,Pool{k}(i)),position(2,Pool{k}(i+1))]);
end
end
%% Sorting routes
for i=1:numel(Pool)
count(i)=numel(Pool{i});
end
[~,idx]=sort(count);
for i=1:numel(Pool)
sPool{i}=Pool{idx(i)};
end
Pool=sPool;
clear sPool
%% Packet Injection
packeti=rand(2500,1); % message importance
packetc=50*ones(2500,1); % Capasity of message (from 1 kb to 100 kb)
packet=[packeti,packetc];
j=1;
disp('----------------------------');
discard=0;
tl=zeros(1,50);
E=tl;
kk=1;
🎉3 参考文献
部分理论来源于网络,如有侵权请联系删除。
Majid Farzaneh (2022). Mamdani Fuzzy Inference System for WSN routing.