⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 consttxsca.m

📁 通讯系统仿真 静态恒定Tx在JOINT系统中
💻 M
字号:
% random order sequential resource allocation, minimize overall transmit
% energy or maximize sum SIR
% system wide fast sequential DCA/FCA
clear
t=cputime
NF=4;
KA=3;
KS=25;
KM=NF*KA;
KSM=KM*KS;
r=3;
alpha=3.0;
hotspotfactor=16;
NN=500;

warning off
rand('seed',0);
randn('seed',0);

targetSIR=10;

%SIR=zeros(NN,KSM,NF,KS*KA)-inf;
ActiveFlag=zeros(NN,KSM);
for nn=1:NN % number of scenarios
    
    kM_center=0;
    
    [SA_index, G]=singleMTpathgain(KSM, KA, KS, r, NF, alpha, hotspotfactor);
    rayleigh=(randn(NF,KSM,KA*KS)+sqrt(-1)*randn(NF,KSM,KA*KS))*sqrt(1/2);
    for nF=1:NF
        H(nF,:,:)=sqrt(G).*squeeze(rayleigh(nF,:,:));
    end

%     G=channelmodel(KA,KM,KS,r, alpha);
%     rayleigh=(randn(NF,KA*KS,KM*KS)+sqrt(-1)*randn(NF,KA*KS,KM*KS))*sqrt(1/2);
%     for nF=1:NF
%         H(nF,:,:)=transpose(sqrt(G).*squeeze(rayleigh(nF,:,:)));
%     end
%     SA_index=[];
%     for kS=1:KS
%         SA_index=[SA_index kS*ones(1,KM)];
%     end
%     seq=[1:KSM];
%     seq2=[];
%     for kk=1:KSM
%         rr=floor(rand*length(seq))+1;
%         seq2=[seq2 seq(rr)];
%         seq(rr)=[];
%     end
%     H=H(:,seq2,:);
%     SA_index=SA_index(seq2);
    
    INDEX=zeros(1,KSM)-1; % MT specific subcarrier index
    counter=zeros(KS,NF);
    
    load=zeros(1,KS);  
    outage=zeros(KSM,NF);
    
    for kSM=1:KSM % system wide sequential DCA
        
        kS=SA_index(kSM); % SA index of the kSM-th MT
        if load(kS) < NF*KA
            load(kS)=load(kS)+1;
            ActiveFlag(nn,kSM)=1; 
            MTs_i=find(SA_index(1:kSM-1)==kS); % the MTs located in SA kS up to the (kSM-1)-th MT
            
            %--------------------
            % FCA
            %--------------------
            flag=1;
            while(flag)
                index_nF=floor(rand*NF)+1;
                if counter(kS,index_nF) < KA
                    counter(kS,index_nF)=counter(kS,index_nF)+1;
                    INDEX(kSM)=index_nF;
                    flag=0;
                end
            end
             
            
            
            %--------------------
            % fast DCA
            %--------------------
