1. SEP算法简介

% SEP: A Stable Election Protocol for clustered heterogeneous wireless sensor networks

% This is the LEACH [1] code we have used.

The same code can be used for FAIR if m=1           
 [1] W.R.Heinzelman, A.P.Chandrakasan and H.Balakrishnan,  "An application-specific protocol architecture for wireless  microsensor networks"IEEE Transactions on Wireless Communications, 1(4):660-670,2002

2.SEP算法matlab源代码

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%Field Dimensions - x and y maximum (in meters)
xm=100;
ym=100;%x and y Coordinates of the Sink
sink.x=0.5*xm;
sink.y=0.5*ym;%Number of Nodes in the field
n=100%Optimal Election Probability of a node
%to become cluster head
p=0.1;%Energy Model (all values in Joules)
%Initial Energy
Eo=0.5;
%Eelec=Etx=Erx
ETX=50*0.000000001;
ERX=50*0.000000001;
%Transmit Amplifier types
Efs=10*0.000000000001;
Emp=0.0013*0.000000000001;
%Data Aggregation Energy
EDA=5*0.000000001;%Values for Hetereogeneity
%Percentage of nodes than are advanced
m=0.1;
%\alpha
a=1;%maximum number of rounds
rmax=9999%%%%%%%%%%%%%%%%%%%%%%%%% END OF PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%Computation of do
do=sqrt(Efs/Emp);%Creation of the random Sensor Network
figure(1);
for i=1:1:nS(i).xd=rand(1,1)*xm;XR(i)=S(i).xd;S(i).yd=rand(1,1)*ym;YR(i)=S(i).yd;S(i).G=0;%initially there are no cluster heads only nodesS(i).type='N';temp_rnd0=i;%Random Election of Normal Nodesif (temp_rnd0>=m*n+1) S(i).E=Eo;S(i).ENERGY=0;plot(S(i).xd,S(i).yd,'o');hold on;end%Random Election of Advanced Nodesif (temp_rnd0<m*n+1)  S(i).E=Eo*(1+a)S(i).ENERGY=1;plot(S(i).xd,S(i).yd,'+');hold on;end
endS(n+1).xd=sink.x;
S(n+1).yd=sink.y;
plot(S(n+1).xd,S(n+1).yd,'x');%First Iteration
figure(1);%counter for CHs
countCHs=0;
%counter for CHs per round
rcountCHs=0;
cluster=1;countCHs;
rcountCHs=rcountCHs+countCHs;
flag_first_dead=0;for r=0:1:rmaxr%Operation for epochif(mod(r, round(1/p) )==0)for i=1:1:nS(i).G=0;S(i).cl=0;endendhold off;%Number of dead nodes
dead=0;
%Number of dead Advanced Nodes
dead_a=0;
%Number of dead Normal Nodes
dead_n=0;%counter for bit transmitted to Bases Station and to Cluster Heads
packets_TO_BS=0;
packets_TO_CH=0;
%counter for bit transmitted to Bases Station and to Cluster Heads
%per round
PACKETS_TO_CH(r+1)=0;
PACKETS_TO_BS(r+1)=0;figure(1);for i=1:1:n%checking if there is a dead nodeif (S(i).E<=0)plot(S(i).xd,S(i).yd,'red .');dead=dead+1;if(S(i).ENERGY==1)dead_a=dead_a+1;endif(S(i).ENERGY==0)dead_n=dead_n+1;endhold on;    endif S(i).E>0S(i).type='N';if (S(i).ENERGY==0)  plot(S(i).xd,S(i).yd,'o');endif (S(i).ENERGY==1)  plot(S(i).xd,S(i).yd,'+');endhold on;end
end
plot(S(n+1).xd,S(n+1).yd,'x');STATISTICS(r+1).DEAD=dead;
DEAD(r+1)=dead;
DEAD_N(r+1)=dead_n;
DEAD_A(r+1)=dead_a;%When the first node dies
if (dead==1)if(flag_first_dead==0)first_dead=rflag_first_dead=1;end
endcountCHs=0;
cluster=1;
for i=1:1:nif(S(i).E>0)temp_rand=rand;     if ( (S(i).G)<=0)%Election of Cluster Headsif(temp_rand<= (p/(1-p*mod(r,round(1/p)))))countCHs=countCHs+1;packets_TO_BS=packets_TO_BS+1;PACKETS_TO_BS(r+1)=packets_TO_BS;S(i).type='C';S(i).G=round(1/p)-1;C(cluster).xd=S(i).xd;C(cluster).yd=S(i).yd;plot(S(i).xd,S(i).yd,'k*');distance=sqrt( (S(i).xd-(S(n+1).xd) )^2 + (S(i).yd-(S(n+1).yd) )^2 );C(cluster).distance=distance;C(cluster).id=i;X(cluster)=S(i).xd;Y(cluster)=S(i).yd;cluster=cluster+1;%Calculation of Energy dissipateddistance;if (distance>do)S(i).E=S(i).E- ( (ETX+EDA)*(4000) + Emp*4000*( distance*distance*distance*distance )); endif (distance<=do)S(i).E=S(i).E- ( (ETX+EDA)*(4000)  + Efs*4000*( distance * distance )); endend     endend
endSTATISTICS(r+1).CLUSTERHEADS=cluster-1;
CLUSTERHS(r+1)=cluster-1;%Election of Associated Cluster Head for Normal Nodes
for i=1:1:nif ( S(i).type=='N' && S(i).E>0 )if(cluster-1>=1)min_dis=sqrt( (S(i).xd-S(n+1).xd)^2 + (S(i).yd-S(n+1).yd)^2 );min_dis_cluster=1;for c=1:1:cluster-1temp=min(min_dis,sqrt( (S(i).xd-C(c).xd)^2 + (S(i).yd-C(c).yd)^2 ) );if ( temp<min_dis )min_dis=temp;min_dis_cluster=c;endend%Energy dissipated by associated Cluster Headmin_dis;if (min_dis>do)S(i).E=S(i).E- ( ETX*(4000) + Emp*4000*( min_dis * min_dis * min_dis * min_dis)); endif (min_dis<=do)S(i).E=S(i).E- ( ETX*(4000) + Efs*4000*( min_dis * min_dis)); end%Energy dissipatedif(min_dis>0)S(C(min_dis_cluster).id).E = S(C(min_dis_cluster).id).E- ( (ERX + EDA)*4000 ); PACKETS_TO_CH(r+1)=n-dead-cluster+1; endS(i).min_dis=min_dis;S(i).min_dis_cluster=min_dis_cluster;endend
end
hold on;countCHs;
rcountCHs=rcountCHs+countCHs;%Code for Voronoi Cells
%Unfortynately if there is a small
%number of cells, Matlab's voronoi
%procedure has some problems%[vx,vy]=voronoi(X,Y);
%plot(X,Y,'r*',vx,vy,'b-');
% hold on;
% voronoi(X,Y);
% axis([0 xm 0 ym]);end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   STATISTICS    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                                     %
%  DEAD  : a rmax x 1 array of number of dead nodes/round
%  DEAD_A : a rmax x 1 array of number of dead Advanced nodes/round
%  DEAD_N : a rmax x 1 array of number of dead Normal nodes/round
%  CLUSTERHS : a rmax x 1 array of number of Cluster Heads/round
%  PACKETS_TO_BS : a rmax x 1 array of number packets send to Base Station/round
%  PACKETS_TO_CH : a rmax x 1 array of number of packets send to ClusterHeads/round
%  first_dead: the round where the first node died
%                                                                                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

