🍁🥬🕒摘要🕒🥬🍁
此代码是数学模型的实现,该模型的开发用于确定某些故障情况下编码节点的最佳数量及其位置。除了降低成本和提高可靠性外,传感器网络最终还具有更高的延迟方面的性能,因为网络编码操作的总数减少;
可以使用不同的网络节点数量,笔者在这里使用 40 节点网络,如下所示:
✨🔎⚡运行结果⚡🔎✨
💂♨️👨🎓Matlab代码👨🎓♨️💂
%% Failure constraint failureIsDest=zeros(length(FailureScenarios)*numberOfNodes,numberOfLinks); failureIsSrc=zeros(length(FailureScenarios)*numberOfNodes,numberOfLinks); e=0; esrc=0; % Failure sources for f=1:length(FailureScenarios) for k=1:failedLinksInScen(f) workingLinks=get_workingLinks_in_failureScen(f,failedLinksInScen,links,FailureScenarios); for i=1:numberOfNodes for j=1:length(workingLinks) bool=isAgateway(workingLinks(j),1,gateways,network); if networkF(workingLinks(j),1)==i && bool==false failureIsSrc(i+e,workingLinks(j)+esrc)=1; else failureIsSrc(i+e,workingLinks(j)+esrc)=0; end end end e=e+numberOfNodes; end end %% failure destination e=0; edest=0; for f=1:length(FailureScenarios) for k=1:failedLinksInScen(f) workingLinks=get_workingLinks_in_failureScen(f,failedLinksInScen,links,FailureScenarios); for i=1:numberOfNodes for j=1:length(workingLinks) bool=isAgateway(workingLinks(j),1,gateways,network); if networkF(workingLinks(j),2)==i && bool==false failureIsDest(i+e,workingLinks(j)+edest)=-1; else failureIsDest(i+e,workingLinks(j)+edest)=0; end end end e=e+numberOfNodes; end end % adjFailure Matrix adjFailure=failureIsSrc(:,:)+failureIsDest(:,:); % store all the sources of failed links in sourcesF matrix sourcesF=cell(1,numberOfFailScens); for f=1:numberOfFailScens for l=1:failedLinksInScen(f) for n=1:numberOfNodes for j=1:numberOfLinks if networkF(j,1)==n && networkF(j,3)==FailureScenarios{f}(1,l) sourcesF{f}(1,l)=networkF(j,1); end end end end end %% Failure scenario:indicate the failed links in each failure scenario e=0; fCol=numberOfNodes+1; fColEnd=fCol-1+numberOfLinks; gmmaCol=numberOfNodes+numberOfLinks+1; etaCol=numberOfLinks + numberOfNodes+failure_scen_var_length*numberOfLinks; GRow=0; for f=1:numberOfFailScens for i=1: failedLinksInScen(f) workingLinks=get_workingLinks_in_failureScen(f,failedLinksInScen,links,FailureScenarios); for j= 1:numberOfNodes Aeq(GRow+j+e,fCol:fColEnd)=adjFailure(j+e,1:numberOfLinks); if isSource(j,FailureScenarios{f}(1,i))==1 sum_lPrime=sum_Working_Links(j,gammaTree,workingLinks,network); beq(GRow+j+e)=1-sum_lPrime; else Aeq(GRow+j+e,etaCol+j+e)=1; beq(GRow+j+e)=0; end end fCol=fColEnd+1; fColEnd=fColEnd+numberOfLinks; e=e+numberOfNodes; end end
📜📢🌈参考文献🌈📢📜
[1]李想想. 面向传感网数据传输的网络编码方案研究[D].哈尔滨工程大学,2012.