├── costcalculator.m ├── ObjectiveFunction.m ├── README.md ├── PSO.m └── mainIoT.m /costcalculator.m: -------------------------------------------------------------------------------- 1 | function [ cost ] = costcalculator (u,n,x,idx) 2 | no_samples = length(x); 3 | dim = size(x,1); 4 | 5 | % create voronoi regions 6 | for cin = 1:n 7 | dum = find(idx==cin); 8 | voronoiSizes(cin) = length(dum); 9 | voronois(cin) = mat2cell(x(dum),dim,voronoiSizes(cin)); 10 | end 11 | 12 | % Calculate the corresponding cost 13 | costtemp = 0; 14 | for cin = 1:n 15 | costi = sum(sqrt((repmat(u(cin), 1, voronoiSizes(cin)) - cell2mat(voronois(cin))).^2)) 16 | costtemp = costi + costtemp; 17 | end 18 | cost = costtemp/no_samples; 19 | end 20 | -------------------------------------------------------------------------------- /ObjectiveFunction.m: -------------------------------------------------------------------------------- 1 | function [ cost ] = ObjectiveFunction ( u,n,r,x,h,delta,P,b,c ) 2 | no_samples = length(x); 3 | dim = size(x,1); 4 | for cin = 1:n 5 | csDists(:,cin) = sqrt(sum((repmat(u(:,cin), 1, no_samples) - x).^2, 1)); 6 | end 7 | % nearest neighbors of each sample 8 | [dist_to_nns, nnss] = min(csDists,[],2); 9 | if n==1 10 | nns=1; 11 | else 12 | nns=nnss; 13 | end 14 | 15 | % create voronoi regions 16 | for cin = 1:n 17 | dum = find(nns==cin); 18 | voronoiSizes(cin) = length(dum); 19 | voronois(cin) = mat2cell(x(:,dum),dim,voronoiSizes(cin)); 20 | end 21 | 22 | % Calculate the cost 23 | costtemp = 0; 24 | for cin = 1:n 25 | PLOS = 1./(1+c*exp(-b*(atan(h./sqrt(sum((repmat(u(:,cin), 1, voronoiSizes(cin)) - cell2mat(voronois(cin))).^2, 1)))-c))) ; 26 | costLOS = sum(log2(1+(P./(sum((repmat(u(:,cin), 1, voronoiSizes(cin)) - cell2mat(voronois(cin))).^2, 1)+h^2).^(r/2))).*PLOS); 27 | costNLOS = sum(log2(1+(P*delta./(sum((repmat(u(:,cin), 1, voronoiSizes(cin)) - cell2mat(voronois(cin))).^2, 1)+h^2).^(r/2))).*(1-PLOS)); 28 | costtemp = costLOS + costNLOS + costtemp; 29 | end 30 | cost = -costtemp/no_samples; 31 | end 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Optimal UAV Deployment for Rate Maximization in IoT Networks 2 | 3 | This is a code package related to the following article: 4 | 5 | Maryam Shabanighazikelayeh, and Erdem Koyuncu. "Optimal UAV Deployment for Rate Maximization in IoT Networks", Accepted in 2020 IEEE International Symposium on Personal, Indoor and Mobile Radio Communications. 6 | 7 | 8 | This repository contains the MATLAB code required to reproduces all the numerical results and figures in the article. 9 | 10 | ## Abstract of Article 11 | 12 | We consider multiple unmanned aerial vehicles (UAVs) at a common altitude serving as data collectors to a network of IoT devices. First, using a probabilistic line of sight channel model, the optimal assignment of IoT devices to the UAVs is determined. Next, for the asymptotic regimes of a large number of UAVs and/or large UAV altitudes, we propose closed-form analytical expressions for the optimal data rate and characterize the corresponding optimal UAV deployments. We also propose a simple iterative algorithm to find the optimal deployments with a small number of UAVs at high altitudes. Globally optimal numerical solutions to the general rate maximization problem are found using particle swarm optimization. 13 | 14 | ## Content of Code Package 15 | The package contains five MATLAB files, including a main file and four functions. 16 | 17 | ## Numerical Results 18 | 19 | ## Acknowledgement 20 | 21 | This work was supported in part by the **NSF Award CCF1814717**. 22 | 23 | -------------------------------------------------------------------------------- /PSO.m: -------------------------------------------------------------------------------- 1 | function [cost_opt,deploy_opt] = PSO(r,x,h,nVar,P,delta) 2 | % Initialize the model parameters 3 | b = 0.43; 4 | b11 = (1-delta)*b; 5 | c = 4.88; 6 | c11 = c*exp(-b*(pi/2-c)); 7 | c22 = .5*(b^2*(1-delta)+r*(c11-1)); 8 | 9 | ub = max(x)*ones(1,nVar); 10 | lb = min(x)*ones(1,nVar); 11 | 12 | fobj = @ObjectiveFunction; 13 | 14 | % Define the PSO's paramters 15 | noP = 10*nVar; 16 | maxIter =50+1*nVar; 17 | wMax = .9; 18 | wMin = .2; 19 | c1 = 1; 20 | c2 = 2; 21 | vMax = (ub - lb) .* .6; 22 | vMin = -vMax; 23 | 24 | 25 | % The PSO algorithm 26 | 27 | % Initialize the particles 28 | for k = 1 : noP 29 | Swarm.Particles(k).X = (ub-lb) .* rand(1,nVar) + lb; 30 | Swarm.Particles(k).V = zeros(1, nVar); 31 | Swarm.Particles(k).PBEST.X = zeros(1,nVar); 32 | Swarm.Particles(k).PBEST.O = inf; 33 | 34 | Swarm.GBEST.X = zeros(1,nVar); 35 | Swarm.GBEST.O = inf; 36 | end 37 | 38 | 39 | % Main loop 40 | for t = 1 : maxIter 41 | 42 | % Calcualte the objective value 43 | for k = 1 : noP 44 | currentX = Swarm.Particles(k).X; 45 | Swarm.Particles(k).O = fobj(currentX,nVar,r,x,h,delta,P,b,c); 46 | 47 | % Update the PBEST 48 | if Swarm.Particles(k).O < Swarm.Particles(k).PBEST.O 49 | Swarm.Particles(k).PBEST.X = currentX; 50 | Swarm.Particles(k).PBEST.O = Swarm.Particles(k).O; 51 | end 52 | 53 | % Update the GBEST 54 | if Swarm.Particles(k).O < Swarm.GBEST.O 55 | Swarm.GBEST.X = currentX; 56 | Swarm.GBEST.O = Swarm.Particles(k).O; 57 | end 58 | end 59 | 60 | % Update the X and V vectors 61 | w = wMax - t .* ((wMax - wMin) / maxIter); 62 | 63 | for k = 1 : noP 64 | Swarm.Particles(k).V = w .* Swarm.Particles(k).V + c1 .* rand(1,nVar) .* (Swarm.Particles(k).PBEST.X - Swarm.Particles(k).X) ... 65 | + c2 .* rand(1,nVar) .* (Swarm.GBEST.X - Swarm.Particles(k).X); 66 | 67 | 68 | % Check velocities 69 | index1 = find(Swarm.Particles(k).V > vMax); 70 | index2 = find(Swarm.Particles(k).V < vMin); 71 | 72 | Swarm.Particles(k).V(index1) = vMax(index1); 73 | Swarm.Particles(k).V(index2) = vMin(index2); 74 | 75 | Swarm.Particles(k).X = Swarm.Particles(k).X + Swarm.Particles(k).V; 76 | 77 | end 78 | 79 | outmsg = ['Iteration# ', num2str(t) , ' Swarm.GBEST.O = ' , num2str(Swarm.GBEST.O)]; 80 | disp(outmsg); 81 | 82 | cgCurve(t) = Swarm.GBEST.O; 83 | end 84 | 85 | cost_opt = -Swarm.GBEST.O 86 | deploy_opt = Swarm.GBEST.X 87 | semilogy(cgCurve); 88 | 89 | end 90 | -------------------------------------------------------------------------------- /mainIoT.m: -------------------------------------------------------------------------------- 1 | % one dimensional user distribution scenario 2 | clear all; 3 | close all; 4 | clc; 5 | 6 | 7 | d = 1; % User space dimension 8 | no_samples = 2000; 9 | r = 2; % Pathloss component 10 | P =10^(75/10); % Transmitter power in Watts 11 | delta = 0.9; % Attenuation factor 12 | h = 1000; % UAV Altitude 13 | radius = 1000; % Area radius 14 | % Rate parameters 15 | b = 0.43; 16 | b1 = (1-delta)*b; 17 | c = 4.88; 18 | c1 = c*exp(-b*(pi/2-c)); 19 | c2 = .5*(b^2*(1-delta)+r*(c1-1)); 20 | n = 1:20; 21 | x = radius*rand(d,no_samples); % user samples uniformly distributed in area of interest. 22 | deploy_opt_PSO = zeros(length(n),length(n)); % Initializing the optimal deployment of UAVs Derived with PSO method 23 | deploy_opt_asymp = zeros(length(n),length(n)); % Initializing the optimal deployment of UAVs Derived with our proposed asymptotic approach 24 | K=1; % Number of iterations 25 | 26 | 27 | % Solving with PSO method 28 | for k=1:K 29 | for j=1:length(h) 30 | for i=1:length(n) 31 | [cost_opt, deploy_opt_PSO(i,1:n(i),j)] = PSO(r,x,h(j),n(i),P,delta) 32 | R_opt_PSO(i,j,k) = cost_opt 33 | end 34 | end 35 | end 36 | 37 | % assymptotic case 38 | for j=1:length(h) 39 | for i=1:length(n) 40 | [idx,u,sumd,D] = kmeans(x,n(i)); 41 | distance = sqrt(min(D,[],2)); 42 | deploy_opt_asymp(i,1:n(i),j) = u' 43 | % Asymptotic cost 44 | cost_opt_asymp(i,j) = (1-delta)*(b*c1/(h(j)))*costcalculator(deploy_opt_asymp(i,1:n(i),j),n(i),x,idx); 45 | COST = costcalculator(deploy_opt_asymp(i,1:n(i),j),n(i),x,idx) 46 | R_opt_largeH(i,j) =(P./(log(2)*(1+c1)^2*(h(j)^r)))*((1+delta*c1)*(1+c1) + cost_opt_asymp(i,j)) 47 | R_opt_largeN(i,j) =(log(1+P/h(j)^r)*(1/(c1+1))+log(1+P*delta/h(j)^r)*(c1/(c1+1))+( log((h(j)^r+P*delta)/(h(j)^r+P))*(b*c1/(h(j)*(1+c1)^2))*costcalculator(deploy_opt_asymp(i,1:n(i),j),n(i),x,idx)))/log(2); 48 | R_opt_asymp(i,j) = -ObjectiveFunction ( deploy_opt_asymp(i,1:n(i),j),n(i),r,x,h(j),delta,P,b,c ); 49 | R_opt_quant(i,j) = (log(1+P/h(j)^r)*(1/(c1+1))+log(1+P*delta/h(j)^r)*(c1/(c1+1))+( log((h(j)^r+P*delta)/(h(j)^r+P))*(b*c1/(h(j)*(1+c1)^2))*250/n(i)))/log(2); 50 | Plos = 1./(1+c*exp(-b*(atan(h(j)./distance)-c))); 51 | R_los = log2(1+(P./(distance.^2+h(j).^2).^(r/2))); 52 | R_nlos = log2(1+(P*delta./(distance.^2+h(j).^2).^(r/2))); 53 | R_new(i,j) = sum(R_los.*Plos+R_nlos.*(1-Plos))/no_samples; 54 | end 55 | end 56 | 57 | 58 | plot(R_opt_largeH,'red') 59 | hold on; 60 | plot(R_opt_largeN,'black') 61 | plot(R_opt_PSO) 62 | plot(R_new,'green') 63 | 64 | Logreal = log2(1+(P./(distance.^2+h(j).^2).^(r/2))); 65 | Logasymp = (P/h(j)^r).*(1-r/2*distance.^2/h(j)^2)/log(2); 66 | %% 67 | % one dim TIME variate - trajectory optimization 68 | clear all; 69 | close all; 70 | clc; 71 | 72 | d = 1; 73 | no_samples = 5000; 74 | r = 2; 75 | P = 10^(50/10); 76 | delta = 0.5; 77 | h = 100%[300,100,50]; 78 | radius = 1000; 79 | b = 0.43; 80 | b1 = (1-delta)*b; 81 | c = 4.88; 82 | c1 = c*exp(b*c); 83 | c2 = .5*(b^2*(1-delta)+r*(c1-1)); 84 | n = 5; 85 | T = -1:.1:1; 86 | deploy_opt_PSO = zeros(n,length(T)); 87 | deploy_opt_asymp = zeros(n,length(T)); 88 | deploy_opt_quant = zeros(n,length(T)); 89 | R_opt_PSO = zeros(length(T)); 90 | K = 100; 91 | 92 | for t = 1:length(T) 93 | q = rand(1,no_samples); 94 | x = 2-2*abs(T(t))+q.^(1/(1+2*abs(T(t)))); 95 | %PSO result 96 | for k=1:K 97 | [cost_opt, temp] = PSO(r,x,h,n,P,delta); 98 | deploy_opt_PSO_temp(:,t,k) = sort(temp) 99 | end 100 | %asymp result 101 | [idx,u] = kmeans(x,n); 102 | deploy_opt_asymp(:,t) = sort(u); 103 | %Quantization result 104 | deploy_opt_quant(:,t) = 2-2*abs(T(t))+((2*(1:n)-1)/(2*n)).^(1/(1+abs(T(t)))); 105 | end 106 | 107 | R_opt_PSO(t) = cost_opt; 108 | deploy_opt_PSO = mean(deploy_opt_PSO_temp,3); 109 | %deploy_opt_PSO = min(deploy_opt_PSO_temp,[],3); 110 | for t=1:length(T) 111 | if mod(t,2) == 1 112 | temp1(:,(t+1)/2) = deploy_opt_PSO(:,t); 113 | temp2(:,(t+1)/2) = deploy_opt_asymp(:,t); 114 | temp3(:,(t+1)/2) = deploy_opt_quant(:,t); 115 | T_new((t+1)/2) = T(t); 116 | end 117 | end 118 | 119 | figure(2) 120 | hold on 121 | for i = 1:n 122 | plot(T,deploy_opt_PSO(i,:),'black') 123 | plot(T,deploy_opt_asymp(i,:),'blue') 124 | plot(T,deploy_opt_quant(i,:),'red') 125 | end 126 | 127 | figure(3) 128 | hold on 129 | for i = 1:n 130 | plot(T_new,temp1(i,:),'black','LineWidth',2) 131 | plot(T_new,temp2(i,:),'blue','LineWidth',2) 132 | plot(T_new,temp3(i,:),'red','LineWidth',2) 133 | end 134 | xlabel('Trajectories of 5 UAVs in a one-dimensional network') 135 | ylabel('UAV location') 136 | legend('PSO','Thorem 2','Quantization theory') 137 | %% 138 | 139 | --------------------------------------------------------------------------------