3.总结

SEP算法是基于二级异构的网络,即网络中存在高级节点和普通节点,算法为不同初始能量的节点分配不同的轮转周期来实现延长网络稳定周期的目的,但SEP算法的簇头选举只是基于节点的初始能量,未考虑节点的剩余能量。DEEC算法将二级异构网络扩展到多级异构网络,在SEP算法的基础上根据节点的剩余能量水平和网络的异构性来决定簇头的选举,既能充分利用网络的异构性又能适应节点能量的变化。但DEEC使用估算方案求解网络平均剩余能量,求解的前提是网络能耗均匀,这与实际并不相符,从而削弱了DEEC的实用性。Aderohumu等人提出了E-SEP算法,该算法将网络中的节点根据能量分为了三类,增加了中间节点,相比于SEP算法,该算法进一步改善了网络的稳定性,但是E-SEP仍未考虑到节点与基站的距离。Faisal等人提出了Z-SEP算法,Z-SEP算法将网络中的能量异构节点按照能量的不同部署在不同的区域,簇头只在高级节点部署的区域中选举,这种分区部署策略一定程度上节省了能耗,延长了网络生命周期。自适应高效动态聚类路由算法EDFCM,与DEEC算法相似,也是通过估算网络平均剩余能量,对下一轮理想状态下的平均消耗能量进行预测,将预测值与历史能耗作为计算概率的参考因素。

