clc;
clear;
close all;
warning off;
RandStream.setDefaultStream(RandStream('mt19937ar','seed',1));
addpath 'My_Function\' %自定义函数路径
addpath 'My_Figure\' %仿真结果图保存路径
addpath 'My_Result\' %仿真结果及仿真中间结果数值保存路径
%参数化
lemda = 0.2;
M = 50;%用户数量
%信道数目
N = 10;
lemda = 1/2000 + (1/200-1/2000)*rand(N,1);%1/2000 ~ 1/200的均匀分布
Treqi = zeros(M,1);
PQi = zeros(M,1);
PQi2 = zeros(M,1);
PHij = zeros(M,N);
PHij2 = zeros(M,1);
betai = zeros(M,1);
for nn = 1:M
nn
TIME = 100;
NUM = 0;
%中继信道lemda
lemda2 = 1/1000 + (1/100-1/1000)*rand(N,1);%1/1000 ~ 1/100的均匀分布
for t = 1:TIME
for i = 1:nn
%步骤1:对次用户业务服务质量所要求的PQi等进行初始化,即最小的不发生切换的概率
PQi(i) = rand(1,1)/2;
%步骤2:次用户SUi的目标切换概率1-PQi
PQi2(i) = 1 - PQi(i);
%步骤3:计算次用户在不同频谱空洞上通信的实际切换概率Phij
Treqi(i) = 10 + (300-10)*rand(1,1);
for j = 1:N
PHij(i,j) = 1-exp(-lemda(j)*Treqi(i));
end
%步骤4:根据Hi,找到切换概率和目标切换概率的差值最小的频谱空洞j
for j = 1:N
Hs1(j) = abs(PQi(i) - exp(-lemda(j)*Treqi(i)));
end
%考虑中继协作,CR用户和中继进行竞争,获得最佳的II值。
for j = 1:N
PHij(i,j) = 1-exp(-lemda2(j)*Treqi(i));
end
for j = 1:N
Hs2(j) = abs(PQi(i) - exp(-lemda2(j)*Treqi(i)));
end
Hss = [Hs1,Hs2];
[VV,II] = min(Hss);
%步骤5:把频谱控制j分配给对应的次用户i
lemdas = [lemda;lemda2];
H(i) = Hss(II);%将最佳的空洞j分配给次用户i
%步骤6:计算次用户SUi在频谱空洞j上通信的不切换概率
PHij2(i) =1-exp(-lemdas(II)*Treqi(i));
%步骤7:比较1-Phij和PQi的大小,1-Phij > PQi,beta=0,则不需要预留频谱空洞,1-Phij <=
%PQi,beta不等于0,则需要频谱预留
if PHij2(i) > PQi
betai(i) = 0;
else
betai(i) = 1+log(PQi(i))/lemdas(II)/Treqi(i);
end
%步骤8:计算对应的切换次数
if betai(i) ~=0;
NUM = NUM + 1;
end
end
end
PRO(nn) = NUM/TIME;
end
hold on
plot(1:M,PRO,'k','Linewidth',2);
PRO1 = PRO;
Treqi = zeros(M,1);
PQi = zeros(M,1);
PQi2 = zeros(M,1);
PHij = zeros(M,N);
PHij2 = zeros(M,1);
betai = zeros(M,1);
for nn = 1:M
nn
TIME = 100;
NUM = 0;
for t = 1:TIME
for i = 1:nn
%步骤1:对次用户业务服务质量所要求的PQi等进行初始化,即最小的不发生切换的概率
PQi(i) = rand(1,1)/2;
%步骤2:次用户SUi的目标切换概率1-PQi
PQi2(i) = 1 - PQi(i);
%步骤3:计算次用户在不同频谱空洞上通信的实际切换概率Phij
Treqi(i) = 10 + (300-10)*rand(1,1);
for j = 1:N
PHij(i,j) = 1-exp(-lemda(j)*Treqi(i));
end
%步骤4:根据Hi,找到切换概率和目标切换概率的差值最小的频谱空洞j
for j = 1:N
Hs(j) = abs(PQi(i) - exp(-lemda(j)*Treqi(i)));
end
%步骤5:把频谱控制j分配给对应的次用户i
[VV,II] = min(Hs);
H(i) = Hs(II);%将最佳的空洞j分配给次用户i
%下面的步骤引入频谱预留的思想,进行切换的改进
%步骤6:计算次用户SUi在频谱空洞j上通信的不切换概率1-Phij
PHij2(i) = 1-(1-exp(-lemda(II)*Treqi(i)));
%步骤7:比较1-Phij和PQi的大小,1-Phij > PQi,beta=0,则不需要预留频谱空洞,1-Phij <=
%PQi,beta不等于0,则需要频谱预留
if PHij2(i) > PQi
betai(i) = 0;
else
betai(i) = 1+log(PQi(i))/lemda(II)/Treqi(i);
end
%步骤8:计算对应的切换次数
if betai(i) ~=0;
NUM = NUM + 1;
end
end
end
PRO(nn) = NUM/TIME;
end
hold on
plot(1:M,PRO,'b','Linewidth',2);
PRO2 = PRO;
Treqi = zeros(M,1);
PQi = zeros(M,1);
PQi2 = zeros(M,1);
PHij = zeros(M,N);
PHij2 = zeros(M,1);
betai = zeros(M,1);
for nn = 1:M
nn
TIME = 100;
NUM = 0;
for t = 1:TIME
for i = 1:nn
%步骤1:对次用户业务服务质量所要求的PQi等进行初始化,即最小的不发生切换的概率
PQi(i) = rand(1,1)/2;
%步骤2:次用户SUi的目标切换概率1-PQi
PQi2(i) = 1 - PQi(i);
%步骤3:计算次用户在不同频谱空洞上通信的实际切换概率Phij
Treqi(i) = 10 + (300-10)*rand(1,1);
for j = 1:N
PHij(i,j) = 1-exp(-lemda(j)*Treqi(i));
end
%步骤4:根据Hi,找到切换概率和目标切换概率的差值最小的频谱空洞j
for j = 1:N
Hs(j) = abs(PQi(i) - exp(-lemda(j)*Treqi(i)));
end
%步骤5:把频谱控制j分配给对应的次用户i
[VV,II] = min(Hs);
H(i) = Hs(II);%将最佳的空洞j分配给次用户i
%步骤6:计算次用户SUi在频谱空洞j上通信的切换概率Phij
PHij2(i) = 1-(1-exp(-lemda(II)*Treqi(i)));
%步骤6:计算对应的切换次数
NUM = NUM+PHij2(i);
end
end
PRO(nn) = NUM/TIME;
end
hold on
plot(1:M,PRO,'r','Linewidth',2);
PRO3 = PRO;
xlabel('次用户个数');
ylabel('切换次数');
legend('中继协作基于最小概率的频谱空洞预留算法','基于最小概率的频谱空洞预留算法','基于最小概率的频谱空洞匹配算法');
save result1.mat M PRO1 PRO2 PRO3
基于频谱空洞预留算法的频谱分配算法具有最优服务质量和最少的切换的次数,基于频谱空洞预留算法的频谱分配算法性能优于基于最小化切换概率的频谱匹配算法,优于传统的基于切换概率的频谱匹配算法。
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删