无线携能通信网络在多用户接收用户时的波束成形优化代码

来源:互联网 发布:mac mini重装系统教程 编辑:程序博客网 时间:2024/06/16 06:04
clear allclc for j=1:50q1 = 20;q2 = 30;q3 = 15;q4 = 5;sigma_sq = 1;W(:,:,1) = eye(2);W(:,:,2) = eye(2);V = eye(2);h1 = complex(randn(2,1),randn(2,1)); h2 = complex(randn(2,1),randn(2,1)); h3 = complex(randn(2,1),randn(2,1)); h4 = complex(randn(2,1),randn(2,1)); g1 = complex(randn(2,1),randn(2,1)); g2 = complex(randn(2,1),randn(2,1)); g3 = complex(randn(2,1),randn(2,1)); g4 = complex(randn(2,1),randn(2,1));  t = -1; minus_SINR1 = -h1'*W(:,:,1)*h1/(h1'*W(:,:,2)*h1+g1'*V*g1+sigma_sq); minus_SINR2 = -h2'*W(:,:,2)*h2/(h2'*W(:,:,1)*h2+g2'*V*g2+sigma_sq); u1 = max(minus_SINR1,minus_SINR2); k = 1;while abs(t) >= 1e-3    cvx_begin sdp    variable W(2,2,2) complex hermitian    variable V(2,2) complex hermitian     variable t     minimize t;    subject to       trace( W(:,:,1)+W(:,:,2) ) <= q1;  % information power constraint       trace(V) <= q2;                           % energy power constraints       W(:,:,1) == hermitian_semidefinite(2);       W(:,:,2) == hermitian_semidefinite(2);       V == hermitian_semidefinite(2);                real( h3'*( W(:,:,1)+W(:,:,2) )*h3 + g3'*V*g3 ) >= q3;  % EH constraint       imag( h3'*( W(:,:,1)+W(:,:,2) )*h3 + g3'*V*g3 ) == 0;       real( h4'*( W(:,:,1)+W(:,:,2) )*h4 + g4'*V*g4 ) <= q4; % Interference constraint        imag( h4'*( W(:,:,1)+W(:,:,2) )*h4 + g4'*V*g4 ) == 0;       real( - h1'*W(:,:,1)*h1 - u1*(h1'*W(:,:,2)*h1+g1'*V*g1+sigma_sq) ) <= t; % mimus_SINR for user 1       real( - h2'*W(:,:,2)*h2 - u1*(h2'*W(:,:,1)*h2+g2'*V*g2+sigma_sq) ) <= t; % minus_SINR for user 2           imag( - h1'*W(:,:,1)*h1 - u1*(h1'*W(:,:,2)*h1+g1'*V*g1+sigma_sq) ) == 0;        imag( - h2'*W(:,:,2)*h2 - u1*(h2'*W(:,:,1)*h2+g2'*V*g2+sigma_sq) ) == 0;     cvx_end imag(u1)==0 q(k)=real(u1)  p(k) = t;     if p(k) == 0      W_opt = W;      V_opt = V;      break;  else      minus_SINR1 = -h1'*W(:,:,1)*h1/(h1'*W(:,:,2)*h1+g1'*V*g1+sigma_sq);      minus_SINR2 = -h2'*W(:,:,2)*h2/(h2'*W(:,:,1)*h2+g2'*V*g2+sigma_sq);      u1 = max(minus_SINR1,minus_SINR2);      k = k+1;  endendz1(j)=u1W(:,:,1) = eye(2);W(:,:,2) = eye(2);V = eye(2);t = -1; minus_SINR1 = -h1'*W(:,:,1)*h1/(h1'*W(:,:,2)*h1+g1'*V*g1+sigma_sq); minus_SINR2 = -h2'*W(:,:,2)*h2/(h2'*W(:,:,1)*h2+g2'*V*g2+sigma_sq); u2 = max(minus_SINR1,minus_SINR2); k = 1; g_value1 = h1'*W(:,:,2)*h1+g1'*V*g1+sigma_sq g_value2 = h2'*W(:,:,1)*h2+g2'*V*g2+sigma_sq while abs(t) >= 1e-3    cvx_begin sdp    variable W(2,2,2) complex hermitian    variable V(2,2) complex hermitian     variable t     minimize t;    subject to       trace( W(:,:,1)+W(:,:,2) ) <= q1;  % information power constraint       trace(V) <= q2;                           % energy power constraints       W(:,:,1) == hermitian_semidefinite(2);       W(:,:,2) == hermitian_semidefinite(2);       V == hermitian_semidefinite(2);                real( h3'*( W(:,:,1)+W(:,:,2) )*h3 + g3'*V*g3 ) >= q3;  % EH constraint       imag( h3'*( W(:,:,1)+W(:,:,2) )*h3 + g3'*V*g3 ) == 0;       real( h4'*( W(:,:,1)+W(:,:,2) )*h4 + g4'*V*g4 ) <= q4; % Interference constraint        imag( h4'*( W(:,:,1)+W(:,:,2) )*h4 + g4'*V*g4 ) == 0;       real( ( - h1'*W(:,:,1)*h1 - u2*(h1'*W(:,:,2)*h1+g1'*V*g1+sigma_sq))/g_value1 ) <= t; % mimus_SINR for user 1       real( (- h2'*W(:,:,2)*h2 - u2*(h2'*W(:,:,1)*h2+g2'*V*g2+sigma_sq))/ g_value2 ) <= t; % minus_SINR for user 2           imag( ( - h1'*W(:,:,1)*h1 - u2*(h1'*W(:,:,2)*h1+g1'*V*g1+sigma_sq))/g_value1 ) == 0;        imag( (- h2'*W(:,:,2)*h2 - u2*(h2'*W(:,:,1)*h2+g2'*V*g2+sigma_sq))/ g_value2 ) == 0;     cvx_end  imag(u2)==0 q(k)=real(u2) p(k) = t;     if p(k) == 0      W_opt = W;      V_opt = V;      break;  else      minus_SINR1 = -h1'*W(:,:,1)*h1/(h1'*W(:,:,2)*h1+g1'*V*g1+sigma_sq);      minus_SINR2 = -h2'*W(:,:,2)*h2/(h2'*W(:,:,1)*h2+g2'*V*g2+sigma_sq);      u2 = max(minus_SINR1,minus_SINR2);      k = k+1;  end   g_value1 = h1'*W(:,:,2)*h1+g1'*V*g1+sigma_sq;   g_value2 = h2'*W(:,:,1)*h2+g2'*V*g2+sigma_sq;endz2(j)=u2W(:,:,1) = eye(2);W(:,:,2) = eye(2);V = eye(2);t = -1; minus_SINR1 = -h1'*W(:,:,1)*h1/(h1'*W(:,:,2)*h1+sigma_sq); minus_SINR2 = -h2'*W(:,:,2)*h2/(h2'*W(:,:,1)*h2+sigma_sq); u3 = max(minus_SINR1,minus_SINR2); k = 1; while abs(t) >= 1e-3    cvx_begin sdp    variable W(2,2,3) complex hermitian    variable V(2,2) complex hermitian     variable t     minimize t;    subject to       trace( W(:,:,1)+W(:,:,2)+W(:,:,3) ) <= q1;  % information power constraint       trace(V) <= q2;                           % energy power constraints       W(:,:,1) == hermitian_semidefinite(2);       W(:,:,2) == hermitian_semidefinite(2);       W(:,:,3) == hermitian_semidefinite(2);       V == hermitian_semidefinite(2);                real( h3'*( W(:,:,1)+W(:,:,2) + W(:,:,3))*h3 + g3'*V*g3 ) >= q3;  % EH constraint       imag( h3'*( W(:,:,1)+W(:,:,2) + W(:,:,3) )*h3 + g3'*V*g3 ) == 0;      % real( h4'*( W(:,:,1)+W(:,:,2) )*h4 + g4'*V*g4 ) <= q4; % Interference constraint        %imag( h4'*( W(:,:,1)+W(:,:,2) )*h4 + g4'*V*g4 ) == 0;       real( - h1'*W(:,:,1)*h1 - u3*(h1'*W(:,:,2)*h1+sigma_sq) ) <= t; % mimus_SINR for user 1       real( - h2'*W(:,:,2)*h2 - u3*(h2'*W(:,:,1)*h2+sigma_sq) ) <= t; % minus_SINR for user 2           imag( - h1'*W(:,:,1)*h1 - u3*(h1'*W(:,:,2)*h1+sigma_sq) ) == 0;        imag( - h2'*W(:,:,2)*h2 - u3*(h2'*W(:,:,1)*h2+sigma_sq) ) == 0;     cvx_end  imag(u3)==0 z(k)=real(u3)  p(k) = t;     if p(k) == 0      W_opt = W;      V_opt = V;      break;  else      minus_SINR1 = -h1'*W(:,:,1)*h1/(h1'*W(:,:,2)*h1+sigma_sq);      minus_SINR2 = -h2'*W(:,:,2)*h2/(h2'*W(:,:,1)*h2+sigma_sq);      u3 = max(minus_SINR1,minus_SINR2);      k = k+1;  endendz3(j)=u3W(:,:,1) = eye(2);W(:,:,2) = eye(2);V = eye(2);t = -1; minus_SINR1 = -h1'*W(:,:,1)*h1/(h1'*W(:,:,2)*h1+sigma_sq); minus_SINR2 = -h2'*W(:,:,2)*h2/(h2'*W(:,:,1)*h2+sigma_sq); u4 = max(minus_SINR1,minus_SINR2); k = 1; g_value1 = h1'*W(:,:,2)*h1+sigma_sq g_value2 = h2'*W(:,:,1)*h2+sigma_sq while abs(t) >= 1e-3    cvx_begin sdp    variable W(2,2,3) complex hermitian    variable V(2,2) complex hermitian     variable t     minimize t;    subject to       trace( W(:,:,1)+W(:,:,2)+W(:,:,3) ) <= q1;  % information power constraint       trace(V) <= q2;                           % energy power constraints       W(:,:,1) == hermitian_semidefinite(2);       W(:,:,2) == hermitian_semidefinite(2);       W(:,:,3) == hermitian_semidefinite(2);       V == hermitian_semidefinite(2);              real( h3'*( W(:,:,1)+W(:,:,2) + W(:,:,3))*h3 + g3'*V*g3 ) >= q3;  % EH constraint       imag( h3'*( W(:,:,1)+W(:,:,2) + W(:,:,3) )*h3 + g3'*V*g3 ) == 0;      % real( h4'*( W(:,:,1)+W(:,:,2) )*h4 + g4'*V*g4 ) <= q4; % Interference constraint        %imag( h4'*( W(:,:,1)+W(:,:,2) )*h4 + g4'*V*g4 ) == 0;       real( ( - h1'*W(:,:,1)*h1 - u4*(h1'*W(:,:,2)*h1+sigma_sq))/g_value1 ) <= t; % mimus_SINR for user 1       real( (- h2'*W(:,:,2)*h2 - u4*(h2'*W(:,:,1)*h2+sigma_sq))/ g_value2 ) <= t; % minus_SINR for user 2           imag( ( - h1'*W(:,:,1)*h1 - u4*(h1'*W(:,:,2)*h1+sigma_sq))/g_value1 ) == 0;        imag( (- h2'*W(:,:,2)*h2 - u4*(h2'*W(:,:,1)*h2+sigma_sq))/ g_value2 ) == 0;     cvx_end  imag(u4)==0 l(k)=real(u4) p(k) = t;     if p(k) == 0      W_opt = W;      V_opt = V;      break;  else      minus_SINR1 = -h1'*W(:,:,1)*h1/(h1'*W(:,:,2)*h1+sigma_sq);      minus_SINR2 = -h2'*W(:,:,2)*h2/(h2'*W(:,:,1)*h2+sigma_sq);      u4 = max(minus_SINR1,minus_SINR2);      k = k+1;  end   g_value1 = h1'*W(:,:,2)*h1+g1'*V*g1+sigma_sq;   g_value2 = h2'*W(:,:,1)*h2+g2'*V*g2+sigma_sq;endz4(j)=u4 end figure;plot(1:length(z1),real(-z1),'-ro'); grid on;hold on;plot(1:length(z2),real(-z2),'-bo');hold off;hold on;plot(1:length(z3),real(-z3),'-go');hold off;hold on;plot(1:length(z4),real(-z4),'-mo');hold off;

原创粉丝点击