LEACH算法改进 SEP算法源代码相关推荐

  1. 改进蚁群算法 改进flod算法对路径进行双向平滑度优化,提高路径的平滑度

    改进蚁群算法 改进flod算法对路径进行双向平滑度优化,提高路径的平滑度 自己研究编写的Matlab路径规划算法 蚁群算法路径规划 自己研究算法对比 可自行设置起始点,目标点,自由更换地图. ID:6 ...

  2. 【路径规划】基于和声算法改进灰狼算法实现机器人栅格地图路径规划

    一.和声搜索算法介绍 和声搜索(Harmony Search, HS)算法是一种新颖的智能优化算法.类似于遗传算法对生物进化的模仿.模拟退火算法对物理退火的模拟以及粒子群优化算法对鸟群的模仿等,和声算 ...

  3. 【路径规划】基于和声算法改进灰狼算法实现机器人栅格地图路径规划matlab源码

    1 简介 1.1 和声搜索算法介绍 和声搜索(Harmony Search, HS)算法是一种新颖的智能优化算法.类似于遗传算法对生物进化的模仿.模拟退火算法对物理退火的模拟以及粒子群优化算法对鸟群的 ...

  4. matlab算法改进,pso算法改进含MATLAB代码

    %% No-dealing LOO RBF %      程序运行完以后,观察一下数据 %QPSO输出 %      Validation_err(curCount,Swarmsize)        ...

  5. 3.TF-IDF算法介绍、应用、NLTK实现TF-IDF算法、Sklearn实现TF-IDF算法、算法的不足、算法改进

    3.TF-IDF 3.1.TF-IDF算法介绍 3.2.TF-IDF应用 3.3.NLTK实现TF-IDF算法 3.4.Sklearn实现TF-IDF算法 3.5.Jieba实现TF-IDF算法 3. ...

  6. 基于麻雀算法改进的无线传感器网络Dv-hop定位算法 - 附代码

    基于麻雀算法改进的无线传感器网络Dv-hop定位算法 文章目录 基于麻雀算法改进的无线传感器网络Dv-hop定位算法 1.DV-Hop算法原理 2.麻雀算法改进DV-Hop算法原理 3.算法测试 4. ...

  7. 实战28:数字图像可视化水印系统的设计与实现(LSB算法、DCT算法、随机间隔算法、区域校验位算法、图像降级算法、图像降级算法改进等6种数字水印算法的实现)

    基于数字图像的可视化水印系统按照水印算法的不同主要分为空间域水印和变换域水印两大类.空间域水印以 LSB 算法--最低有效位算法为代表,变换域水印以 DCT 算法--离散余弦变换算法为代表[10]. ...

  8. 萤火虫算法_萤火虫算法(二)

    点击上方"蓝字"关注我们吧! 前面已经简单介绍了萤火虫算法,接下来详细介绍萤火虫算法. 天然萤火虫的行为天然萤火虫在寻找猎物.吸引配偶和保护领地时表现出惊人的闪光行为.萤火虫的吸引 ...

  9. [学习笔记] [机器学习] 8. 聚类算法(聚类算法:K-means、K-means++;聚类算法评估;特征降维:特征选择(Pearson相关系数、Spearman相关系数)、PCA主成分分析)

    视频链接 数据集下载地址:无需下载 1. 聚类算法简介 学习目标: 掌握聚类算法实现过程 知道 K-means 算法原理 知道聚类算法中的评估模型 说明 K-means 的优缺点 了解聚类中的算法优化 ...

  10. 群体智能优化算法之萤火虫算法(Firefly Algorithm,FA)

    获取更多资讯,赶快关注上面的公众号吧! 文章目录 第八章 萤火虫算法 8.1 介绍 8.2 天然萤火虫的行为 8.3 萤火虫算法 8.4 萤火虫算法改进 参考文献 第八章 萤火虫算法 8.1 介绍 萤 ...

最新文章

  1. cv2.rectangle()画出矩形的用法
  2. linux shell中 if else以及大于、小于、等于逻辑表达式
  3. Oracle的sql 函数
  4. 查看mysql 内核_如何查看和更新数据库内核小版本
  5. 计算机在外语专业中有哪些应用,CALL(3):计算机在外语教学中的应用
  6. 搭建K8s集群(二进制方式)-搭建步骤介绍
  7. 2021-10-12Spring缓存注解@Cacheable、@CacheEvict、@CachePut使用
  8. python将ros下bag文件的所有topic解析为csv格式
  9. leetcode 104. Maximum Depth of Binary Tree
  10. CodeForces 592C The Big Race
  11. java jdom_JAVA JDOM生成XML
  12. Bootstrap 下拉菜单事件
  13. Android的JNI【实战教程】5⃣️---Android Studio 2.2 以上 NDK开发
  14. 老司机教你如何快速入门Linux | 小白必知
  15. SWEBOK软件工程知识体系 - 7.软件工程管理
  16. 视频编码格式全面解析
  17. 计算几何——扇形面积
  18. ANT 下载,ant的配法 整理
  19. ART-Pi系列文章
  20. 往年二本计算机分数线,全国一本、二本院校历年录取分数线汇总

热门文章

  1. 高效记忆/形象记忆(06)110数字编码表 01-10
  2. 车辆跟踪技术概述zt
  3. icd11中文版精神障碍pdf_精神与行为障碍类别目录(ICD-11)(借鉴资料)
  4. 16QAM的理论误码率仿真
  5. Linux 测试连接端口
  6. 回文字符串判断python实现
  7. JLINK 驱动 V7.00a 更新导致JLINK V9无法使用问题解决
  8. python调用按键精灵插件_按键精灵 插件命令 重中之重务必要记住怎么操作
  9. 2021新书—《Python机器学习算法与实战》
  10. 训练猫咪,一本书就够了