%             SIR_inc=zeros(1,NF);
%             for nF=1:NF
%                 Gamma=0;
%                 Gamma2=0;
%                 Gamma_dB=0;
%                 Gamma2_dB=0;
%                 if counter(kS,nF)<KA
%                     index_i=find(INDEX(MTs_i)==nF); % the MTs active at subcarrier nF up to the (kSM-1)-th MT
%                     K=length(index_i); % the number of MTs active at subcarrier nF in SA i 
%                     H_SA=reshape(H(nF,MTs_i(index_i),(kS-1)*KA+1:kS*KA), [K,KA]); % the MTs at subcarrier nF in SA kS up to the (kSM-1)-th MT
%                     B=diag(abs(inv(H_SA*H_SA'))); % K-by-1       
%                     MAI_DL = zeros(K,1);
%                     
%                     H_SA=[H_SA; reshape(H(nF,kSM,(kS-1)*KA+1:kS*KA), [1,KA])]; % the MTs at subcarrier nF in SA kS up to the kSM-th MT
%                     B2=diag(abs(inv(H_SA*H_SA'))); % (K+1)-by-1;
%                     
% 
%                     if K>0
%                         %Gamma=sum(1./B);
%                         Gamma_dB=sum(10*log10(1./B));
% %                         if Gamma==inf
% %                             Gamma=0;
% %                         end
%                     end
%                     %Gamma2=sum(1./B2);
%                     Gamma2_dB=sum(10*log10(1./B2));
% %                     if Gamma2==inf
% %                         Gamma2=sum(1./B2);
% %                     end
%                     
%                     %SIR_inc(nF)=Gamma2-Gamma;
%                     SIR_inc(nF)=Gamma2_dB-Gamma_dB;
%                 else % fully loaded on nF 
%                     SIR_inc(nF)=-Inf;                 
%                 end 
%             end % of nF
%             [MAX,index_nF]=max(SIR_inc);
%             counter(kS,index_nF)=counter(kS,index_nF)+1;
%             INDEX(kSM)=index_nF;
            
            %----------------------------------------------------
            % performance measurement
            % SIR of the MTs which are already activated at subcarrier
            % index_nF
            %----------------------------------------------------
        
            SIR_DL=zeros(KS*KA,1);        
            for i=1:KS
        
                MT_i=find(SA_index(1:kSM)==i);    
                index_i=find(INDEX(MT_i)==index_nF); % the MTs in the SA i at subcarrier index_nF
                K=length(index_i); % the number of MTs active at subcarrier index_nF in SA i 

                if K>0 % there is at least one MT being active at subcarrier index_nF in SA i
                    H_SA=reshape(H(index_nF, MT_i(index_i) ,(i-1)*KA+1:i*KA), [K,KA]);
                    B=diag(abs(inv(H_SA*H_SA'))); % K-by-1       
                    MAI_DL = zeros(K,1);
               
                    for j=1:KS
                        if j~=i
                            MT_j=find(SA_index(1:kSM)==j);
                            index_j=find(INDEX(MT_j)==index_nF); % the MTs in the co-channel SAs
                            H_temp = reshape(H(index_nF,MT_j(index_j),(j-1)*KA+1:j*KA), [length(index_j),KA]); % remove the first dimension
                            HH = inv(H_temp*H_temp'); % K-by-K
            
                            H_inter = reshape(H(index_nF,MT_i(index_i),(j-1)*KA+1:j*KA), [K,KA]);
                            Y=H_inter*H_temp'*HH*diag(1./sqrt(diag(HH))); % K-by-K
                            MAI_DL = MAI_DL + abs(Y).^2*ones(size(HH,1),1);
                        end 
                    end % of j
        
                    % SIR of the MTs active at subcarrier index_nF conditioned that
                    % kSM MTs are active in the system
                    SIR_DL((i-1)*KA+1:(i-1)*KA+K) = 1./(B.*MAI_DL);
                end
            end % of i
            
            if kSM>1
                %SIR(nn,kSM,:,:)=SIR(nn,kSM-1,:,:);
                outage(kSM,:)=outage(kSM-1,:);
            end
            %SIR(nn,kSM,index_nF,:)=10*log10(SIR_DL); % in dB
            outage(kSM,index_nF)=length(find(SIR_DL>0 & 10*log10(SIR_DL)<targetSIR));
        else % fully loaded
            ActiveFlag(nn,kSM)=-1; % the MT is will not be supported
            %SIR(nn,kSM,:,:)=SIR(nn,kSM-1,:,:);
            outage(kSM,:)=outage(kSM-1,:);
        end % of load(kS)<NF*KA
        
        Pout(nn,kSM)=( sum(outage(kSM,:)) + length(find(ActiveFlag(nn,1:kSM)==-1)) ) / kSM;
        
        
        if kS==1 % in the central SA
            kM_center=kM_center+1;
            Pout_cen(nn,kM_center)=Pout(nn,kSM);
        end
        
    end % of kSM
        
end % of nn
figure
semilogy(mean(Pout_cen,1))
%hold on
% for kSM=1:KSM
%     Pout_old(kSM)=(length(find(-Inf<SIR(:,kSM,:,:) & SIR(:,kSM,:,:)<targetSIR)) + length(find(ActiveFlag(:,1:kSM)==-1))) / (length(find(-Inf<SIR(:,kSM,:,:)))+length(find(ActiveFlag(:,1:kSM)==-1)));
% end
% plot(Pout_old)
cputime-t

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -