% Author: Ian C. Wong and Zukang Shen
% Copyright (C) 2004 Ian C. Wong
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
%
% You may reach the author at wongic@mail.utexas.edu.
% Or visit his website at www.ece.utexas.edu/~iwong
% SIPS 2004 Main Simulation File
clear all;
worstpower=1.1565;
N0=worstpower*1e-8;
Ptotal=1;
BER = 1e-3;
Gap = -log(5*BER)/1.6;
channelnum=10;
samplenum=10;
numuser = 8;
epsilong=1e-3;
maxNumOfNewton=0;
maxTotalNewtonIteNum=0;
avenonlintime = zeros(1,numuser);
aveshentime = zeros(1,numuser);
aveiantime = zeros(1,numuser);
diffuservector = [];
iancapamat = [];
shencapamat = [];
cc = 1;
clear shencapa iancapa
N=64; % 子载波数目
B=1000000; % 带宽是1MHz
noise=B*N0/N;
clear ch
%for different user number
for ii=1:numuser,
diffuser=2*ii;
diffuservector(ii)=diffuser;
K=diffuser;
totaliancapa=0;
totalshencapa=0;
totalnonlincapa = 0;
shencapavec = zeros(1,diffuser);
iancapavec = zeros(1,diffuser);
iannorm = 0;
shennorm = 0;
nonlinnorm = 0;
%for different channel
for chan=1:channelnum,
chan
[env,I,Q]=chtry(K,samplenum,30);
h = rand(1,K);
gamma = .064*(h < .5) + .128*((h >= .5) & (h < .8)) + .256*(h>.8);%%how to generate the coefficient
%for diff samples
for diffsamp=1:samplenum,
diffsamp
for i=1:K
user=I(i,:,diffsamp)+sqrt(-1)*Q(i,:,diffsamp);
ch(i,:)=abs(fft(user,N)).^2/Gap;%%channel in frequency domain
end
% Shen's subcarrier allocation
[rheecapa,rheesuballo]=rheesub(Ptotal,ch, N, K, noise, gamma);
% Shen's power allocation
t=cputime; shenp = shenpowerallo(ch,rheesuballo,N,K,Ptotal,noise,gamma); shentime = cputime-t;
aveshentime(ii) = aveshentime(ii) + shentime;
% Ian's subcarrier allocation
[iancapa,iansuballo]=wongsuballo(Ptotal, ch, N, K, noise, gamma);
% Ian's power allocation
t=cputime; ianp = wongpowerallo(ch,iansuballo,N,K,Ptotal,noise,gamma); iantime = cputime-t;
aveiantime(ii) = aveiantime(ii) + iantime;
for i=1:K,
shencapa(i) = waterfilling(shenp(i),rheesuballo(i,:).*ch(i,:)/noise)/N;
iancapa(i) = waterfilling(ianp(i),iansuballo(i,:).*ch(i,:)/noise)/N;
end;
totalshencapa=totalshencapa+sum(shencapa);
totaliancapa=totaliancapa+sum(iancapa);
if (chan == 1),
shencapavec = shencapavec + shencapa;
iancapavec = iancapavec + iancapa;
if (chan == 1 & diffsamp == 1),
figure(2);
bar([gamma/sum(gamma); iancapavec/sum(iancapavec); shencapavec/sum(shencapavec)]', 'grouped');%; nonlincapavec/sum(nonlincapavec)]', 'grouped');
title('snapshot');
end;
end;
iannorm = iannorm + norm(iancapa/sum(iancapa) - gamma/sum(gamma), inf);
shennorm = shennorm + norm(shencapa/sum(shencapa) - gamma/sum(gamma), inf);
end
if (chan == 1),
iancapavec = iancapavec/(channelnum*samplenum);
shencapavec = shencapavec/(channelnum*samplenum);
figure(5);
bar([gamma/sum(gamma); iancapavec/sum(iancapavec); shencapavec/sum(shencapavec)]', 'grouped');
legend('Gamma', 'LINEAR', 'ROOT-FINDING');
end;
%end diff channel
end
maxNumOfNewton;
maxTotalNewtonIteNum;
totalshencapavec(ii)=totalshencapa/(channelnum*samplenum);
totaliancapavec(ii)=totaliancapa/(channelnum*samplenum);
iannormvec(ii) = iannorm/(channelnum*samplenum);
shennormvec(ii) = shennorm/(channelnum*samplenum);
end
% total capacities plot
figure(1)
plot(diffuservector,totaliancapavec, 'ko--', diffuservector, totalshencapavec, 'b+-.');%, diffuservector, totalnonlincapavec, 'rx-.');
iansumcapa = sum(totaliancapavec)
shensumcapa = sum(totalshencapavec)
grid on
xlabel('number of users')
ylabel('capacity (bit/s/Hz)')
legend('LINEAR', 'ROOT-FINDING'); %, 'NONLIN');
hold off
aveshentime = aveshentime/(channelnum*samplenum)
aveiantime = aveiantime/(channelnum*samplenum)
figure(3);
semilogy(diffuservector,aveiantime, 'ko--', diffuservector,aveshentime, 'b+-.');%, diffuservector, avenonlintime, 'rx-.');
grid on
xlabel('number of users')
ylabel('Ave CPU time (s)')
legend('LINEAR', 'ROOT-FINDING'); %, 'NONLIN');
title('Average CPU time comparison');
APei
- 粉丝: 81
- 资源: 1万+
最新资源
- WixToolset.DirectX.wixext - DirectX WiX 工具集扩展.zip
- XAPP583示例代码
- Windows 界面组合引擎是一个用于创建 Windows 应用程序的 .NET C# UI 引擎 .zip
- Ruby编程语言及相关框架的学习资源汇总
- matlab实现阶次分析完整代码文件
- Windows 版 DirectStorage 是一种 API,它允许游戏开发人员充分发挥高速 NVMe 驱动器的潜力来加载游戏资产 .zip
- Windows 游戏和 DirectX SDK 博客.zip
- 高性能恒流恒压原边控制功率开关DP3701X详解
- Rust学习资源概述及应用实践
- 转换px单位为rpx等任意单位-小程序 附完整源码,一键运行
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论1