├── ProposedAlg.m ├── README.md ├── CreateSmallScaleFading.m ├── ChannelEstimation.m ├── ChannelModel.m ├── Plot_Layout.m ├── PlotUserPosition.m ├── PathlossShadowingModel.m ├── CreateLargeScaleFading.m ├── PilotAssignment.m ├── GetInitialization.m ├── Sim_EEvsNoUEs.m ├── Sim_Convergence.m └── Get_optSolutionPerIteration.m /ProposedAlg.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DinhNguyenCherry/Full-Duplex-Cell-Free-mMIMO/HEAD/ProposedAlg.m -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Full-Duplex-Cell-Free-mMIMO 2 | 3 | The MATLAB CODE is used for reproducing the results of the following paper: 4 | 5 | Hieu V. Nguyen, Van-Dinh Nguyen, Octavia A. Dobre, Shree Krishna Sharma, Symeon Chatzinotas, Björn Ottersten, and Oh-Soon Shin, 6 | 7 | "On the Spectral and Energy Efficiencies of Full-Duplex Cell-Free Massive MIMO," 8 | 9 | IEEE Journal on Selected Areas in Communications (SI in Multiple Antenna Technologies for Beyond 5G), 2020 10 | 11 | ### Dependency 12 | 13 | YALMIP 14 | 15 | SDPT3/ SeDuMi/ MOSEK 16 | 17 | MATLAB 18 | -------------------------------------------------------------------------------- /CreateSmallScaleFading.m: -------------------------------------------------------------------------------- 1 | function [Channel] = CreateSmallScaleFading( NoAntennasAtDestination, NoAntennasAtSource, dist) 2 | 3 | % This function is to generate the channel 4 | % NoSources : Number of source objects 5 | % NoDestinations: Number of destination objects 6 | % AntennaPerSource: Number of antennas per source (scalar or vector) 7 | % AntennaPerDestination: Number of antennas per destination (scalar or vector) 8 | 9 | if (nargin < nargin('CreateSmallScaleFading')) 10 | dist = {[]}; 11 | end 12 | 13 | 14 | if (strcmp(dist{1},'Rice')) 15 | v = dist{2}*ones(NoAntennasAtDestination,NoAntennasAtSource); 16 | s = dist{3}*ones(NoAntennasAtDestination,NoAntennasAtSource); 17 | Channel = sqrt(1/2)*(ricernd(v, s) + 1i*ricernd(v, s)); 18 | else 19 | Channel = sqrt(1/2)*(randn(NoAntennasAtDestination,NoAntennasAtSource) + 1i*randn(NoAntennasAtDestination,NoAntennasAtSource) ); 20 | end 21 | 22 | 23 | 24 | 25 | end -------------------------------------------------------------------------------- /ChannelEstimation.m: -------------------------------------------------------------------------------- 1 | function [ Est_H, Err_H ] = ChannelEstimation( M, Nm, tau, U, Bar_Xi, real_H, Beta, Ptr, sigma, isTranspose ) 2 | %CHANNELESTIMATION Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | 6 | Y_tr = cell(1,M); 7 | 8 | for m = 1:1:M 9 | 10 | Z = sigma*sqrt(1/2)*(randn(tau,Nm) + 1i*randn(tau,Nm)); 11 | % size(real_H([(m-1)*Nm+1:m*Nm],:)) 12 | % size(Bar_Xi) 13 | Y_tr{m} = sqrt(tau*Ptr)*Bar_Xi*real_H(:,[(m-1)*Nm+1:m*Nm]) + Z; 14 | 15 | end 16 | 17 | Est_H = []; 18 | Err_H = zeros(M,U); 19 | 20 | for m = 1:1:M 21 | 22 | Est_h = []; 23 | for l = 1:1:U 24 | Var = sigma^2; 25 | for ll = 1:1:U 26 | Var = Var + tau*Ptr*Beta(m,ll)*(Bar_Xi(:,l)'*Bar_Xi(:,ll))^2; 27 | end 28 | Est_h = [Est_h; sqrt(tau*Ptr)*Beta(m,l)/(Var)*Bar_Xi(:,l)'*Y_tr{m}]; 29 | Err_H(m,l) = Beta(m,l)*Nm*(1 - tau*Ptr*Beta(m,l)/(Var))/sigma^2; 30 | end 31 | 32 | if (isTranspose) 33 | Est_H = [Est_H; Est_h']; 34 | else 35 | Est_H = [Est_H, Est_h]; 36 | end 37 | 38 | 39 | end 40 | 41 | 42 | end 43 | 44 | -------------------------------------------------------------------------------- /ChannelModel.m: -------------------------------------------------------------------------------- 1 | %% Small-scale Fading & Channel Model 2 | 3 | %% DL and UL 4 | 5 | H_A2D = cell(K, M); 6 | H_A2U = cell(M, L); 7 | 8 | H_DL = []; 9 | H_UL = []; 10 | 11 | for m = 1:1:M 12 | 13 | temp_DL = []; 14 | for k = 1:1:K 15 | H_A2D{k,m} = CreateSmallScaleFading( 1, Nm ); 16 | temp_DL = [temp_DL, H_A2D{k,m}'*D_A2D(m,k)]; 17 | end 18 | H_DL = [H_DL; temp_DL]; 19 | 20 | temp_UL = []; 21 | for l = 1:1:L 22 | H_A2U{m,l} = CreateSmallScaleFading( Nm, 1 ); 23 | temp_UL = [temp_UL, H_A2U{m,l}*D_A2U(m,l)]; 24 | end 25 | H_UL = [H_UL; temp_UL]; 26 | 27 | end 28 | 29 | H_DL = H_DL'; 30 | 31 | 32 | %% A2A and SI channels 33 | 34 | G_AA = cell(M, M); 35 | G_AA_All = []; 36 | 37 | for m = 1:1:M 38 | temp_AA = []; 39 | for mp = 1:1:M 40 | if (m==mp) 41 | v = sqrt(10); s = 1; 42 | dist = {'Rice', v, s}; % K_factor = v^2/(2*s^2) = 5 43 | G_AA{m, mp} = CreateSmallScaleFading( Nm, Nm, dist ); 44 | % G_AA{m, mp} = CreateSmallScaleFading( Nm, Nm ); 45 | else 46 | G_AA{m, mp} = CreateSmallScaleFading( Nm, Nm ) * D_A2A(mp, m); 47 | end 48 | temp_AA = [temp_AA; G_AA{m, mp}]; 49 | end 50 | G_AA_All = [G_AA_All, temp_AA]; 51 | end 52 | 53 | 54 | G_CCI = CreateSmallScaleFading( K, L ) .* D_U2D(1:L,1:K)'; 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /Plot_Layout.m: -------------------------------------------------------------------------------- 1 | function [ done ] = Plot_Layout( RadiusOfRegion, Objects, Styles, Legends, WithColorBar ) 2 | %PLOT_LAYOUT Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | if (nargin<5) 6 | NoObj = length(Objects); 7 | WithColorBar = cell(1,NoObj); 8 | for iObj = 1:1:NoObj 9 | WithColorBar{1,iObj} = cell(1,1); 10 | WithColorBar{1,iObj}{1,1} = 'none'; 11 | end 12 | end 13 | 14 | 15 | 16 | Extra = 0.05; 17 | 18 | hold on 19 | 20 | ang=0:0.01:2*pi; 21 | 22 | xp=RadiusOfRegion*cos(ang); 23 | yp=RadiusOfRegion*sin(ang); 24 | ax = plot(0+xp,0+yp, 'HandleVisibility', 'off'); 25 | 26 | % xp1=RadiusOfInnerzone*cos(ang); 27 | % yp1=RadiusOfInnerzone*sin(ang); 28 | % ax1 = plot(0+xp1,0+yp1); 29 | 30 | NoObj = length(Objects); 31 | 32 | for iObj = 1:1:NoObj 33 | 34 | if (strfind(WithColorBar{1,iObj}{1,1},'none')) 35 | scatter(Objects{1,iObj}(:,1), Objects{1,iObj}(:,2), 100, Styles{iObj}) 36 | else 37 | scatter(Objects{1,iObj}(:,1), Objects{1,iObj}(:,2), 200, Objects{1,iObj}(:,3), 'filled') 38 | colorbar('Ticks',WithColorBar{1,iObj}{1,2},... 39 | 'TickLabels',WithColorBar{1,iObj}{1,3}) 40 | colormap(jet) 41 | % colorbar('Ticks',[min(Objects{1,iObj}(:,3)) 1 max(Objects{1,iObj}(:,3))],... 42 | % 'TickLabels',{'Sleep','Weak Active', 'Strong Active'}) 43 | 44 | % AxesH = axes('CLim', [-12, 12]); 45 | % colorbar('YTick',0:1:1) 46 | % colorbar('YTickLabel', {'Sleep','Active'}) 47 | end 48 | % scatter(positionUplinkUsers(:,1), positionUplinkUsers(:,2), 'b+ ') 49 | % scatter(positionDownlinkUsers(:,1), positionDownlinkUsers(:,2), 'r* ') 50 | 51 | end 52 | 53 | 54 | set(gca,'XTick',[-RadiusOfRegion :0.2*RadiusOfRegion: RadiusOfRegion]) 55 | set(gca,'YTick',[-RadiusOfRegion :0.2*RadiusOfRegion: RadiusOfRegion]) 56 | 57 | xlim([-(RadiusOfRegion+Extra*RadiusOfRegion) (RadiusOfRegion+Extra*RadiusOfRegion)]) 58 | ylim([-(RadiusOfRegion+Extra*RadiusOfRegion) (RadiusOfRegion+Extra*RadiusOfRegion)]) 59 | axis('square') 60 | 61 | legend(Legends); 62 | 63 | done = 1; 64 | 65 | 66 | end 67 | 68 | -------------------------------------------------------------------------------- /PlotUserPosition.m: -------------------------------------------------------------------------------- 1 | close all 2 | clear 3 | clc 4 | 5 | load('ForTable.mat','positionDownlinkUsers'); 6 | load('ForTable.mat','positionUplinkUsers'); 7 | load('ForTable.mat','RadiusOfCell'); 8 | 9 | % load('Rate_all_4.mat','D_H'); 10 | % load('Rate_all_4.mat','D_G_channel'); 11 | % 12 | % load('Rate_all_4.mat','StandardDeviation'); 13 | % load('Rate_all_4.mat','ploss'); 14 | % load('Rate_all_4.mat','RadiusOfCell'); 15 | % load('Rate_all_4.mat','RadiusOfNearestUser'); 16 | 17 | 18 | % K=size(D_H,1); 19 | % distanceBS_To_DownlinkUsers = 1000*ones(1,K); 20 | % 21 | % while (max(distanceBS_To_DownlinkUsers)>100 || min(distanceBS_To_DownlinkUsers)<10) 22 | % 23 | % Zvector = StandardDeviation*randn(1,K) 24 | % betavector_downlink = (diag(D_H)').^2 25 | % 26 | % distanceBS_To_DownlinkUsers = ((10.^(Zvector/10))./betavector_downlink).^(1/ploss)*RadiusOfNearestUser; 27 | % 28 | % end 29 | 30 | % anglevector = 2*pi*rand(1,K); 31 | % positionDownlinkUsers = [(distanceBS_To_DownlinkUsers.*cos(anglevector))' (distanceBS_To_DownlinkUsers.*sin(anglevector))'] 32 | 33 | 34 | % L=size(D_G_channel,1); 35 | % distanceBS_To_UplinkUsers = 1000*ones(1,L); 36 | % 37 | % while (max(distanceBS_To_UplinkUsers)>100 || min(distanceBS_To_UplinkUsers)<10) 38 | % 39 | % Zvector = StandardDeviation*randn(1,L); 40 | % betavector_uplink = (diag(D_G_channel)').^2; 41 | % 42 | % distanceBS_To_UplinkUsers = ((10.^(Zvector/10))./betavector_uplink).^(1/ploss)*RadiusOfNearestUser; 43 | % 44 | % end 45 | % 46 | % anglevector = 2*pi*rand(1,L); 47 | % positionUplinkUsers = [(distanceBS_To_UplinkUsers.*cos(anglevector))' (distanceBS_To_UplinkUsers.*sin(anglevector))'] 48 | 49 | 50 | %% plot 51 | 52 | ang=0:0.01:2*pi; 53 | xp=RadiusOfCell*cos(ang); 54 | yp=RadiusOfCell*sin(ang); 55 | ax = plot(0+xp,0+yp); 56 | 57 | hold on 58 | scatter(0,0 , 'k^ ') 59 | 60 | Users = size(positionDownlinkUsers,1); 61 | for iUser = 1:1:Users 62 | scatter(positionDownlinkUsers(iUser,1), positionDownlinkUsers(iUser,2), 'r* ') 63 | text(positionDownlinkUsers(iUser,1)+4, positionDownlinkUsers(iUser,2), num2str(iUser),'color','r'); 64 | scatter(positionUplinkUsers(iUser,1), positionUplinkUsers(iUser,2), 'b+ ') 65 | length(num2str(iUser)) 66 | text(positionUplinkUsers(iUser,1)-5-3*length(num2str(iUser)), positionUplinkUsers(iUser,2), num2str(iUser),'color','b'); 67 | end 68 | 69 | set(gca,'XTick',[-100 :20: 100]) 70 | set(gca,'YTick',[-100 :20: 100]) 71 | 72 | xlim([-105 105]) 73 | ylim([-105 105]) 74 | axis('square') 75 | 76 | -------------------------------------------------------------------------------- /PathlossShadowingModel.m: -------------------------------------------------------------------------------- 1 | %% Large-scale Fading 2 | 3 | RadiusOfRegion = 1000; 4 | % RadiusOfNearestUser = 10; 5 | % PLx = 145.5; 6 | % PLy = 20.9; 7 | 8 | PL = 140.7; 9 | d0 = 10/1000; 10 | d1 = 50/1000; 11 | Shd = 8; 12 | 13 | % FirstTier = 2*RadiusOfCell*[1 0; cos(pi/3) sin(pi/3); -cos(pi/3) sin(pi/3); -1 0; -cos(pi/3) -sin(pi/3); cos(pi/3) -sin(pi/3)]; 14 | 15 | if (isempty(loadingfile)) 16 | Parameters = {RadiusOfRegion, PL, d0, d1, Shd, 'S2S', 0}; % type = 'S2S' 17 | if (Method==3 || Method==6) 18 | positionAPs = [0 0]; 19 | [ D_A2A, positionAPs, ~ ] = CreateLargeScaleFading( M, M, Parameters, positionAPs ) 20 | else 21 | [ D_A2A, positionAPs, ~ ] = CreateLargeScaleFading( M, M, Parameters ) 22 | end 23 | 24 | Parameters = {RadiusOfRegion, PL, d0, d1, Shd, 'S2D'}; % type = 'S2D' : AP --> DL users 25 | [ D_A2D, ~, positionDLUs ] = CreateLargeScaleFading( M, K, Parameters, positionAPs ) 26 | [ D_A2U, ~, positionULUs ] = CreateLargeScaleFading( M, L, Parameters, positionAPs ); 27 | [ D_U2D, ~, ~ ] = CreateLargeScaleFading( L, K, Parameters, positionULUs, positionDLUs ); 28 | else 29 | 30 | if (Method==3 || Method==6) 31 | positionAPs = [0 0]; 32 | recalcD = 1; 33 | else 34 | load(loadingfile,'positionAPs'); 35 | recalcD = 0; 36 | end 37 | load(loadingfile,'positionDLUs'); 38 | load(loadingfile,'positionULUs'); 39 | if (recalcD) 40 | Parameters = {RadiusOfRegion, PL, d0, d1, Shd, 'S2S', 0}; % type = 'S2S' 41 | [ D_A2A, positionAPs, ~ ] = CreateLargeScaleFading( M, M, Parameters, positionAPs ) 42 | Parameters = {RadiusOfRegion, PL, d0, d1, Shd, 'S2D'}; % type = 'S2D' : AP --> DL users 43 | [ D_A2D, ~, positionDLUs ] = CreateLargeScaleFading( M, K, Parameters, positionAPs ) 44 | [ D_A2U, ~, positionULUs ] = CreateLargeScaleFading( M, L, Parameters, positionAPs ); 45 | [ D_U2D, ~, ~ ] = CreateLargeScaleFading( L, K, Parameters, positionULUs, positionDLUs ); 46 | else 47 | load(loadingfile,'D_A2A'); 48 | load(loadingfile,'D_A2D'); 49 | load(loadingfile,'D_A2U'); 50 | load(loadingfile,'D_U2D'); 51 | end 52 | end 53 | 54 | Layout = Plot_Layout(RadiusOfRegion, {positionAPs, positionDLUs, positionULUs}, {'k^', 'rs', 'bo'}, {'AP', 'DLU', 'ULU'} ) 55 | 56 | 57 | APs_DLs = ones(M,K); 58 | APs_ULs = ones(M,L); 59 | if (Method==4 || Method==7) 60 | APs_DLs = zeros(M,K); 61 | AP_NoDLs = zeros(M,1); 62 | for k = 1:1:K 63 | DLPos_k = repmat(positionDLUs(k,:),M,1); 64 | Dist_k = sqrt(sum((DLPos_k-positionAPs).^2,2)+10^12*(AP_NoDLs>=Nm)); 65 | [~, AP_selected] = min(Dist_k); 66 | APs_DLs(AP_selected,k) = 1; 67 | AP_NoDLs(AP_selected) = AP_NoDLs(AP_selected) + 1; 68 | end 69 | % AP_NoDLs' 70 | % sum(AP_NoDLs) 71 | % sum(APs_DLs) 72 | % D_A2D = D_A2D.*APs_DLs; 73 | 74 | APs_ULs = zeros(M,L); 75 | AP_NoULs = zeros(M,1); 76 | for l = 1:1:L 77 | ULPos_l = repmat(positionULUs(l,:),M,1); 78 | Dist_l = sqrt(sum((ULPos_l-positionAPs).^2,2)+10^12*(AP_NoULs>=Nm)); 79 | [~, AP_selected] = min(Dist_l); 80 | APs_ULs(AP_selected,l) = 1; 81 | AP_NoULs(AP_selected) = AP_NoULs(AP_selected) + 1; 82 | end 83 | % AP_NoULs' 84 | % sum(AP_NoULs) 85 | % sum(APs_ULs) 86 | % D_A2U = D_A2U.*APs_ULs; 87 | end 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /CreateLargeScaleFading.m: -------------------------------------------------------------------------------- 1 | function [ D_S2D, positionSources, positionDests ] = CreateLargeScaleFading( NoSources, NoDestinations, Parameters, posSources, posDests ) 2 | %CREATED Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | Radius = Parameters{1}; 6 | % NearestS2D = Parameters{2}; % nearest distance from sources to destinations 7 | % PLx = Parameters{2}; 8 | % PLy = Parameters{3}; 9 | L = Parameters{2}; 10 | d0 = Parameters{3}; 11 | d1 = Parameters{4}; 12 | Shd = Parameters{5}; 13 | type = Parameters{6}; 14 | 15 | if (length(Parameters)>6) 16 | DistLim = Parameters{7}; 17 | else 18 | DistLim = 0; 19 | end 20 | 21 | while (true) 22 | 23 | if (nargin0) 103 | continue 104 | end 105 | else 106 | % DistLim 107 | % Distcomp = [distance_S2D=0]; 144 | c1 = [((d1-distance)./abs(d1-distance+10^(-20)))>=0]; 145 | 146 | Pathloss_dB = -L - 20 * ( c0*log10(d0) + (1-c0).*log10(distance) ) ... 147 | - 15 * ( c1*log10(d1) + (1-c1).*log10(distance) ); 148 | 149 | ShdCheck = [distance>d1]; 150 | Pathloss_dB = Pathloss_dB - Shd*rand(size(distance)).*ShdCheck; 151 | 152 | Pathloss = 10.^(Pathloss_dB/10); 153 | 154 | end 155 | 156 | -------------------------------------------------------------------------------- /PilotAssignment.m: -------------------------------------------------------------------------------- 1 | function [ Upsilon ] = PilotAssignment( Nm, tau, Ptr, Beta ) 2 | %PILOTASSIGNMENT Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | U = size(Beta, 2); 6 | 7 | Beta_tilde = Nm*tau*Ptr*sum(Beta); 8 | 9 | Upsilon = eye(tau); 10 | 11 | if (U<=tau) 12 | Upsilon = Upsilon(:,1:U); 13 | else 14 | 15 | minHeap = GenHeap(Beta_tilde(1:tau), Upsilon, 'min'); 16 | 17 | % nHeap = minHeap{1} 18 | % minKey = minHeap{2} 19 | % minParam = minHeap{3} 20 | % minParent = minHeap{4} 21 | % minChildren = minHeap{5} 22 | 23 | % error('Layout is done !!!'); 24 | 25 | maxHeap = GenHeap(Beta_tilde(tau+1:U), [tau+1:U], 'max'); 26 | 27 | Upsilon = [Upsilon, zeros(size(Upsilon,1), U-tau)]; 28 | 29 | while (maxHeap{1}>0) 30 | Upsilon(:,maxHeap{3}(1)) = minHeap{3}(:,1); 31 | minHeap = RepNode(minHeap, minHeap{2}(1)+maxHeap{2}(1), minHeap{3}(:,1)); 32 | maxHeap = RemNode(maxHeap); 33 | % maxHeap{1} 34 | end 35 | end 36 | 37 | end 38 | 39 | function [ ReturnHeap ] = RemNode( OrgHeap ) 40 | 41 | % Remove root node from maxHeap 42 | 43 | CurPos = 1; 44 | nHeap = OrgHeap{1}-1; 45 | Key = OrgHeap{2}; 46 | Param = OrgHeap{3}; 47 | Parent = OrgHeap{4}; 48 | Children = OrgHeap{5}; 49 | 50 | while (true) 51 | if (sum(Children(:,CurPos)>0)==2) 52 | if (Key(Children(1,CurPos))>=Key(Children(2,CurPos))) 53 | Key(CurPos) = Key(Children(1,CurPos)); 54 | Param(:,CurPos) = Param(:,Children(1,CurPos)); 55 | if (sum(Children(:,Children(1,CurPos))>0)>0) 56 | CurPos = Children(1,CurPos); 57 | else 58 | Children(1,CurPos) = 0; 59 | break 60 | end 61 | else 62 | Key(CurPos) = Key(Children(2,CurPos)); 63 | Param(:,CurPos) = Param(:,Children(2,CurPos)); 64 | if (sum(Children(:,Children(2,CurPos))>0)>0) 65 | CurPos = Children(2,CurPos); 66 | else 67 | Children(2,CurPos) = 0; 68 | break 69 | end 70 | end 71 | elseif (sum(Children(:,CurPos)>0)==1) 72 | if (Children(1,CurPos)>0) 73 | c = 1; 74 | else 75 | c = 2; 76 | end 77 | 78 | Key(CurPos) = Key(Children(c,CurPos)); 79 | Param(:,CurPos) = Param(:,Children(c,CurPos)); 80 | if (sum(Children(:,Children(c,CurPos))>0)>0) 81 | CurPos = Children(c,CurPos); 82 | else 83 | Children(c,CurPos) = 0; 84 | break 85 | end 86 | else 87 | break 88 | end 89 | end 90 | 91 | ReturnHeap = {nHeap, Key, Param, Parent, Children}; 92 | 93 | end 94 | 95 | 96 | 97 | function [ ReturnHeap ] = RepNode( OrgHeap, newKey, newParam ) 98 | 99 | % Replace root node for minHeap 100 | 101 | CurPos = 1; 102 | nHeap = OrgHeap{1}; 103 | Key = OrgHeap{2}; 104 | Param = OrgHeap{3}; 105 | Parent = OrgHeap{4}; 106 | Children = OrgHeap{5}; 107 | 108 | while (true) 109 | 110 | if (sum(Children(:,CurPos)>0)==2) 111 | if (newKey<=Key(Children(1,CurPos)) && newKey<=Key(Children(2,CurPos))) 112 | Key(CurPos) = newKey; 113 | Param(:,CurPos) = newParam; 114 | break 115 | else 116 | if (Key(Children(1,CurPos))<=Key(Children(2,CurPos))) 117 | Key(CurPos) = Key(Children(1,CurPos)); 118 | Param(:,CurPos) = Param(:,Children(1,CurPos)); 119 | CurPos = Children(1,CurPos); 120 | else 121 | Key(CurPos) = Key(Children(2,CurPos)); 122 | Param(:,CurPos) = Param(:,Children(2,CurPos)); 123 | CurPos = Children(2,CurPos); 124 | end 125 | end 126 | elseif (sum(Children(:,CurPos)>0)==1) 127 | if (Children(1,CurPos)>0) 128 | c = 1; 129 | else 130 | c = 2; 131 | end 132 | if (newKey<=Key(Children(c,CurPos))) 133 | Key(CurPos) = newKey; 134 | Param(:,CurPos) = newParam; 135 | break 136 | else 137 | Key(CurPos) = Key(Children(c,CurPos)); 138 | Param(:,CurPos) = Param(:,Children(c,CurPos)); 139 | CurPos = Children(c,CurPos); 140 | end 141 | else 142 | Key(CurPos) = newKey; 143 | Param(:,CurPos) = newParam; 144 | break 145 | end 146 | 147 | end 148 | 149 | ReturnHeap = {nHeap, Key, Param, Parent, Children}; 150 | 151 | end 152 | 153 | 154 | function [ HeapTree ] = GenHeap( Keys, ParamInit, Type ) 155 | 156 | Hmin = strcmp(Type,'min'); 157 | 158 | 159 | nHeap = 0; 160 | Key = []; 161 | Param = []; 162 | Parent = zeros(1, length(Keys)); 163 | Children = zeros(2, length(Keys)); 164 | 165 | 166 | for i = 1:1:length(Keys) 167 | Extkey = Keys(i); 168 | ExtPar = ParamInit(:,i); 169 | CurPos = 1; 170 | nHeap = nHeap + 1; 171 | while (true) 172 | 173 | if (nHeap==1) 174 | Key = [Key Extkey]; 175 | Param = [Param, ExtPar]; 176 | break 177 | else 178 | if (Hmin) 179 | if (ExtkeyKey(CurPos)) 189 | tmpKey = Key(CurPos); 190 | tmpPar = Param(:,CurPos); 191 | Key(CurPos) = Extkey; 192 | Param(:,CurPos) = ExtPar; 193 | Extkey = tmpKey; 194 | ExtPar = tmpPar; 195 | end 196 | end 197 | 198 | if (Children(1,CurPos)==0) 199 | Parent(nHeap) = CurPos; 200 | Children(1,CurPos) = nHeap; 201 | Key(nHeap) = Extkey; 202 | Param(:,nHeap) = ExtPar; 203 | break 204 | elseif (Children(2,CurPos)==0) 205 | Parent(nHeap) = CurPos; 206 | Children(2,CurPos) = nHeap; 207 | Key(nHeap) = Extkey; 208 | Param(:,nHeap) = ExtPar; 209 | break 210 | else 211 | if (Hmin) 212 | if (Key(Children(1,CurPos)) <= Key(Children(2,CurPos)) ) 213 | if (Extkey<=Key(Children(1,CurPos))) 214 | CurPos = Children(1,CurPos); 215 | else 216 | CurPos = Children(2,CurPos); 217 | end 218 | else 219 | if (Extkey<=Key(Children(2,CurPos))) 220 | CurPos = Children(2,CurPos); 221 | else 222 | CurPos = Children(1,CurPos); 223 | end 224 | end 225 | else 226 | if (Key(Children(1,CurPos)) >= Key(Children(2,CurPos)) ) 227 | if (Extkey>=Key(Children(1,CurPos))) 228 | CurPos = Children(1,CurPos); 229 | else 230 | CurPos = Children(2,CurPos); 231 | end 232 | else 233 | if (Extkey>=Key(Children(2,CurPos))) 234 | CurPos = Children(2,CurPos); 235 | else 236 | CurPos = Children(1,CurPos); 237 | end 238 | end 239 | end 240 | end 241 | 242 | 243 | end 244 | 245 | end 246 | 247 | end 248 | 249 | HeapTree = {nHeap, Key, Param, Parent, Children}; 250 | 251 | 252 | end 253 | -------------------------------------------------------------------------------- /GetInitialization.m: -------------------------------------------------------------------------------- 1 | function [ StartingPoint ] = GetInitialization( M, K, L, Nm, sigma, H_d, H_u, G_SI, G_CCI, nu, Pd, Pu, eta, C_SE, C_EE, Pa, Ps, PAP, Pl, SysModel, APConn, Delta, ErrorEst ) 2 | %GETINITIALIZATION Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | if (nargin=5) 64 | omega = 100*rand(1,K); 65 | end 66 | 67 | T_tilde = zeros(K,K); 68 | for i = 1:1:K 69 | for j = 1:1:K 70 | if (i0); 87 | if (length(idx_k)==1) 88 | QT([(m-1)*Nm+1:m*Nm], idx_k) = H_d(idx_k,[(m-1)*Nm+1:m*Nm])'; 89 | elseif (length(idx_k)>1) 90 | % size(QT([(m-1)*Nm+1:m*Nm], idx_k)) 91 | % size(H_d(idx_k,[(m-1)*Nm+1:m*Nm])) 92 | QT([(m-1)*Nm+1:m*Nm], idx_k) = H_d(idx_k,[(m-1)*Nm+1:m*Nm])'*inv(H_d(idx_k,[(m-1)*Nm+1:m*Nm])*H_d(idx_k,[(m-1)*Nm+1:m*Nm])'); 93 | end 94 | end 95 | 96 | for k = 1:1:K 97 | QT(:,k) = QT(:,k)/norm(QT(:,k)); 98 | end 99 | 100 | else 101 | 102 | if (DLULSchemes==1) 103 | 104 | QT = Q'*T_tilde; 105 | 106 | elseif (DLULSchemes==2) 107 | 108 | QT = H_d'*inv(H_d*(H_d)'); 109 | 110 | else 111 | 112 | QT = H_d'; 113 | 114 | end 115 | 116 | if (DLULSchemes~=1) 117 | for k = 1:1:K 118 | QT(:,k) = QT(:,k)/norm(QT(:,k)); 119 | end 120 | end 121 | end 122 | 123 | % QT_Blk = []; 124 | % for m = 1:1:M 125 | % QT_Blk = blkdiag(QT_Blk,QT([(m-1)*Nm+1:m*Nm],:)); 126 | % end 127 | 128 | 129 | W = QT*diag(omega.^(0.5)); 130 | 131 | DLMask = QT; 132 | 133 | if (Method==2 && DLULSchemes==1) 134 | W = P*W; 135 | DLMask = P*QT; 136 | end 137 | 138 | % W = QT*diag(omega.^(0.5)); 139 | 140 | p = 1*rand(1,L);%0.01*Pl 141 | 142 | if (Method>=5) 143 | p = 10*rand(1,L); 144 | end 145 | 146 | mu = ones(1,M);%rand(1, M);%%0.5* 147 | 148 | psi_d = zeros(1,K); 149 | 150 | for k = 1:1:K 151 | 152 | sum_hw_k = 0; 153 | for kp = 1:1:K 154 | if (kp==k) 155 | continue 156 | end 157 | % size(W) 158 | sum_hw_k = sum_hw_k + norm(H_d(k,:)*W(:,kp))^2; 159 | end 160 | 161 | 162 | % psi_d(k) = 1/(norm(H_d(k,:)*QT(:,k)))^2*(sum_hw_k+norm(G_CCI(k,:).* (p.^(0.5)) )^2 + sigma^2 ); 163 | psi_d(k) = 1/(norm(H_d(k,:)*DLMask(:,k)))^2*(sum_hw_k+norm(G_CCI(k,:).* (p.^(0.5)) )^2 + sigma^2 + ... 164 | norm(kron((Err_H_DL(:,k)'/Nm).^(0.5),ones(1,Nm))*W)^2 + ... 165 | norm(Err_GCCI(k,:).* (p.^(0.5)))^2); 166 | 167 | end 168 | 169 | 170 | lambda_d = omega./psi_d; 171 | 172 | psi_u = zeros(1,L); 173 | ULMask = []; 174 | 175 | if (Method==4 || Method==7) 176 | 177 | A_SIC = zeros(L, M*Nm); 178 | 179 | for m=1:1:M 180 | idx_l = find(APs_ULs(m,:)>0); 181 | if (length(idx_l)==1) 182 | A_SIC(idx_l, [(m-1)*Nm+1:m*Nm]) = H_u([(m-1)*Nm+1:m*Nm], idx_l)'; 183 | elseif (length(idx_l)>1) 184 | A_SIC(idx_l, [(m-1)*Nm+1:m*Nm]) = inv(H_u([(m-1)*Nm+1:m*Nm], idx_l)'*H_u([(m-1)*Nm+1:m*Nm], idx_l))*H_u([(m-1)*Nm+1:m*Nm], idx_l)'; 185 | end 186 | end 187 | 188 | for l = 1:1:L 189 | psi_u(l) = 1/(A_SIC(l,:)*H_u(:,l))^2*( norm(A_SIC(l,:)*H_u(:,[1:(l-1) (l+1):L])*diag(p([1:(l-1) (l+1):L]).^(0.5)))^2 + ... 190 | norm(A_SIC(l,:)*G_SI*W)^2 + sigma^2*norm(A_SIC(l,:))^2 + ... 191 | norm(A_SIC(l,:)*kron((Err_H_UL/Nm).^(0.5),ones(Nm,1))*diag(p.^(0.5)))^2); 192 | ULMask = [ULMask; A_SIC(l,:)./norm(A_SIC(l,:))]; 193 | 194 | end 195 | else 196 | 197 | if (DLULSchemes==2 || DLULSchemes==3) 198 | if (DLULSchemes==2) 199 | A_SIC = inv(H_u'*H_u)*H_u'; 200 | else 201 | A_SIC = H_u'; 202 | end 203 | for l = 1:1:L 204 | psi_u(l) = 1/(A_SIC(l,:)*H_u(:,l))^2*( norm(A_SIC(l,:)*H_u(:,[1:(l-1) (l+1):L])*diag(p([1:(l-1) (l+1):L]).^(0.5)))^2 + ... 205 | norm(A_SIC(l,:)*G_SI*W)^2 + sigma^2*norm(A_SIC(l,:))^2 + ... 206 | norm(Err_H_UL*(p'.^(0.5)))^2); 207 | ULMask = [ULMask; A_SIC(l,:)./norm(A_SIC(l,:))]; 208 | 209 | end 210 | else 211 | for l = 1:1:L 212 | A_SIC = inv(H_u(:,[l:L])'*H_u(:,[l:L]))*H_u(:,[l:L])'; 213 | if (l==L) 214 | psi_u(l) = 1/(A_SIC(1,:)*H_u(:,l))^2*( norm(A_SIC(1,:)*G_SI*W)^2 + sigma^2*norm(A_SIC(1,:))^2 + ... 215 | norm(Err_H_UL*(p'.^(0.5)))^2 ); 216 | else 217 | psi_u(l) = 1/(A_SIC(1,:)*H_u(:,l))^2*( norm(A_SIC(1,:)*H_u(:,[(l+1):L])*diag(p([(l+1):L]).^(0.5)))^2 + ... 218 | norm(A_SIC(1,:)*G_SI*W)^2 + sigma^2*norm(A_SIC(1,:))^2 + ... 219 | norm(Err_H_UL*(p'.^(0.5)))^2); 220 | end 221 | ULMask = [ULMask; A_SIC(1,:)./norm(A_SIC(1,:))]; 222 | % A_ZFSIC = [A_ZFSIC; A_SIC(1,:)]; 223 | end 224 | end 225 | end 226 | 227 | lambda_u = p./psi_u; 228 | 229 | xi = zeros(1,M); 230 | sum_chi_xi = 0; 231 | 232 | for m = 1:1:M 233 | sum_norm_w = 0; 234 | for k = 1:1:K 235 | w_km = W([((m-1)*Nm+1):(m*Nm)],k); 236 | sum_norm_w = sum_norm_w + norm(w_km)^2*(1/nu(1)+Pd/(norm(w_km)^2+epspow)); 237 | end 238 | xi(m) = sum_norm_w; %+Pa+Pu 239 | sum_chi_xi = sum_chi_xi + (xi(m)/(2*mu(m))*mu(m)^2+mu(m)/(2*xi(m))*xi(m)^2); 240 | 241 | % DLEffPow_current(m) = sqrt(sum_norm_w); 242 | % ULEffPow_current(m) = sqrt(sum(p.*real(diag(ULMask(:,[(m-1)*Nm+1:m*Nm])*H_u([(m-1)*Nm+1:m*Nm],:))'.^2))); 243 | end 244 | 245 | chi = sum_chi_xi + sum(p) + sum(mu*Pu) + sum(mu*Pa) + sum((1-mu)*Ps); 246 | 247 | phi = 1/(eta*C_SE+(1-eta)*C_EE/chi); 248 | 249 | phi_bar = 1/(eta*C_SE*chi + (1-eta)*C_EE); 250 | 251 | % phi = phi_bar*chi; 252 | 253 | DLSel_current = ones(K,M); 254 | ULSel_current = ones(L,M); 255 | 256 | 257 | % StartingPoint = {DLMask, ULMask, omega, p, mu, lambda_d, lambda_u, psi_d, psi_u, xi, {phi, phi_bar}, chi, {DLEffPow_current, ULEffPow_current} }; 258 | StartingPoint = {DLMask, ULMask, omega, p, mu, lambda_d, lambda_u, psi_d, psi_u, xi, {phi, phi_bar}, chi, {DLSel_current, ULSel_current} }; 259 | 260 | end 261 | 262 | 263 | 264 | 265 | 266 | -------------------------------------------------------------------------------- /Sim_EEvsNoUEs.m: -------------------------------------------------------------------------------- 1 | close all 2 | clear 3 | clc 4 | 5 | pathCell = regexp(path, pathsep, 'split'); 6 | if (~any(strcmpi('.\yalmip', pathCell))) 7 | disp('_________________ Adding path ... _________________') 8 | addpath(genpath('./yalmip')); 9 | addpath(genpath('./SeDuMi_1_3')); 10 | addpath(genpath('./SDPT3-4.0')); 11 | end 12 | clear pathCell 13 | 14 | addpath(genpath('./rician')); 15 | 16 | pathname = fileparts('./Figures/EE_vs_NoUEs/'); 17 | addpath(genpath('./Figures/EE_vs_NoUEs')); 18 | 19 | tic 20 | 21 | %% Simulation Setting 22 | 23 | Simname = 'EEvsNoUEs_ext'; 24 | 25 | Files = 1:1; 26 | NumOfSim = 10; 27 | NoWorkers = 6; 28 | 29 | Method = 1; % 1: FD-DM-MIMO 30 | % 2: FD-DM-MIMO with PCA 31 | % 3: FD-CM-MIMO 32 | % 4: FD-SC (small cell) 33 | % 5: HD-DM-MIMO 34 | % 6: HD-SC (small cell) 35 | 36 | 37 | DLULSchemes = 3; % 1: DPC/ZF-SIC 38 | % 2: ZF/ZF 39 | % 3: MRT/MRC 40 | 41 | Methodname = {'FD_DM_MIMO', 'FD_DM_MIMO_PCA', 'FD_CM_MIMO', 'FD_SC', 'HD_DM_MIMO', 'HD_SC'}; 42 | DLULname = {'DPC_SIC','ZF','MRT_MRC'}; 43 | 44 | % global MaxIteration 45 | % MaxIteration = 50; 46 | 47 | 48 | 49 | loadingfile = [];%['Layout6_EE.mat'];% 50 | recalcD = 0; 51 | RenewChannel = 1; 52 | 53 | 54 | 55 | %% Set Parameters 56 | 57 | ParameterSetting 58 | 59 | URange = 10; 60 | lenRange = length(URange); 61 | 62 | %% Build Channel Model 63 | 64 | % h = waitbar(0, [ str_Group ': ' num2str(floor(0*100 / NumberOfRunning)) ' % Completed'],'Name','Percent of completion'); 65 | h = waitbar(0, 'Please wait ...','Name','Percent of completion'); 66 | 67 | rho = 10^(rho_dB/10); 68 | 69 | iRate_Threshold = Rate_Threshold*log(2); 70 | 71 | NoEntries = length(Files)*NumOfSim; 72 | 73 | for iFile = Files 74 | 75 | filename = ['[' Simname num2str(floor(10*Rate_Threshold)) '] Method' num2str(Method) '_' DLULname{DLULSchemes} '_' num2str(iFile) '.mat']; 76 | 77 | savedname = fullfile(pathname, filename); 78 | 79 | Channels = cell(NumOfSim,lenRange); 80 | 81 | 82 | for iU = 1:1:lenRange 83 | 84 | K = URange(iU); 85 | L = URange(iU); 86 | Pl_dB = 23 * ones(L,1); 87 | Pl = 10.^(Pl_dB/10)*NORMAL*PowNorm; 88 | 89 | 90 | PathlossShadowingModel 91 | 92 | for iSim = 1:1:NumOfSim 93 | ChannelModel 94 | Channels{iSim,iU} = {H_DL, H_UL, G_AA_All, G_CCI}; 95 | end 96 | 97 | end 98 | 99 | % error('Layout is done !!!'); 100 | 101 | %% Run Algorithms 102 | 103 | 104 | 105 | % figure; 106 | 107 | % Chain = cell(NumOfSim,1); 108 | 109 | 110 | 111 | % error('Layout is done !!!'); 112 | 113 | 114 | 115 | OptValue_All = zeros(NumOfSim,lenRange); 116 | OptSolution_All = cell(NumOfSim,lenRange); 117 | OptValueChain_All = cell(NumOfSim,lenRange); 118 | DLRate_PerUser_All = cell(NumOfSim,lenRange); 119 | ULRate_PerUser_All = cell(NumOfSim,lenRange); 120 | 121 | 122 | iSim = 0; 123 | while (iSim3600) 289 | hour = floor(time/3600); 290 | time = mod(time,3600); 291 | end 292 | if (time>60) 293 | min = floor(time/60); 294 | time = mod(time,60); 295 | end 296 | disp(['Running Time = ' num2str(hour) ' h ' num2str(min) ' m ' num2str(time) ' s.' ]); -------------------------------------------------------------------------------- /Sim_Convergence.m: -------------------------------------------------------------------------------- 1 | close all 2 | clear 3 | clc 4 | 5 | pathCell = regexp(path, pathsep, 'split'); 6 | if (~any(strcmpi('.\yalmip', pathCell))) 7 | disp('_________________ Adding path ... _________________') 8 | addpath(genpath('./yalmip')); 9 | addpath(genpath('./SeDuMi_1_3')); 10 | addpath(genpath('./SDPT3-4.0')); 11 | end 12 | clear pathCell 13 | 14 | addpath(genpath('./rician')); 15 | 16 | pathname = fileparts('./Figures/Convergence/'); 17 | addpath(genpath('./Figures/Convergence')); 18 | 19 | tic 20 | 21 | %% Simulation Setting 22 | 23 | NumOfSim = 1; 24 | 25 | Method = 1; % 1: FD-DM-MIMO 26 | % 2: FD-DM-MIMO with PCA 27 | % 3: FD-CM-MIMO 28 | % 4: FD-SC (small cell) 29 | % 5: HD-DM-MIMO 30 | % 6: HD-CM-MIMO 31 | % 7: HD-SC (small cell) 32 | % 8: FD-DM-MIMO + MRT/MRC full power factors 33 | 34 | 35 | DLULSchemes = 2; % 1: DPC/ZF-SIC 36 | % 2: ZF/ZF 37 | % 3: MRT/MRC 38 | 39 | Methodname = {'FD_DM_MIMO', 'FD_DM_MIMO_PCA', 'FD_CM_MIMO', 'CRP_PF', 'Con_FD', 'FD_noNOMA', 'HD', 'OMA'}; 40 | 41 | % global MaxIteration 42 | % MaxIteration = 50; 43 | 44 | filename = ['Convergence_' Methodname{Method} '_DLULSchemes' num2str(DLULSchemes) '_' num2str(NumOfSim) '.mat']; 45 | 46 | loadingfile = ['Layout8.mat'];%[];% 47 | recalcD = 0; 48 | RenewChannel = 0; 49 | 50 | savedname = fullfile(pathname, filename); 51 | 52 | 53 | %% Set Parameters 54 | 55 | ParameterSetting 56 | 57 | % if (Method==3 || Method==6) 58 | % Pbs = Pbs*M; 59 | % Nm = M*Nm; 60 | % M = 1; 61 | % end 62 | 63 | %% Build Channel Model 64 | 65 | PathlossShadowingModel 66 | 67 | % APs_DLs = ones(M,K); 68 | % APs_ULs = ones(M,L); 69 | % if (Method==4 || Method==7) 70 | % APs_DLs = zeros(M,K); 71 | % AP_NoDLs = zeros(M,1); 72 | % for k = 1:1:K 73 | % DLPos_k = repmat(positionDLUs(k,:),M,1); 74 | % Dist_k = sqrt(sum((DLPos_k-positionAPs).^2,2)+10^12*(AP_NoDLs>=Nm)); 75 | % [~, AP_selected] = min(Dist_k); 76 | % APs_DLs(AP_selected,k) = 1; 77 | % AP_NoDLs(AP_selected) = AP_NoDLs(AP_selected) + 1; 78 | % end 79 | % % AP_NoDLs' 80 | % % sum(AP_NoDLs) 81 | % % sum(APs_DLs) 82 | % % D_A2D = D_A2D.*APs_DLs; 83 | % 84 | % APs_ULs = zeros(M,L); 85 | % AP_NoULs = zeros(M,1); 86 | % for l = 1:1:L 87 | % ULPos_l = repmat(positionULUs(l,:),M,1); 88 | % Dist_l = sqrt(sum((ULPos_l-positionAPs).^2,2)+10^12*(AP_NoULs>=Nm)); 89 | % [~, AP_selected] = min(Dist_l); 90 | % APs_ULs(AP_selected,l) = 1; 91 | % AP_NoULs(AP_selected) = AP_NoULs(AP_selected) + 1; 92 | % end 93 | % % AP_NoULs' 94 | % % sum(AP_NoULs) 95 | % % sum(APs_ULs) 96 | % % D_A2U = D_A2U.*APs_ULs; 97 | % end 98 | 99 | % error('Layout is done !!!'); 100 | 101 | for iSim = 1:1:NumOfSim 102 | if (RenewChannel) 103 | ChannelModel 104 | else 105 | load(loadingfile,'H_DL'); 106 | load(loadingfile,'H_UL'); 107 | load(loadingfile,'G_AA_All'); 108 | load(loadingfile,'G_CCI'); 109 | end 110 | Channels{iSim,1} = {H_DL, H_UL, G_AA_All, G_CCI}; 111 | end 112 | 113 | % error('Layout is done !!!'); 114 | 115 | %% Run Algorithms 116 | 117 | 118 | 119 | 120 | % h = waitbar(0, [ str_Group ': ' num2str(floor(0*100 / NumberOfRunning)) ' % Completed'],'Name','Percent of completion'); 121 | % h = waitbar(0, 'Please wait ...','Name','Percent of completion'); 122 | 123 | % Clus = parcluster('local'); 124 | % Clus.NumWorkers = 4; 125 | 126 | % poolobj = parpool(Clus, Clus.NumWorkers); 127 | 128 | figure; 129 | 130 | Chain = cell(NumOfSim,1); 131 | 132 | Blkrho = []; 133 | for m = 1:1:M 134 | Mat_rho = sqrt(rho)*ones(Nm, Nm)-1; 135 | Blkrho = blkdiag(Blkrho, Mat_rho); 136 | end 137 | Blkrho = Blkrho + 1; 138 | 139 | % error('Layout is done !!!'); 140 | 141 | OptValue_All = zeros(NumOfSim,1); 142 | OptSolution_All = cell(NumOfSim,1); 143 | OptValueChain_All = cell(NumOfSim,1); 144 | DLRate_PerUser_All = cell(NumOfSim,1); 145 | ULRate_PerUser_All = cell(NumOfSim,1); 146 | 147 | iSim = 0; 148 | while (iSim=1); 309 | Layout = Plot_Layout(RadiusOfRegion, {positionDLUs, positionULUs, positionAPs(SleepID,:) [positionAPs(ACtiveID,:), RateDis(ACtiveID)'] }, ... 310 | {'rs', 'bo', 'k^', 'rx'}, {'DLU', 'ULU', 'Sleep AP', 'Active AP'}, ... 311 | {{'none'}, {'none'}, {'none'}, ... 312 | {'ColorBar', [1 max(RateDis)], ... 313 | {'Weak Active', 'Strong Active'} } } ) 314 | 315 | figure 316 | ModeIdx = sum(OptSolution{1,13}{1,1}) - sum(OptSolution{1,13}{1,2}); 317 | ModeDis = ModeIdx(find(OptSolution{1,5}>0)); 318 | Layout = Plot_Layout(RadiusOfRegion, {positionAPs, positionDLUs, positionULUs, [positionAPs(find(OptSolution{1,5}>0),:), ModeDis'] }, ... 319 | {'k^', 'rs', 'bo', 'rx'}, {'Sleep AP', 'DLU', 'ULU', 'HD/FD Mode'}, ... 320 | {{'none'}, {'none'}, {'none'}, ... 321 | {'ColorBar', [min(ModeDis), 0.5*(min(ModeDis) + max(ModeDis)), max(ModeDis)], ... 322 | {'UL', 'FD', 'DL'} } } ) 323 | 324 | end 325 | 326 | % delete(poolobj); 327 | 328 | % clear Clus 329 | 330 | % close(h); 331 | 332 | save(savedname); 333 | 334 | 335 | %% 336 | 337 | time = toc 338 | hour = 0; min=0; 339 | if (time>3600) 340 | hour = floor(time/3600); 341 | time = mod(time,3600); 342 | end 343 | if (time>60) 344 | min = floor(time/60); 345 | time = mod(time,60); 346 | end 347 | disp(['Running Time = ' num2str(hour) ' h ' num2str(min) ' m ' num2str(time) ' s.' ]); -------------------------------------------------------------------------------- /Get_optSolutionPerIteration.m: -------------------------------------------------------------------------------- 1 | function [ OptimalValue, DLRate_PerUser_next, ULRate_PerUser_next, Solution_next, Status, PowScale ] = Get_optSolutionPerIteration( AllParameters, Solution_current, Iter, Init, prePowScale ) 2 | %GET_OPTSOLUTIONPERITERATION Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | penpar = 10^2; 6 | Iter = Iter + 1; 7 | 8 | pThres = 10^(-3); 9 | 10 | M = AllParameters{1}; 11 | K = AllParameters{2}; 12 | L = AllParameters{3}; 13 | Nm = AllParameters{4}; 14 | sigma = AllParameters{5}; 15 | H_d = AllParameters{6}; 16 | H_u = AllParameters{7}; 17 | G_SI = AllParameters{8}; 18 | G_CCI = AllParameters{9}; 19 | nu = AllParameters{10}; 20 | P_AP = AllParameters{11}; 21 | P_UL = AllParameters{12}; 22 | Pd = AllParameters{13}; 23 | Pu = AllParameters{14}; 24 | eta = AllParameters{15}; 25 | C_SE = AllParameters{16}; 26 | C_EE = AllParameters{17}; 27 | if (length(AllParameters{18})==1) 28 | DLRate_Threshold = AllParameters{18}; 29 | ULRate_Threshold = AllParameters{18}; 30 | else 31 | DLRate_Threshold = AllParameters{18}(1); 32 | ULRate_Threshold = AllParameters{18}(2); 33 | end 34 | Pa = AllParameters{19}(1); 35 | PcirAP = AllParameters{19}(2); 36 | PcirUE = AllParameters{19}(3); 37 | Ps = AllParameters{20}; 38 | Pbh = AllParameters{21}; 39 | DLULSchemes = AllParameters{22}; 40 | 41 | if (length(AllParameters)<23) 42 | Err_H_DL = zeros(M,K); 43 | Err_H_UL = zeros(M,L); 44 | Err_GCCI = zeros(K,L); 45 | else 46 | Err_H_DL = AllParameters{23}{1,1}; 47 | Err_H_UL = AllParameters{23}{1,2}; 48 | Err_GCCI = AllParameters{23}{1,3}; 49 | end 50 | 51 | if (norm(G_SI)<10^(-20) && norm(G_CCI)<10^(-20)) 52 | HD = 1; 53 | else 54 | HD = 0; 55 | end 56 | 57 | % P_AP 58 | Init; 59 | 60 | epspow = 10^(-2)*(P_AP/nu(1)+Pd); % *3^(-Iter)+Pu+Pa-Ps 61 | epspowDL = epspow; %10^(-3)*(P_AP) 62 | epspowUL = 10^(-2)*P_UL(1); 63 | 64 | if (prePowScale.keepSolution) 65 | epspow = epspow; %* 2^(prePowScale.epsScale); 66 | end 67 | 68 | epspow; 69 | 70 | DLMask = Solution_current{1}; 71 | ULMask = Solution_current{2}; 72 | omega_current = Solution_current{3}; 73 | p_current = Solution_current{4}; 74 | mu_current = Solution_current{5}; 75 | lambda_d_current = Solution_current{6}; 76 | lambda_u_current = Solution_current{7}; 77 | psi_d_current = Solution_current{8}; 78 | psi_u_current = Solution_current{9}; 79 | xi_current = Solution_current{10}; 80 | phi_current = Solution_current{11}{1}; 81 | phi_bar_current = Solution_current{11}{2}; 82 | chi_current = Solution_current{12}; 83 | DLSel_current = Solution_current{13}{1}; 84 | ULSel_current = Solution_current{13}{2}; 85 | 86 | 87 | omega_next = sdpvar(1, K, 'full','real'); 88 | p_next = sdpvar(1, L, 'full','real'); 89 | % mu_next = ones(1,M);%sdpvar(1, M, 'full','real');% 90 | lambda_d_next = sdpvar(1, K, 'full','real'); 91 | lambda_u_next = sdpvar(1, L, 'full','real'); 92 | psi_d_next = sdpvar(1, K, 'full','real'); 93 | psi_u_next = sdpvar(1, L, 'full','real'); 94 | xi_next = sdpvar(1, M, 'full','real'); 95 | phi_next = sdpvar(1, 1, 'full','real'); 96 | chi_next = sdpvar(1, 1, 'full','real'); 97 | 98 | W_current = DLMask*diag(omega_current.^(0.5)); 99 | DLPowPercent = zeros(K,M); 100 | 101 | A = H_u*diag(p_current.^(0.5)); 102 | ULPowPercent = zeros(L,M); 103 | 104 | for m = 1:1:M 105 | 106 | for k = 1:1:K 107 | Wmk = H_d(k,(m-1)*Nm+1:m*Nm)*W_current((m-1)*Nm+1:m*Nm,k); 108 | DLPowPercent(k,m) = (norm(Wmk)^2)/(norm(H_d(k,:)*W_current(:,k))^2); 109 | end 110 | 111 | for l = 1:1:L 112 | Aml = ULMask(l,[(m-1)*Nm+1:m*Nm])*A([(m-1)*Nm+1:m*Nm],l); 113 | ULPowPercent(l,m) = (norm(Aml)^2)/(norm(ULMask(l,:)*A(:,l))^2);%trace(Am'*Am); 114 | end 115 | 116 | end 117 | 118 | maxMu = max([DLPowPercent' ULPowPercent'],[],2)'; 119 | 120 | if (~(HD && P_UL(1)<10^(-3))) 121 | DLMask = diag(kron(mu_current,ones(1,Nm)))*DLMask; 122 | end 123 | 124 | 125 | if (~(HD && P_AP<10^(-3))) 126 | ULMask = ULMask*diag(kron(mu_current,ones(1,Nm))); 127 | end 128 | 129 | 130 | % W_next = DLMask*diag(omega_next); 131 | % mu_estimate = zeros(1,M); 132 | % for m = 1:1:M 133 | % mu_estimate(m) = norm(vec(W_current([(m-1)*Nm+1:m*Nm],:)))^2/(norm(vec(W_current([(m-1)*Nm+1:m*Nm],:)))^2 + epspow); 134 | % % mu_estimate(m) = xi_current(m)/(xi_current(m)+epspow); 135 | % end 136 | 137 | cons = []; 138 | 139 | %% Cons. (14c) 140 | 141 | for l = 1:1:L 142 | cons = [cons, p_next(l)>=0]; 143 | cons = [cons, p_next(l)<=P_UL(l)]; 144 | end 145 | 146 | 147 | %% Cons. (22) (34e) 148 | 149 | % pen_mu = sdpvar(1, M, 'full','real'); 150 | for m = 1:1:M 151 | 152 | if (HD && P_AP<10^(-3)) 153 | continue 154 | end 155 | 156 | Sm = zeros(1,M*Nm); 157 | Sm( ((m-1)*Nm+1):(m*Nm) ) = ones(1,Nm); 158 | Sm = diag(Sm); 159 | % cons = [cons, trace(DLMask'*Sm*DLMask*diag(omega_next))<=mu_next(m)*P_AP]; 160 | % cons = [cons, sum(real(diag(DLMask'*Sm*DLMask))'.*omega_next)<=mu_next(m)*P_AP]; 161 | 162 | 163 | cons = [cons, sum(real(diag(DLMask'*Sm*DLMask))'.*omega_next)<=(mu_current(m)+10^(-5))*P_AP]; % mu_current(m)* 164 | % cons = [cons, sum(real(diag(DLMask'*Sm*DLMask))'.*omega_next)<=xi_current(m)/(xi_current(m)+epspow)*P_AP]; 165 | % cons = [cons, sum(real(diag(DLMask'*Sm*DLMask))'.*omega_next)<=mu_estimate(m)*P_AP]; 166 | 167 | % cons = [cons, mu_next(m)>=0]; 168 | % cons = [cons, mu_next(m)<=1]; 169 | 170 | % cons = [cons, pen_mu(m)<=0]; 171 | % cons = [cons, 2*mu_current(m)*mu_next(m)-mu_current(m)^2-mu_next(m)>=pen_mu(m)]; 172 | % cons = [cons, mu_next(m)>=mu_next(m)^2+pen_mu(m)]; 173 | end 174 | 175 | %% Cons. (40a) (41a) 176 | 177 | omega_bar = sdpvar(1, K, 'full','real'); 178 | for k = 1:1:K 179 | 180 | if (HD && P_AP<10^(-3)) 181 | cons = [cons, lambda_d_next(k) >=0]; 182 | cons = [cons, lambda_d_next(k) <=10^(-4)]; 183 | cons = [cons, omega_next(k) >=0]; 184 | continue 185 | end 186 | 187 | cons = [cons, psi_d_next(k) >= 1/(norm(H_d(k,:)*DLMask(:,k))^2)* ... 188 | ( sum( abs(H_d(k,:)*DLMask(:,[1:(k-1) (k+1):K])).^2.*omega_next([1:(k-1) (k+1):K])) + ... 189 | sum(abs(G_CCI(k,:)).^2.*p_next) + sigma^2 + ... 190 | sum( abs(kron((Err_H_DL(:,k)'/Nm).^(0.5),ones(1,Nm))*DLMask).^2.*omega_next) + ... 191 | sum(abs(Err_GCCI(k,:)).*p_next) )]; 192 | 193 | % cons = [cons, psi_d_next(k) >=0]; 194 | cons = [cons, omega_next(k) >=0]; 195 | % cons = [cons, rcone(omega_bar(k), omega_next(k), 1/2)]; 196 | cons = [cons, cone([omega_bar(k), 0.5*(omega_next(k)-1)], 0.5*(omega_next(k)+1) )]; 197 | cons = [cons, 2*sqrt(omega_current(k))/psi_d_current(k)*omega_bar(k)-omega_current(k)/(psi_d_current(k)^2)*psi_d_next(k)>=lambda_d_next(k)]; 198 | cons = [cons, omega_bar(k)>=0]; 199 | cons = [cons, lambda_d_next(k) >=0]; 200 | 201 | 202 | cons = [cons, 2*sqrt(omega_current(k))/psi_d_current(k)*omega_bar(k)-omega_current(k)/(psi_d_current(k)^2)*psi_d_next(k)>=0]; 203 | end 204 | 205 | 206 | %% Cons. (40b) (41b) 207 | 208 | p_bar = sdpvar(1, L, 'full','real'); 209 | ULMask_temp = ULMask; 210 | for l = 1:1:L 211 | 212 | if (HD && P_UL(l)<10^(-3)) 213 | cons = [cons, lambda_u_next(l) >=0]; 214 | cons = [cons, lambda_u_next(l) <=10^(-4)]; 215 | cons = [cons, psi_u_next(l)>=0]; 216 | continue 217 | end 218 | 219 | % if (~(HD && P_AP<10^(-3))) 220 | % % ULMask = ULMask*diag(kron(xi_current./(xi_current+epspow).*mu_current,ones(1,Nm))); 221 | % ULMask = ULMask*diag(kron(mu_current,ones(1,Nm))); 222 | % end 223 | 224 | if (DLULSchemes==1) 225 | 226 | if (l==L) 227 | cons = [cons, psi_u_next(l) >= 1/(norm(ULMask(l,:)*H_u(:,l))^2)* ... 228 | ( sum( abs(ULMask(l,:)*G_SI*DLMask).^2.*omega_next) + sigma^2*norm(ULMask(l,:))^2 + ... 229 | sum( abs(ULMask(l,:)*kron((Err_H_UL/Nm).^(0.5),ones(Nm,1))).^2.*p_next) )]; 230 | else 231 | 232 | % GSIDLMask = norm(G_SI*DLMask); 233 | % UMaskHu_SI = abs(ULMask(l,:)*G_SI*DLMask).^2; 234 | % UMaskHu_noise = sigma^2*norm(ULMask(l,:))^2; 235 | cons = [cons, psi_u_next(l) >= 1/(norm(ULMask(l,:)*H_u(:,l))^2)* ... 236 | ( sum( abs( ULMask(l,:)*H_u(:,(l+1):L) ).^2.*p_next((l+1):L) ) + ... 237 | sum( abs(ULMask(l,:)*G_SI*DLMask).^2.*omega_next) + sigma^2*norm(ULMask(l,:))^2 + ... 238 | sum( abs(ULMask(l,:)*kron((Err_H_UL/Nm).^(0.5),ones(Nm,1))).^2.*p_next) )]; 239 | end 240 | else 241 | cons = [cons, psi_u_next(l) >= 1/(norm(ULMask(l,:)*H_u(:,l))^2)* ... 242 | ( sum( abs( ULMask(l,:)*H_u(:,[1:(l-1) (l+1):L]) ).^2.*p_next([1:(l-1) (l+1):L]) ) + ... 243 | sum( abs(ULMask(l,:)*G_SI*DLMask).^2.*omega_next) + sigma^2*norm(ULMask(l,:))^2 + ... 244 | sum( abs(ULMask(l,:)*kron((Err_H_UL/Nm).^(0.5),ones(Nm,1))).^2.*p_next) )]; 245 | end 246 | 247 | % cons = [cons, psi_u_next(l)>=0]; 248 | 249 | % cons = [cons, rcone(p_bar(l), p_next(l), 1/2)]; 250 | cons = [cons, cone([p_bar(l), 0.5*(p_next(l)-1)], 0.5*(p_next(l)+1) )]; 251 | cons = [cons, 2*sqrt(p_current(l))/psi_u_current(l)*p_bar(l)-p_current(l)/(psi_u_current(l)^2)*psi_u_next(l)>=lambda_u_next(l)]; 252 | cons = [cons, p_bar(l)>=0]; 253 | cons = [cons, lambda_u_next(l)>=0]; 254 | 255 | 256 | 257 | end 258 | 259 | ULMask = ULMask_temp; 260 | %% Cons. (45) 261 | 262 | 263 | 264 | Coeff = zeros(K,M); 265 | CoeffUL = zeros(L,M); 266 | DLEff = sdpvar(1, M, 'full','real'); 267 | ULEff = sdpvar(1, M, 'full','real'); 268 | DLEffPow_sum = sdpvar(1, M, 'full','real'); 269 | ULEffPow_sum = sdpvar(1, M, 'full','real'); 270 | DLEffPow_next = sdpvar(1, M, 'full','real'); 271 | ULEffPow_next = sdpvar(1, M, 'full','real'); 272 | 273 | DLrateperAP = zeros(K,M); 274 | ULrateperAP = zeros(L,M); 275 | for m = 1:1:M 276 | 277 | if (HD && P_AP<10^(-3)) 278 | continue 279 | end 280 | % Coeff{m} = zeros(1, K); 281 | maxNorm = 0; 282 | for k = 1:1:K 283 | % Coeff(k,m) = 1/nu + Pd/(norm(W_current([(m-1)*Nm+1:m*Nm],k))^2 + epspowDL); 284 | % Coeff(k,m) = Coeff(k,m)*norm(DLMask([(m-1)*Nm+1:m*Nm],k))^2; 285 | 286 | % maxNorm = max(norm(W_current([(m-1)*Nm+1:m*Nm],k))^2,maxNorm); 287 | DLrateperAP(k,m) = norm(H_d(k,:)*W_current(:,k))^2; 288 | Coeff(k,m) = norm(H_d(k,[(m-1)*Nm+1:m*Nm])*DLMask([(m-1)*Nm+1:m*Nm],k))^2; 289 | end 290 | 291 | for k = 1:1:K 292 | % Coeff(k,m) = Coeff(k,m)*(1/nu + Pd/(maxNorm + epspowDL)); 293 | % Coeff(k,m) = Coeff(k,m)*(1/nu(1) + Pd/(DLrateperAP(k,m) + 0.01/M)); 294 | Coeff(k,m) = Coeff(k,m)*(Pd/(DLrateperAP(k,m) + 0.01/M)) + 1/nu(1)*norm(DLMask([(m-1)*Nm+1:m*Nm],k))^2; 295 | end 296 | 297 | 298 | 299 | % if (~Init) 300 | % % cons = [cons, real(sum(Coeff{m}.*omega_current))<=xi_next(m)]; 301 | % 302 | % cons = [cons, real(sum(Coeff(:,m)'.*omega_next))<=xi_next(m)+10^(-3)]; 303 | % cons = [cons, real(sum(Coeff(:,m)'.*omega_next))>=xi_next(m)-10^(-3)]; 304 | % 305 | % 306 | % DLEffPow_sum(m) = real(sum(Coeff(:,m)'.*omega_next)); 307 | % 308 | % ULEffPow_sum(m) = sum(p_next.*real(diag(ULMask(:,[(m-1)*Nm+1:m*Nm])*H_u([(m-1)*Nm+1:m*Nm],:))'.^2)); 309 | % 310 | % 311 | % DLEff(m) = DLEffPow_sum(m)/real(sum(Coeff(:,m)'.*omega_current)+epspow); 312 | % ULEff(m) = ULEffPow_sum(m)/(sum(p_current.*real(diag(ULMask(:,[(m-1)*Nm+1:m*Nm])*H_u([(m-1)*Nm+1:m*Nm],:))'.^2))+epspowUL); 313 | % 314 | % 315 | % else 316 | % xi_next(m)=real(sum(Coeff(:,m)'.*omega_current)); 317 | xi_next(m)=real(sum(Coeff(:,m)'.*omega_next)); 318 | 319 | % end 320 | 321 | % cons = [cons, xi_next(m)<=P_AP/nu+Pd]; 322 | maxNormUL = 0; 323 | for l = 1:1:L 324 | % maxNormUL = max(norm(ULMask(l,[(m-1)*Nm+1:m*Nm])*H_u([(m-1)*Nm+1:m*Nm],l))^2,maxNormUL); 325 | ULrateperAP(l,m) = norm(ULMask(l,:)*H_u(:,l))^2*p_current(l); 326 | CoeffUL(l,m) = norm(ULMask(l,[(m-1)*Nm+1:m*Nm])*H_u([(m-1)*Nm+1:m*Nm],l))^2; 327 | end 328 | 329 | for l = 1:1:L 330 | % CoeffUL(l,m) = CoeffUL(l,m)*(Pu/(maxNormUL + epspowUL)); 331 | CoeffUL(l,m) = CoeffUL(l,m)*(Pu/(ULrateperAP(l,m) + 0.01/M)); 332 | end 333 | end 334 | 335 | 336 | %% Cons. (46) 337 | if (eta==0) 338 | if (~(HD && P_AP<10^(-3))) 339 | 340 | DLThput = sdpvar(1, K, 'full','real'); 341 | ULThput = sdpvar(1, L, 'full','real'); 342 | 343 | DLappx = log(1+lambda_d_current) - lambda_d_current./(1+lambda_d_current); 344 | for k = 1:1:K 345 | DLThput(k) = real(DLappx(k) + lambda_d_next(k)/(1+lambda_d_current(k))); 346 | % cons = [cons, DLappx(k) + lambda_d_next(k)/(1+lambda_d_current(k)) <= DLThput(k) ]; 347 | % cons = [cons, DLThput(k) >= 0]; 348 | end 349 | 350 | ULappx = log(1+lambda_u_current) - lambda_u_current./(1+lambda_u_current); 351 | for l = 1:1:L 352 | ULThput(l) = real(ULappx(l) + lambda_u_next(l)/(1+lambda_u_current(l))); 353 | % cons = [cons, ULappx(l) + lambda_u_next(l)/(1+lambda_u_current(l)) <= ULThput(l) ]; 354 | % cons = [cons, ULThput(l)>=0]; 355 | end 356 | 357 | SumThput = sum(DLThput) + sum(ULThput); 358 | 359 | if (~Init) 360 | 361 | 362 | % cons = [cons, sum(xi_next.^2./(xi_current+epspow).*mu_current) + sum(p_next) + ... 363 | % sum(xi_next./(xi_current+epspow).*mu_current*(Pa+Pu)) + sum((1-xi_next./(xi_current+epspow).*mu_current)*Ps) <= chi_next]; 364 | 365 | % cons = [cons, sum(real(Coeff(:,m)'*omega_next').*mu_current') + sum(p_next) + ... 366 | % sum(real(Coeff(:,m)'*omega_next').*mu_current'*(Pa+Pu)) + sum((1-real(Coeff(:,m)'*omega_next').*mu_current')*Ps) + SumThput*Pbh <= chi_next]; 367 | 368 | % real(Coeff(:,m)'*omega_next') 369 | 370 | % cons = [cons, sum(real(Coeff'*omega_next').*mu_current') + sum(p_next) + sum(real(CoeffUL'*p_next').*mu_current') + ... 371 | % sum(0.5*real(Coeff'*omega_next'+CoeffUL'*p_next').*mu_current'*Pa) + ... 372 | % sum((1-0.5*real(Coeff'*omega_next'+CoeffUL'*p_next').*mu_current')*Ps) + SumThput*Pbh <= chi_next]; 373 | 374 | % cons = [cons, sum(max([DLPowPercent' ULPowPercent'],[],2).*real(Coeff'*omega_next').*mu_current') + ... 375 | % sum(p_next/nu(2)) + sum(max([DLPowPercent' ULPowPercent'],[],2).*real(CoeffUL'*p_next').*mu_current') + ... 376 | % sum(max([DLPowPercent' ULPowPercent'],[],2).*mu_current'*Pa) + ... 377 | % sum((1-max([DLPowPercent' ULPowPercent'],[],2).*mu_current')*Ps) + SumThput*Pbh/log(2) + ... 378 | % M*PcirAP + (K+L)*PcirUE <= chi_next]; 379 | 380 | cons = [cons, sum(max([DLPowPercent' ULPowPercent'],[],2).*real(Coeff'*omega_next').*mu_current') + ... 381 | sum(p_next/nu(2)) + sum(max([DLPowPercent' ULPowPercent'],[],2).*mu_current'*Pu) + ... 382 | sum(max([DLPowPercent' ULPowPercent'],[],2).*mu_current'*Pa) + ... 383 | sum((1-max([DLPowPercent' ULPowPercent'],[],2).*mu_current')*Ps) + SumThput*Pbh/log(2) + ... 384 | M*PcirAP + (K+L)*PcirUE <= chi_next]; 385 | 386 | cons = [cons, chi_next>=0]; 387 | 388 | % cons = [cons, chi_next<= 10^(10)*(M*P_AP + M*K*Pd + sum(P_UL) + M*Pu + M*Pa + M*Ps)]; 389 | 390 | else 391 | 392 | 393 | % chi_next = sum(xi_next.^2./(xi_current+epspow).*mu_current) + sum(p_next) + ... 394 | % sum(xi_next./(xi_current+epspow).*mu_current*(Pa+Pu)) + sum((1-xi_next./(xi_current+epspow).*mu_current)*Ps); 395 | 396 | % chi_next = sum(real(Coeff'*omega_next').*mu_current') + sum(p_next) + ... 397 | % sum(real(Coeff'*omega_next').*mu_current'*(Pa+Pu)) + sum((1-real(Coeff'*omega_next').*mu_current')*Ps) + SumThput*Pbh; 398 | 399 | chi_next = sum(max([DLPowPercent' ULPowPercent'],[],2).*real(Coeff'*omega_next').*mu_current') + ... 400 | sum(p_next/nu(2)) + sum(max([DLPowPercent' ULPowPercent'],[],2).*real(CoeffUL'*p_next').*mu_current') + ... 401 | sum(max([DLPowPercent' ULPowPercent'],[],2).*mu_current'*Pa) + ... 402 | sum((1-max([DLPowPercent' ULPowPercent'],[],2).*mu_current')*Ps) + SumThput*Pbh/log(2) + M*PcirAP + (K+L)*PcirUE; 403 | 404 | end 405 | 406 | 407 | 408 | end 409 | end 410 | 411 | % cons = [cons, chi_next<= M*P_AP + M*K*Pd + sum(P_UL) + M*Pu + M*Pa + M*Ps]; 412 | 413 | %% Cons. (48) 414 | 415 | 416 | phi_bar = sdpvar(1, 1, 'full','real'); 417 | % cons = [cons, cone([1, 0.5*(phi_next-phi_bar)],0.5*(phi_next+phi_bar))]; 418 | % cons = [cons, eta*C_SE + (1-eta)*C_EE*(2/chi_current-chi_next/(chi_current^2))>=phi_bar]; 419 | % cons = [cons, phi_next>=0]; 420 | % cons = [cons, phi_bar>=0]; 421 | if (~(HD && P_AP<10^(-3))) 422 | if (eta==1) 423 | phi_next = 1; 424 | else 425 | if (~Init) 426 | % chi1 = eta*C_SE*chi_next + (1-eta)*C_EE; 427 | % 428 | % cons = [cons, chi_next-10^(-5) <= 2*phi_bar*phi_bar_current-phi_bar_current^2]; 429 | % cons = [cons, cone([phi_bar, 0.5*(chi1-phi_next)],0.5*(chi1+phi_next))]; 430 | % % cons = [cons, cone([sqrt(chi_current/(2*phi_bar_current))*phi_bar, sqrt(phi_bar_current/(2*chi_current))*chi_next, 0.5*(phi_next-1)], ... 431 | % % 0.5*(phi_next+1)) ]; 432 | % 433 | % cons = [cons, chi1>=0]; 434 | % cons = [cons, phi_bar>=0]; 435 | cons = [cons, phi_next>=0]; 436 | cons = [cons, chi_next<=phi_next]; 437 | else 438 | % chi1 = eta*C_SE*chi_next + (1-eta)*C_EE; 439 | % phi_bar = sqrt(real(chi_next)); 440 | % phi_next = phi_bar^2/chi1; 441 | phi_next=chi_next; 442 | end 443 | end 444 | end 445 | 446 | %% Cons. (50) 447 | % Rate_Threshold = 0; 448 | pen_d = sdpvar(1, K, 'full','real'); 449 | % varrho = sdpvar(1, 1, 'full','real'); 450 | for k = 1:1:K 451 | % if (HD && P_AP<10^(-3)) 452 | % pen_d(k)=0; 453 | % continue 454 | % end 455 | % cons = [cons, lambda_d_next(k)-exp(Rate_Threshold)+1>=0 ]; 456 | 457 | % cons = [cons, lambda_d_next(k)>=varrho ]; 458 | % cons = [cons, (eta*C_SE + (1-eta)*C_EE)*(lambda_d_next(k)-exp(Rate_Threshold)+1)>=pen_d(k) ]; 459 | 460 | cons = [cons, (lambda_d_next(k)-exp(DLRate_Threshold)+1)>=pen_d(k) ]; 461 | cons = [cons, pen_d(k)<=0]; 462 | end 463 | 464 | pen_u = sdpvar(1, L, 'full','real'); 465 | for l = 1:1:L 466 | % if (HD && P_UL(l)<10^(-3)) 467 | % pen_u(l)=0; 468 | % continue 469 | % end 470 | % cons = [cons, lambda_u_next(l)-exp(Rate_Threshold)+1>=0 ]; 471 | 472 | % cons = [cons, lambda_u_next(l)>= varrho]; 473 | 474 | % cons = [cons, (eta*C_SE + (1-eta)*C_EE)*(lambda_u_next(l)-exp(Rate_Threshold)+1)>= pen_u(l)]; 475 | cons = [cons, (lambda_u_next(l)-exp(ULRate_Threshold)+1)>= pen_u(l)]; 476 | cons = [cons, pen_u(l)<=0]; 477 | end 478 | 479 | 480 | %% Objective func. 481 | t_current = real((log(det( eye(K)+diag(lambda_d_current) )) + log(det( eye(L)+diag(lambda_u_current) )))/phi_current); 482 | 483 | % obj = 0; 484 | 485 | if (~Init) 486 | if (HD && P_AP<10^(-3)) 487 | obj = logdet( eye(L)+diag(real(lambda_u_next)) ); 488 | elseif (HD && P_UL(1)<10^(-3)) 489 | obj = logdet( eye(K)+diag(real(lambda_d_next)) ); 490 | else 491 | obj = logdet( eye(K)+diag(real(lambda_d_next)) ) + logdet( eye(L)+diag(real(lambda_u_next)) ) - t_current*real(phi_next); 492 | end 493 | 494 | obj = obj + penpar^(Iter)*(sum(pen_d) + sum(pen_u) );% + 2^(Iter)*sum(pen_mu); 495 | 496 | % obj = logdet( diag(real(lambda_d_next)) );% + logdet( eye(L)+diag(real(lambda_u_next)) ) - t_current*real(phi_next); 497 | % cons = [cons, logdet( eye(K)+diag(real(lambda_d_next)) ) + logdet( eye(L)+diag(real(lambda_u_next)) ) - t_current*real(phi_next)>=0]; 498 | else 499 | % if (HD && P_AP<10^(-3)) 500 | % obj = 100*penpar*(sum(pen_u));% + 2^(Iter)*sum(pen_mu); 501 | % elseif (HD && P_UL(1)<10^(-3)) 502 | % obj = 100*penpar*(sum(pen_d));% + 2^(Iter)*sum(pen_mu); 503 | % else 504 | obj = 100*penpar*(sum(pen_d) + sum(pen_u));% + 2^(Iter)*sum(pen_mu); 505 | % end 506 | end 507 | 508 | 509 | 510 | %% Optimization 511 | 512 | % cons = [cons, varrho>=10^(-5)]; 513 | % myops = sdpsettings('solver','mosek'); 514 | myops = sdpsettings('solver','sdpt3','verbose',0); 515 | % myops = sdpsettings('solver','sedumi','verbose',0); 516 | 517 | diagnotics = solvesdp(cons, -obj, myops); 518 | % diagnotics = solvesdp(cons, -varrho, myops) 519 | 520 | % diagnotics = solvesdp(cons, -(varrho+Sum_alpha+Sum_beta), myops) 521 | 522 | 523 | %% Output 524 | Status.convergence = 0; 525 | % mu_next = ones(1,M);%double(xi_next)./(xi_current+10^(-5)) 526 | 527 | obj = double(obj); 528 | % obj = double(varrho); 529 | DLRate_PerUser_next = log( ones(1,K)+double(lambda_d_next)); 530 | DLRate_Sum = log(det( eye(K)+diag(double(lambda_d_next)) )); 531 | 532 | ULRate_PerUser_next = log( ones(1,L)+double(lambda_u_next)); 533 | ULRate_Sum = log(det( eye(L)+diag(double(lambda_u_next)) )); 534 | 535 | if (HD) 536 | OptimalValue = DLRate_Sum+ULRate_Sum; 537 | else 538 | OptimalValue = (DLRate_Sum+ULRate_Sum)/double(phi_next); %(eta + (1-eta)*10^4)* 539 | end 540 | omega = double(omega_next); 541 | p = double(p_next); 542 | 543 | W = DLMask*diag(omega.^(0.5)); 544 | WW = zeros(1,M); 545 | DLPowPercent = zeros(K,M); 546 | 547 | A = H_u*diag(p.^(0.5)); 548 | ULPowPercent = zeros(L,M); 549 | 550 | for m = 1:1:M 551 | Wm = W((m-1)*Nm+1:m*Nm,:); 552 | WW(m) = trace(Wm'*Wm); 553 | for k = 1:1:K 554 | Wmk = H_d(k,(m-1)*Nm+1:m*Nm)*W((m-1)*Nm+1:m*Nm,k); 555 | DLPowPercent(k,m) = 100*(norm(Wmk)^2)/(norm(H_d(k,:)*W(:,k))^2); 556 | end 557 | 558 | for l = 1:1:L 559 | Aml = ULMask(l,[(m-1)*Nm+1:m*Nm])*A([(m-1)*Nm+1:m*Nm],l); 560 | ULPowPercent(l,m) = 100*(norm(Aml)^2)/(norm(ULMask(l,:)*A(:,l))^2);%trace(Am'*Am); 561 | end 562 | 563 | end 564 | WW; 565 | DLPowPercent; 566 | ULPowPercent; 567 | DL = norm(H_d(k,:)*W(:,k))^2; 568 | UL = norm(ULMask(l,:)*A(:,l))^2; 569 | DLrateperAP; 570 | ULrateperAP; 571 | 572 | 573 | % mu_estimate 574 | 575 | % mu = max([double(DLEff); double(ULEff)],[],1) %double(mu_next) 576 | 577 | %Print 578 | lambda_d = double(lambda_d_next); 579 | lambda_u = double(lambda_u_next); 580 | pen_d = double(pen_d); 581 | pen_u = double(pen_u); 582 | psi_d = double(psi_d_next); 583 | psi_u = double(psi_u_next); 584 | %EndPrint 585 | 586 | MaxMu = max([Coeff'*diag(omega), CoeffUL'*diag(p)],[],2)'; 587 | Coeff; 588 | CoeffUL; 589 | 590 | % sum_u = zeros(1,L); 591 | % for l = 1:1:L 592 | % sum_u(l) = 1/(norm(ULMask(l,:)*H_u(:,l))^2)* ... 593 | % ( sum( abs( ULMask(l,:)*H_u(:,(l+1):L) ).^2.*double(p_next((l+1):L)) ) + ... 594 | % sum( abs(ULMask(l,:)*G_SI*DLMask).^2.*double(omega_next)) + sigma^2*norm(ULMask(l,:))^2 ); 595 | % end 596 | % sum_u 597 | % pen_mu = double(pen_mu) 598 | if (~Init) 599 | 600 | % [mu, id] = max(double([DLEff; ULEff]),[],1) 601 | % mu = double(xi_next)./(double(xi_next) + epspow)%mu_current + Step_mu.*Delta_mu 602 | % ActiveAP = max(double([DLEff; ULEff]),[],1) 603 | xi= double(xi_next); 604 | % sum_xi = sum(diag(double(omega_next)*Coeff)) 605 | % Coeff 606 | phi = double(phi_next); 607 | phi_bar = double(phi_bar); 608 | chi = double(chi_next); 609 | obj1 = log(det( eye(K)+diag(double(lambda_d_next)) )) + log(det( eye(L)+diag(double(lambda_u_next)) )) - t_current*double(phi_next); 610 | if (obj1<0 && eta<1) 611 | disp('====> computing selection variables | obj1<0'); 612 | PowScale.keepSolution = 1; 613 | PowScale.epsScale = prePowScale.epsScale + 1; 614 | % mu_next = double(xi_next)>epspow 615 | DLSel_next = [DLPowPercent>=pThres*100/M] + 10^(-5)*[DLPowPercent=pThres*100/M] + 10^(-5)*[ULPowPercent0.5) 619 | Status.convergence = 1; 620 | end 621 | PowScale.reset = 1; 622 | Solution_current{5} = mu_next; 623 | else 624 | PowScale.keepSolution = 0; 625 | PowScale.epsScale = prePowScale.epsScale; 626 | PowScale.reset = 0; 627 | mu_next = mu_current; 628 | DLSel_next = DLSel_current; 629 | ULSel_next = ULSel_current; 630 | end 631 | else 632 | mu_next = mu_current; 633 | DLSel_next = DLSel_current; 634 | ULSel_next = ULSel_current; 635 | PowScale.keepSolution = 0; 636 | PowScale.epsScale = 0; 637 | PowScale.reset = 0; 638 | end 639 | 640 | if (PowScale.keepSolution) 641 | Solution_next = Solution_current; 642 | else 643 | Solution_next = {DLMask, ULMask, double(omega_next), ... 644 | double(p_next), ... 645 | mu_next, ... %mu,... %double(mu_next), ... % 646 | double(lambda_d_next), ... 647 | double(lambda_u_next), ... 648 | double(psi_d_next), ... 649 | double(psi_u_next), ... 650 | double(xi_next), ... 651 | {double(phi_next), double(phi_bar) }, ... 652 | double(chi_next), ... 653 | {DLSel_next, ULSel_next}, ... 654 | abs(sum(pen_d)+sum(pen_u))}; 655 | 656 | end 657 | Status.info = diagnotics.info; 658 | 659 | 660 | end 661 | 662 | --------------------------------------------------------------------------------