Error using *
Disciplined convex programming error:
Invalid numeric values (NaNs) may not be used in CVX expressions.
Error in main (line 127)
object = object + 2real(w_hat_j0(:,j)’ * hr_reg * hr_reg’ * w_hat_j(:,j)) - …
my CVX code is here:
while iter<=Nmax
iter
object=0;
cvx_begin quiet
variable w_hat_j(M,K) complex
variable w_hat_theta(M,1) complex
variable t1(1,K)
variable t2(1,K)
variable t3(1,K)
variable t4(1,K)
variable t5
for j=1:K
object = object + 2real(w_hat_j0(:,j)’ * hr_reg * hr_reg’ * w_hat_j(:,j)) - …
real(w_hat_j0(:,j)’ * hr_reg* hr_reg’ * w_hat_j0(:,j));
end
M1=object+2*real(w_hat_theta0’hr_reghr_reg’*w_hat_theta)-real(w_hat_theta0’hr_reghr_reg’w_hat_theta0);
maximize M1
% 约束条件
subject to
% 添加约束(2)
for n=1:K
for i=1:K-1
2real(w_hat_j0(:,i+1)‘*h_hat_j(:,n)*h_hat_j(:,n)’*w_hat_j(:,i+1))-…
real(w_hat_j0(:,i+1)‘*h_hat_j(:,n)*h_hat_j(:,n)’*w_hat_j0(:,i+1)) >= …
square_abs(h_hat_j(:,n)‘w_hat_j(:,i));
2real(w_hat_theta0’*h_hat_j(:,n)*h_hat_j(:,n)‘*w_hat_theta)-…
real(w_hat_theta0’*h_hat_j(:,n)*h_hat_j(:,n)‘*w_hat_theta0)>=square_abs(h_hat_j(:,n)‘w_hat_j(:,K));
end
end
%添加约束(3)
for n=1:K
right=0;
for j=1:n-1
right=right+2real(w_hat_j0(:,j)’*h_hat_j(:,n)*h_hat_j(:,n)’*w_hat_j(:,j))-…
real(w_hat_j0(:,j)‘*h_hat_j(:,n)*h_hat_j(:,n)’*w_hat_j0(:,j));
end
e_i=0;
for i=1:n
e_i=e_i+(norm(Hru(:,i)‘*phi0).^2)deta_v+deta;
2real(w_hat_j0(:,n)’*h_hat_j(:,i)*h_hat_j(:,i)‘*w_hat_j(:,i))-…
real(w_hat_j0(:,n)’*h_hat_j(:,i)*h_hat_j(:,i)‘w_hat_j0(:,n))>=r_th(right+e_i);
end
end
%添加约束(4)
for n=1:K
right=0;
e_k=0;
for j=1:K
e_k=e_k+(norm(Hru(:,i)’*phi0).^2)deta_v+deta;
right=right+2real(w_hat_j0(:,j)‘*h_hat_j(:,n)*h_hat_j(:,n)’*w_hat_j(:,j))-…
real(w_hat_j0(:,j)‘*h_hat_j(:,n)*h_hat_j(:,n)‘w_hat_j0(:,j));
end
2real(w_hat_theta0’*h_hat_j(:,n)*h_hat_j(:,n)’*w_hat_theta)-…
real(w_hat_theta0’*h_hat_j(:,n)*h_hat_j(:,n)'w_hat_theta0)>=r_th_sita(right+e_k);
end
%
%添加约束(5)
t_total_1=0;
t_total_2=0;
for n=2:K
t_total_1=t_total_1+t1(:,n)-t2(:,n);
end
for n=1:K
t_total_2=t_total_2+t3(:,n)-t4(:,n);
end
t_total_1 - t_total_2 + t5 >= rol_1;
%%约束(6)
left=[];
x=zeros(1,K);
y=zeros(1,K);
for i=1:K
left=[2*he*w_hat_j(:,i),left];
end
for i=1:K
aux_2z=0;
x(i) = exp(t30(:, i));
aux_2z=t3(:,i) + 1 - t30(:,i) ;
norm([2 * sqrt(x(i)), aux_2z, y(i)]') <= aux_2z + y(i);
norm([left,2*he*w_hat_theta,2*deta,y(i)-1]')<=...
y(i) + 1;
end
% 添加约束(8)
for i=2:K
left=0;
for j=1:i
left=left+2*real(w_hat_j0(:,j)‘*h_hat_j(:,i)*h_hat_j(:,i)’*w_hat_j(:,j))-…
real(w_hat_j0(:,j)‘*h_hat_j(:,i)*h_hat_j(:,i)‘w_hat_j0(:,j));
end
left+deta>=exp(t1(:,i));
end
%%%约束(7)
z = zeros(1, K); % 定义 z(i)
w = zeros(1, K); % 定义 w(i)
for i = 2:K
% 定义 left
left = [];
for j = 1:i-1
left = [2 * h_hat_j(:, i)’ * w_hat_j(:, j), left];
end
% 定义 z(i)
aux_y =0;
z(i) = exp(t20(:, i));
z(1)=1;
% 第一部分:定义 w(i) 的锥约束
aux_y = t2(:, i) + 1 - t20(:, i); % 定义辅助变量 aux_y
norm([2 * sqrt(z(i)), aux_y, w(i)]‘) <= aux_y + w(i);
% 第二部分:重新构造的主约束
norm([left, 2 * deta, w(i) - 1]’) <= w(i) + 1;
end
%添加约束(9)
for i=1:K
left=0;
for j=1:K
left=left+2real(w_hat_j0(:,j)’*he’hew_hat_j(:,j))-…
real(w_hat_j0(:,j)‘he’hew_hat_j0(:,j));
end
left=left-(2real(w_hat_j0(:,i)’*he’hew_hat_j(:,i))-…
real(w_hat_j0(:,i)‘he’hew_hat_j0(:,i)));
left+2real(w_hat_theta0’*he’hew_hat_theta)-…
real(w_hat_theta0’he’hew_hat_theta0)+deta>=exp(t4(:,i));
end
%添加约束(10)
2real(w_hat_j0(:,1)’*he’hew_hat_j(:,1))-…
real(w_hat_j0(:,1)'he’hew_hat_j0(:,1))>=exp(t5);
%添加约束(11)
sum=0;
for i=1:K
sum = sum + square_pos(norm(w_hat_j(:,i)));
end
sum=sum+square_pos(norm(w_hat_theta));
sum<=Ps;
cvx_end
object_history(iter) = M1;
alpha = 0.8/iter; % 动态调整步长系数
w_hat_j0 = alpha w_hat_j+(1-alpha)w_hat_j0;
w_hat_theta0 = alpha w_hat_theta+(1-alpha)*w_hat_theta0;
t20=alpha *t2+(1 - alpha) *t20;
t20(:,1)=0;
t30=alpha *t3+(1 - alpha) *t30;
iter=iter+1;
end