E-DEEC基于matlab增强的分布式能源有效集群(E-DEEC)含Matlab源码 1566期
Posted 紫极神光
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了E-DEEC基于matlab增强的分布式能源有效集群(E-DEEC)含Matlab源码 1566期相关的知识,希望对你有一定的参考价值。
一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【E-DEEC】基于matlab增强的分布式能源有效集群(E-DEEC)【含Matlab源码 1566期】
获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、部分源代码
clear all
xm=100;
ym=100;
sink.x=0.5*xm; %location of sink on x-axis
sink.y=0.5*ym; %location of sink on y-axis
n=100 %nodes+
P=0.1; %probability of cluster heads
Eo=0.5;%initial energy
%
Echeck=Eo;
%
ETX=50*0.000000001; %tx energy
ERX=50*0.000000001; %rx energy
Efs=10*0.000000000001; %free space loss
Emp=0.0013*0.000000000001; %multipath loss
%Data Aggregation Energy
EDA=5*0.000000001; %compression energy
a=1.5; %fraction of energy enhancment of advance nodes
rmax=5000 %maximum number of rounds
do=sqrt(Efs/Emp); %distance do is measured
Et=0; %variable just use below
m=0.5;
mo=0.4;
b=3;
normal=n*(1-m);
advance=n*m*(1-mo);
monaysuper=n*m*mo;
for i=1:1:monaysuper
S(i).xd=rand(1,1)*xm; %generates a random no. use to randomly distibutes nodes on x axis
XR(i)=S(i).xd;
S(i).yd=rand(1,1)*ym; %generates a random no. use to randomly distibutes nodes on y axis
YR(i)=S(i).yd;
S(i).G=0; %node is elegible to become cluster head
%talhar=rand*a
S(i).E=Eo*(1+b);
%S(i).A=talhar;
E(i)= S(i).E;
% if (E(i)>Echeck)
% m1=m1+1;
% end
Et=Et+E(i); %estimating total energy of the network
%initially there are no cluster heads only nodes
S(i).type='N';
end
talha1=monaysuper+advance;
for i=monaysuper:1:talha1
S(i).xd=rand(1,1)*xm; %generates a random no. use to randomly distibutes nodes on x axis
XR(i)=S(i).xd;
S(i).yd=rand(1,1)*ym; %generates a random no. use to randomly distibutes nodes on y axis
YR(i)=S(i).yd;
S(i).G=0; %node is elegible to become cluster head
%talhar=rand*a
S(i).E=Eo*(1+a);
%S(i).A=talhar;
E(i)= S(i).E;
% if (E(i)>Echeck)
% m1=m1+1;
% end
Et=Et+E(i); %estimating total energy of the network
%initially there are no cluster heads only nodes
S(i).type='N';
end
for i=talha1:1:n
S(i).xd=rand(1,1)*xm; %generates a random no. use to randomly distibutes nodes on x axis
XR(i)=S(i).xd;
S(i).yd=rand(1,1)*ym; %generates a random no. use to randomly distibutes nodes on y axis
YR(i)=S(i).yd;
S(i).G=0; %node is elegible to become cluster head
%talhar=rand*a
S(i).E=Eo;
%S(i).A=talhar;
E(i)= S(i).E;
% if (E(i)>Echeck)
% m1=m1+1;
% end
Et=Et+E(i); %estimating total energy of the network
%initially there are no cluster heads only nodes
S(i).type='N';
end
d1=0.765*xm/2; %distance between cluster head and base station
K=sqrt(0.5*n*do/pi)*xm/d1^2; %optimal no. of cluster heads
d2=xm/sqrt(2*pi*K); %distance between cluster members and cluster head
Er=4000*(2*n*ETX+n*EDA+K*Emp*d1^4+n*Efs*d2^2); %energy desipated in a round
S(n+1).xd=sink.x; %sink is a n+1 node, x-axis postion of a node
S(n+1).yd=sink.y; %sink is a n+1 node, y-axis postion of a node
countCHs=0; %variable, counts the cluster head
cluster=1; %cluster is initialized as 1
flag_first_dead=0; %flag tells the first node dead
flag_teenth_dead=0; %flag tells the 10th node dead
flag_all_dead=0; %flag tells all nodes dead
dead=0; %dead nodes count initialized to 0
first_dead=0;
teenth_dead=0;
all_dead=0;
allive=n;
%counter for bit transmitted to Bases Station and to Cluster Heads
packets_TO_BS=0;
packets_TO_CH=0;
for r=0:1:rmax
r
if(mod(r, round(1/P) )==0)
for i=1:1:n
S(i).G=0;
S(i).cl=0;
end
end
Ea=Et*(1-r/rmax)/n;
dead=0;
for i=1:1:n
if (S(i).E<=0)
dead=dead+1;
if (dead==1)
if(flag_first_dead==0)
first_dead=r;
flag_first_dead=1;
end
end
if(dead==0.1*n)
if(flag_teenth_dead==0)
teenth_dead=r;
flag_teenth_dead=1;
end
end
if(dead==n)
if(flag_all_dead==0)
all_dead=r;
flag_all_dead=1;
end
end
end
if S(i).E>0
S(i).type='N';
end
end
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 沈再阳.精通MATLAB信号处理[M].清华大学出版社,2015.
[2]高宝建,彭进业,王琳,潘建寿.信号与系统——使用MATLAB分析与实现[M].清华大学出版社,2020.
[3]王文光,魏少明,任欣.信号处理与系统分析的MATLAB实现[M].电子工业出版社,2018.
以上是关于E-DEEC基于matlab增强的分布式能源有效集群(E-DEEC)含Matlab源码 1566期的主要内容,如果未能解决你的问题,请参考以下文章
微电网优化基于matlab遗传算法求解微电网经济优化问题含Matlab源码 2062期
微电网优化基于matlab遗传算法求解微电网经济优化问题含Matlab源码 2062期
图像增强基于matlab可见边缘梯度比率图像增强含Matlab源码 1404期
图像增强基于matlab直方图均衡化图像增强含Matlab源码 960期