%% This program is to calculate the number of groups in different scenarios
% Plot of the number of groups formed with scenario 1, with 250 links and
% fixed link lengths, using the first distance model with the greedy
% grouping algorithm.
clear;
clc;
% Distance criterium d_min is calculated as follows:
n=4; % n is the pass loss exponent
% d_D2Dmax=100; % The maximum length of D2D links, in scenario 1, the
% value of d_D2Dmax equal to the lengh of links.
% fi=6; % fi is the required SINR(dB), in our simulation, the value is
% 6dB、9dB or 12dB.
for p=1:5
l=0;
for L=[1000,500,250,100,50,10]
for fi=6:3:12
%% Cell Scenarios With Fixed D2D Link Lengths(500 nodes)
Num=250; % Half of Number of nodes
R=1000; % Cell Raius(meters)
% L=100; % Length of links
d_D2Dmax=L; % For fixed D2D link length, d_D2Dmax equal to the length of link L
d_min=10.^((fi+10*log10(6))/(10*n))*d_D2Dmax;
% Circle,it stands for a cell which has a radiu equal to 1000 meter.
seta=0:0.0001:2*pi;
x=R*sin(seta);
y=R*cos(seta);
% figure
% plot(x,y,'LineWidth',2,'Color','k')
% axis square
% hold on
% Plot the center of the circle
% x_c=0;
% y_c=0;
% plot(x_c,y_c,'*blue','LineWidth',1.5,'MarkerSize',8)
% 5000 Nodes (Part A) Uniformity Distributed in the Cell(均匀分布).
r_A=R*sqrt(rand(1,5000));
beta_A=2*pi*rand(1,5000);
x_A=r_A.*cos(beta_A);
y_A=r_A.*sin(beta_A);
% Calculate the other 250 Nodes (Part B) which has a distance 1000 meter with
% the Uniformiy Distributed Nodes
for i=1:5000
gama_B=2*pi*rand(1);
x_B(i)=x_A(i)-L.*cos(gama_B);
y_B(i)=y_A(i)-L.*sin(gama_B);
Value(i)=x_B(i)+1i*y_B(i);
end
Find_Node=find(abs(Value)<=1000);
Node_A=x_A(Find_Node)+1i*y_A(Find_Node);
Node_B=x_B(Find_Node)+1i*y_B(Find_Node);
Position_A=Node_A(1:Num);
Position_B=Node_B(1:Num);
% plot(real(Position_A(1:Num)),imag(Position_A(1:Num)),'+','Color','k')
% plot(real(Position_A(1:Num)),imag(Position_A(1:Num)),'o','Color','r','LineWidth',1.5)
% hold on
% plot(real(Position_B(1:Num)),imag(Position_B(1:Num)),'+','Color','k')
% plot(real(Position_B(1:Num)),imag(Position_B(1:Num)),'o','Color','green','LineWidth',1.5)
% Connect the two part of the Nodes
% for j=1:Num
% plot([real(Position_A(j));real(Position_B(j))],[imag(Position_A(j));imag(Position_B(j))],':r')
% end
%% Compare the distance of the links with d_min
% Calculate the minimum distance between every vertice(link).
d=[];
d_min_link=[];
vert_degree=[]; % Degree of every vertice(link).
for j=1:250
vert_degree(j)=0;
for i=j+1:250
d(1)=abs(Position_A(i)-Position_A(j));
d(2)=abs(Position_B(i)-Position_A(j));
d(3)=abs(Position_A(i)-Position_B(j));
d(4)=abs(Position_B(i)-Position_B(j));
% Find the minimum distance
d_min_link=min(d);
% If the minimum distance between every vertice(link) less than d_min,
% degree of every vertice will plus one.
if(min(d)<d_min)
vert_degree(j)=vert_degree(j)+1;
end
end
end
% Sort descending of degree of vertices.
[vert_degree_sort,Index]=sort(vert_degree,'descend');
Position_A_sort=Position_A(Index);
Position_B_sort=Position_B(Index);
%% Use Greedy Grouping Algorthm to ascertain the number of link grouping
Position_vert_fulfill=[]; % Matrix put the position value of vertices which fulfill min(d_sort)>d_min
Group_matrix_column=2; % The initial value of matrix column of group
Group_matrix_row=1; % The nitial value of matrix row of group
while (1)
k=1;
Group_matrix_column=2;
M(Group_matrix_row,1)=Position_A_sort(k);
N(Group_matrix_row,1)=Position_B_sort(k);
if(length(Position_A_sort)<2)
break;
end
for h=k+1:length(Position_A_sort)
d_sort(1)=abs(Position_A_sort(h)-Position_A_sort(k));
d_sort(2)=abs(Position_B_sort(h)-Position_A_sort(k));
d_sort(3)=abs(Position_A_sort(h)-Position_B_sort(k));
d_sort(4)=abs(Position_B_sort(h)-Position_B_sort(k));
if(min(d_sort)>d_min)
M(Group_matrix_row,Group_matrix_column)=Position_A_sort(h);
N(Group_matrix_row,Group_matrix_column)=Position_B_sort(h);
Position_vert_fulfill=[Position_vert_fulfill,h]; % Find the position of vertices which fulfill min(d_sort)>d_min
Group_matrix_column=Group_matrix_column+1;
end
end
if(length(Position_A_sort)==length(Position_vert_fulfill)+1)
break;
end
Position_A_sort([1,Position_vert_fulfill])=[];
Position_B_sort([1,Position_vert_fulfill])=[];
Position_vert_fulfill=[];
Group_matrix_row=Group_matrix_row+1;
end
l=l+1;
% The number of group M we want to get
M_group=Group_matrix_row;
Matrix_M_group(p,l)=M_group; % Put all the M_group value to this matrix to plot bar
end
end
end
% Find the maximum value and minimum value of M
Matrix_M_group_max=max(Matrix_M_group);
Matrix_M_group_min=min(Matrix_M_group);
% Calculate the average value of M
Matrix_M_group_mean=mean(Matrix_M_group);
% This three matrix combine to one matrix, so as to plot bar of M/Lt
Matrix_M=[Matrix_M_group_min';Matrix_M_group_mean';Matrix_M_group_max'];
Final_Matrix_M=reshape(Matrix_M,18,3);
%% Plot of the number of groups formed with scenario 1
Lt=250;
bar(Final_Matrix_M/Lt);
title('由场景1情形下形成的分组结果')
grid;
legend('Min(M)/Lt','Mean(M)/Lt','Max(M)/Lt')
set(gca,'XTickLabel',{'6dB','9dB','12dB','6dB','9dB','12dB','6dB','9dB','12dB','6dB','9dB','12dB','6dB','9dB','12dB','6dB','9dB','12dB'});
xlabel('链路长度(m)');
ylabel('M/Lt')
hold on
没有合适的资源?快使用搜索试试~ 我知道了~
Efficient Resource Allocation for D2D Communication
共7个文件
m:7个
需积分: 10 24 下载量 110 浏览量
2017-12-12
20:58:35
上传
评论 1
收藏 6KB ZIP 举报
温馨提示
该程序主要关于D2D方面的matlab仿真,仿真结果表明,该算法既可以提高系统速率、降低系统能耗又能够保证D2D用户获得无线资源的公平性。
资源推荐
资源详情
资源评论
收起资源包目录
matlab.zip (7个子文件)
Scenario_1_nodes_500.m 6KB
budingjifen.m 136B
node50_dangong_shuanggong.m 2KB
nodes50r1000_choose.m 2KB
50nodes_tongji.m 476B
p-16-function-1.m 4B
tianchong+Dindjifen.m 155B
共 7 条
- 1
资源评论
qq_41372116
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功