目录
💥1 概述
📚2 运行结果
🎉3 参考文献
👨💻4 Matlab代码
💥1 概述
近年来,随着对等网络、云计算和网格计算等分布式环境的发展,无线传感器网络(WSN)得到了广泛的应用。无线传感器网络(WSN)是一种新兴的计算和网络模式,它可以被定义为一个由称为传感器节点的微小、小型、昂贵和高度智能化的设备组成的网络。传感器节点位于被观测空间内的不同位置,通过无线通信信道交换从监测领域收集的数据。收集的数据被发送到sink节点,sink节点要么本地处理数据,要么将数据发送到处理能力更强的其他网络。
该项目的目标是设计一种路由算法,该算法应在同一WSN上提供数据完整性和延迟差异化服务。
📚2 运行结果
主函数部分代码:
%% -----Generate problem instances--------- M = 5; % number of secondary users K = 1; % number of orthogonal channels Iters = 4*1e3/1; rho = 0.2 ;%+ 0.01*(2*rand(1,K)-1); % QoS constraints of primary users p1 = 0.2 + 0.1*(2*rand(1,K) - 1); % vector of idle-channel prob p2 = 0.8 + 0.1*(2*rand(1,K) - 1); % link capacities c_bar = zeros(1,M); c = c_bar + 0.5*(2*rand(1,M)); c_max = 1; c2 = c_bar + 0.5*(2*rand(1,K)); % secondary users' flow rates x = zeros(Iters,M); x_max = c(1:M); gamm = zeros(Iters,M); phi = zeros(M,K); % resource matrix phi2 = zeros(Iters,M); % resource matrix [phi,cost] = Hungarian(phi); %phi_bak = zeros(M,K,Iters); C_MUE = zeros(Iters,K); % collision variable % Virtual Queues Q = zeros(Iters,M); Z = zeros(Iters,M); H = zeros(Iters,K); % Channel state % S = zeros(Iters,K); V = 2; % Define Non-negative weight of penanty function nu = 1; % weight of proportionally fair utility function %% -----Algorithms----------------------------------------- t_change = 2000; W = zeros(M,K); p = p1; % high channel occupancy operation = [zeros(1,1600) ones(1,400)]; %# Fill the vector with 0 and 1 S = operation(randperm(2000))'; %# Randomly reorder it for iter = 1:t_change %----CFBS level-----------------% Performance weighted matrixfor i=1:Mfor j=1:KW(i,j) = Z(iter,i)*c(i)*p(j) - H(iter)*(1-S(iter));%W(i,j) = Z(iter,i)*c(i)*p(j) - H(iter)*(1-p(j))*c2(j);endend[phi,cost] = Hungarian(-W); % Resuorce allocationfor i=1:Mphi2(iter,i) = phi(i);end%----FUE level------------------% Auxiliary Variablefor i=1:Mgamm(iter,i) = V/Q(iter,i) - 1/nu; if (gamm(iter,i)<0)gamm(iter,i) = 0;endif (gamm(iter,i)> x_max(i))gamm(iter,i) = x_max(i);endend% Flow Controlfor i=1:M % cvx_begin % variable x_min % minimize ((Z(iter,i)-Q(iter,i))*x_min) % subject to % x_min <= x_max(i); % x_min >= 0; % cvx_end % x(iter,i) = x_min; % f_min = cvx_optval; % optimal value of LP%fprintf(1,'Optimal value of LP is %0.4f.\n\n',f_min);f = Z(iter,i)-Q(iter,i);A = 1;b = x_max(i);lb = zeros(1,1);[x_min,fval,exitflag,output,lambda] = linprog(f,A,b,[],[],lb);x(iter,i) = x_min;f_min = fval;end%----Update Virtual Queues------C_MUE(iter) = 0;for i=1:Mfor j=1:KQ(iter+1,i) = max(Q(iter,i) + gamm(iter,i) - x(iter,i),0);Z(iter+1,i) = max(Z(iter,i) + x(iter,i) - c(i)*p(j)*phi(i),0);C_MUE(iter,j) = C_MUE(iter,j) + (1-S(iter))*phi(i);%C_MUE(iter) = C_MUE(iter) + (1-p(j))*phi(i)*c2(j);endendfor i=1:K%H(iter+1,i) = max(H(iter,i) - rho*c2(i),0) + C_MUE(iter);H(iter+1,i) = max(H(iter,i) - rho,0) + C_MUE(iter);end
🎉3 参考文献
[1]董志乾.基于无线传感器网络的主机温度采集监测系统[J].内燃机与配件,2022(04):230-232.
部分理论引用网络文献,若有侵权联系博主删除。