├── Antenna.PNG ├── HW2.pdf ├── HW_TEST2.m ├── README.MD ├── README.md ├── SINR.PNG ├── USER.PNG ├── Untitled.m ├── data_generation.m ├── data_generation_antenna.asv ├── data_generation_antenna.m ├── data_generation_user.asv ├── data_generation_user.m ├── functionFeasibilityProblem_cvx.m ├── noise0.PNG ├── noise1.PNG └── noise2.PNG /Antenna.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zslwyuan/Multi-User-Transmit-Beamforming-Linear-Regression-Convex-Optimization-Tutorial/560af4b4f55d89438293434cb853d7caf3182733/Antenna.PNG -------------------------------------------------------------------------------- /HW2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zslwyuan/Multi-User-Transmit-Beamforming-Linear-Regression-Convex-Optimization-Tutorial/560af4b4f55d89438293434cb853d7caf3182733/HW2.pdf -------------------------------------------------------------------------------- /HW_TEST2.m: -------------------------------------------------------------------------------- 1 | function [feasible,Wsolution] = HW_TEST2(H,gammavar) 2 | 3 | % This is the source code for HW2 of ELEC 5470. It is refered to the 4 | % following source code on GitHub. 5 | % https://github.com/emilbjornson/optimal-beamforming/blob/master/functionFeasibilityProblem_cvx.m 6 | % The related paper can be found on arXiv: https://arxiv.org/pdf/1404.0408.pdf 7 | 8 | 9 | Kr = size(H,1); %Number of users 10 | N = size(H,2); %Number of transmit antennas (in total) 11 | D = repmat(eye(N),[1 1 Kr]); 12 | 13 | %Solve the power minimization under QoS requirements problem using CVX 14 | cvx_begin 15 | cvx_quiet(true); % This suppresses screen output from the solver 16 | 17 | variable W(N,Kr) complex; %Variable for N x Kr beamforming matrix 18 | variable POWER %Scaling parameter for power constraints 19 | 20 | minimize POWER %Minimize the power indirectly by scaling power constraints 21 | 22 | subject to 23 | 24 | %SINR constraints (Kr constraints) 25 | for k = 1:Kr 26 | 27 | %Channels of the signal intended for user i when it reaches user k 28 | hkD = zeros(Kr,N); 29 | for i = 1:Kr 30 | hkD(i,:) = H(k,:)*D(:,:,i); 31 | end 32 | 33 | imag(hkD(k,:)*W(:,k)) == 0; %Useful link is assumed to be real-valued 34 | 35 | %SOCP formulation for the SINR constraint of user k 36 | real(hkD(k,:)*W(:,k)) >= sqrt(gammavar)*norm([1 hkD(k,:)*W(:,[1:k-1 k+1:Kr]) ]); 37 | end 38 | 39 | %Power constraints (L constraints) scaled by the variable betavar 40 | norm(W,'fro') <= POWER; 41 | POWER >= 0; %Power constraints must be positive 42 | 43 | cvx_end 44 | 45 | 46 | %Analyze result and prepare the output variables. 47 | if isempty(strfind(cvx_status,'Solved')) %Both power minimization problem and feasibility problem are infeasible. 48 | feasible = false; 49 | Wsolution = []; 50 | else %Both power minimization problem and feasibility problem are feasible. 51 | feasible = true; 52 | Wsolution = W; 53 | POWER 54 | end 55 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | This is the homework 2 of ELEC 5470 Convex Optimization. In this homework, we use convex optimization package in MATLAB to implement linear regression and multi-user transmit beamforming problem. 2 | 3 | It could be a basic tutorial for using CVX package in MATLAB. Before trying these source code, user should first intall CVX for MATLAB properly. (http://cvxr.com/cvx/doc/install.html) 4 | 5 | How to use these source code and how they work? Please refer to the report: 6 | 7 | https://github.com/zslwyuan/Multi-User-Transmit-Beamforming-Linear-Regression-Convex-Optimization-Homework/blob/master/HW2.pdf 8 | 9 | Hope they help. Please note that, this work refers to the following works: 10 | 11 | https://github.com/emilbjornson/optimal-beamforming/blob/master/functionFeasibilityProblem_cvx.m 12 | 13 | The related paper can be found on arXiv: 14 | 15 | https://arxiv.org/pdf/1404.0408.pdf 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Multi-User-Transmit-Beamforming-Linear-Regression-Convex-Optimization-Homework 2 | This is the homework 2 of ELEC 5470 Convex Optimization. In this homework, we use convex optimization package in MATLAB to implement linear regression and multi-user transmit beamforming problem. 3 | -------------------------------------------------------------------------------- /SINR.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zslwyuan/Multi-User-Transmit-Beamforming-Linear-Regression-Convex-Optimization-Tutorial/560af4b4f55d89438293434cb853d7caf3182733/SINR.PNG -------------------------------------------------------------------------------- /USER.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zslwyuan/Multi-User-Transmit-Beamforming-Linear-Regression-Convex-Optimization-Tutorial/560af4b4f55d89438293434cb853d7caf3182733/USER.PNG -------------------------------------------------------------------------------- /Untitled.m: -------------------------------------------------------------------------------- 1 | clear all; 2 | clf; 3 | randn('seed',2); 4 | rand('seed',2); 5 | x = -10 + 20*rand(50,1); 6 | a_true = 2; b_true = 5; 7 | y =a_true * x + b_true; 8 | %noise = randn(50,1) + 20*[zeros(19,1);1;zeros(19,1);1;zeros(10,1)]; 9 | %noise = randn(50,1); 10 | noise = trnd(1,[50,1]); 11 | 12 | y = y + noise; 13 | plot(x,y,'b.') 14 | 15 | cvx_begin 16 | variable a_est1(1) 17 | variable b_est1(1) 18 | minimize( norm( y-a_est1 * x - b_est1, 2 ) ) 19 | cvx_end 20 | x_est1 = (-10:10); 21 | y_est1 = a_est1 * x_est1 + b_est1; 22 | hold on; 23 | plot(x_est1,y_est1,'r-'); 24 | txt2 = ' \phi_1(r) \Rightarrow'; 25 | text(x_est1(14)-3,y_est1(14),txt2) 26 | grid on 27 | 28 | 29 | cvx_begin 30 | variable a_est2(1) 31 | variable b_est2(1) 32 | minimize( norm( y-a_est2 * x - b_est2, 1 ) ) 33 | cvx_end 34 | x_est2 = (-10:10); 35 | y_est2 = a_est2 * x_est2 + b_est2; 36 | hold on; 37 | plot(x_est2,y_est2,'g-'); 38 | txt1 = '\Leftarrow \phi_2(r)'; 39 | text(x_est2(7)+1,y_est2(7),txt1) 40 | grid on 41 | 42 | est_error1 = (a_est1-a_true)^2+(b_est1-b_true)^2; 43 | est_error2 = (a_est2-a_true)^2+(b_est2-b_true)^2; 44 | 45 | txt = sprintf('%s=%f','a_{est1}',a_est1); 46 | text(-8,21,txt) 47 | txt = sprintf('%s=%f','b_{est1}',b_est1); 48 | text(-8,18,txt) 49 | txt = sprintf('%s=%f','error_{est1}',est_error1); 50 | text(-8,15,txt) 51 | txt = sprintf('%s=%f','a_{est2}',a_est2); 52 | text(0,-9,txt) 53 | txt = sprintf('%s=%f','b_{est2}',b_est2); 54 | text(0,-12,txt) 55 | txt = sprintf('%s=%f','error_{est2}',est_error2); 56 | text(0,-15,txt) 57 | title('Noise(2) (Significant Noise)') -------------------------------------------------------------------------------- /data_generation.m: -------------------------------------------------------------------------------- 1 | clear all; 2 | 3 | K = 50; %user number 4 | N = 3; %antenna number 5 | 6 | gamma_dB_Seq = -13:0.5:-11 7 | feasibility_ratio = -13:0.5:-11 8 | gamma_index = 0 9 | 10 | for gamma_dB=-13:0.5:-11 11 | gamma_dB 12 | gamma_index = gamma_index + 1; 13 | ok_num = 0; 14 | for test=1:20 15 | 16 | H = []; %initialize H matrix 17 | 18 | for i=1:K 19 | h = 1/sqrt(2*K)*mvnrnd(zeros(N,1),eye(N),1)'+1i/sqrt(2*K)*mvnrnd(zeros(N,1),eye(N),1)'; 20 | H = [H h]; 21 | end 22 | 23 | H = H'; 24 | 25 | gamma = db2mag(2*gamma_dB); 26 | 27 | [feasible,Wsolution] = HW_TEST2(H,gamma); 28 | ok_num = ok_num + feasible; 29 | end 30 | feasibility_ratio(gamma_index) = ok_num / 20.0 31 | end 32 | plot(gamma_dB_Seq,feasibility_ratio) 33 | grid on -------------------------------------------------------------------------------- /data_generation_antenna.asv: -------------------------------------------------------------------------------- 1 | clear all; 2 | 3 | K = 100; %antenna number 4 | 5 | N_seq = 7:1:12 6 | feasibility_ratio = 7:1:12 7 | N_index = 0 8 | gamma_dB = -10; %SINR / dB 9 | 10 | for K=95:1:100 %user number 11 | 12 | N 13 | N_inde = K_index + 1; 14 | ok_num = 0; 15 | for test=1:20 16 | 17 | H = []; %initialize H matrix 18 | 19 | for i=1:K 20 | h = 1/sqrt(2*K)*mvnrnd(zeros(N,1),eye(N),1)'+1i/sqrt(2*K)*mvnrnd(zeros(N,1),eye(N),1)'; 21 | H = [H h]; 22 | end 23 | 24 | H = H'; 25 | 26 | gamma = db2mag(2*gamma_dB); 27 | 28 | [feasible,Wsolution] = HW_TEST2(H,gamma); 29 | ok_num = ok_num + feasible; 30 | end 31 | feasibility_ratio(K_index) = ok_num / 20.0 32 | end 33 | plot(K_seq,feasibility_ratio) 34 | grid on -------------------------------------------------------------------------------- /data_generation_antenna.m: -------------------------------------------------------------------------------- 1 | clear all; 2 | 3 | K = 100; %antenna number 4 | 5 | N_seq = 7:1:12 6 | feasibility_ratio = 7:1:12 7 | N_index = 0 8 | gamma_dB = -10; %SINR / dB 9 | 10 | for N=7:1:12 %user number 11 | 12 | N 13 | N_index = N_index + 1; 14 | ok_num = 0; 15 | for test=1:20 16 | 17 | H = []; %initialize H matrix 18 | 19 | for i=1:K 20 | h = 1/sqrt(2*K)*mvnrnd(zeros(N,1),eye(N),1)'+1i/sqrt(2*K)*mvnrnd(zeros(N,1),eye(N),1)'; 21 | H = [H h]; 22 | end 23 | 24 | H = H'; 25 | 26 | gamma = db2mag(2*gamma_dB); 27 | 28 | [feasible,Wsolution] = HW_TEST2(H,gamma); 29 | ok_num = ok_num + feasible; 30 | end 31 | feasibility_ratio(N_index) = ok_num / 20.0 32 | end 33 | plot(N_seq,feasibility_ratio) 34 | grid on -------------------------------------------------------------------------------- /data_generation_user.asv: -------------------------------------------------------------------------------- 1 | clear all; 2 | 3 | K = 50; %user number 4 | N = 3; %antenna number 5 | 6 | K_seq = 95:1:100 7 | feasibility_ratio = 95:1:100 8 | K_index = 0 9 | gamma_dB = -15; 10 | 11 | for gamma_dB=-13:0.5:-11 12 | 13 | K_index = K_index + 1; 14 | ok_num = 0; 15 | for test=1:20 16 | 17 | H = []; %initialize H matrix 18 | 19 | for i=1:K 20 | h = 1/sqrt(2*K)*mvnrnd(zeros(N,1),eye(N),1)'+1i/sqrt(2*K)*mvnrnd(zeros(N,1),eye(N),1)'; 21 | H = [H h]; 22 | end 23 | 24 | H = H'; 25 | 26 | gamma = db2mag(2*gamma_dB); 27 | 28 | [feasible,Wsolution] = HW_TEST2(H,gamma); 29 | ok_num = ok_num + feasible; 30 | end 31 | feasibility_ratio(K_index) = ok_num / 20.0 32 | end 33 | plot(gamma_dB_Seq,feasibility_ratio) 34 | grid on -------------------------------------------------------------------------------- /data_generation_user.m: -------------------------------------------------------------------------------- 1 | clear all; 2 | 3 | N = 3; %antenna number 4 | 5 | K_seq = 95:1:100 6 | feasibility_ratio = 95:1:100 7 | K_index = 0 8 | gamma_dB = -15; %SINR / dB 9 | 10 | for K=95:1:100 %user number 11 | 12 | K 13 | K_index = K_index + 1; 14 | ok_num = 0; 15 | for test=1:20 16 | 17 | H = []; %initialize H matrix 18 | 19 | for i=1:K 20 | h = 1/sqrt(2*K)*mvnrnd(zeros(N,1),eye(N),1)'+1i/sqrt(2*K)*mvnrnd(zeros(N,1),eye(N),1)'; 21 | H = [H h]; 22 | end 23 | 24 | H = H'; 25 | 26 | gamma = db2mag(2*gamma_dB); 27 | 28 | [feasible,Wsolution] = HW_TEST2(H,gamma); 29 | ok_num = ok_num + feasible; 30 | end 31 | feasibility_ratio(K_index) = ok_num / 20.0 32 | end 33 | plot(K_seq,feasibility_ratio) 34 | grid on -------------------------------------------------------------------------------- /functionFeasibilityProblem_cvx.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zslwyuan/Multi-User-Transmit-Beamforming-Linear-Regression-Convex-Optimization-Tutorial/560af4b4f55d89438293434cb853d7caf3182733/functionFeasibilityProblem_cvx.m -------------------------------------------------------------------------------- /noise0.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zslwyuan/Multi-User-Transmit-Beamforming-Linear-Regression-Convex-Optimization-Tutorial/560af4b4f55d89438293434cb853d7caf3182733/noise0.PNG -------------------------------------------------------------------------------- /noise1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zslwyuan/Multi-User-Transmit-Beamforming-Linear-Regression-Convex-Optimization-Tutorial/560af4b4f55d89438293434cb853d7caf3182733/noise1.PNG -------------------------------------------------------------------------------- /noise2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zslwyuan/Multi-User-Transmit-Beamforming-Linear-Regression-Convex-Optimization-Tutorial/560af4b4f55d89438293434cb853d7caf3182733/noise2.PNG --------------------------------------------------------------------------------