Hello, a error occured when I run my code, my code is as follows, please help me. Thanks!
This is my matlab codes:
clear all
clc
tic
global h_mB h_mE g_nB g_nE
W = 8;
g_nB = [1.44924338701434e-06*(1+1i),3.63188309794729e-07*(1+1i),9.07472859811576e-08*(1+1i),2.08958242236184e-07*(1+1i),0.000543522514688916*(1+1i),1.77911904616958e-06*(1+1i),1.53372715576804e-07*(1+1i),1.97159803748322e-07*(1+1i),3.46390370939759e-06*(1+1i)];
g_nE = [5.67255098422262e-05*(1+1i),1.25912635166875e-05*(1+1i),4.78015765032432e-05*(1+1i),8.91546016462140e-05*(1+1i),1.40389165890170e-05*(1+1i),4.98983183289721e-05*(1+1i),1.10754244910520e-04*(1+1i),2.84635902374235e-03*(1+1i),8.50214371168785e-02*(1+1i)];
h_mB = [4.34404855030804e-06,2.26142258059391e-07,7.25067001767426e-06,1.20084212562690e-05,0.000391180435143247,4.89525724968232e-07];
h_mE = [2.33534605202823e-07,5.54513400422210e-08,7.26470059779064e-07,2.18580357625511e-06,5.15089617626485e-08,3.73847113626707e-07];
n_B = 1e-10;
n_E = 1e-10;
delta = 1e-08;
cn_req = 10;
cm_req = 5;
h_mE_max = h_mE +delta;
h_mE_min = h_mE -delta;
g_nE_min = g_nE -delta;
P = 1;
M = size(h_mB,2);
N = size(g_nB,2);
q = [1,1,1,1,1,1];
pv_m_max = 1;
result = [];
e = 1;
converged = false;
for n=1:1:N
T_K(n) = 0;
R_l_K(n) = 0;
end
F = [];
max_iterations = 1000;
for l=1:1:max_iterations
for m=1:1:M
M1(m) = q(m).*h_mB(m)+(sum(q(1:m-1).*h_mB(1:m-1)+n_B));
end
cvx_begin
variables t_k r_l_k p_V(1,N) x_k y_l
expressions result M2(m) M3(m) M3(m) M4(m) t
G_mE_min = zeros(1, N);
for n = 1:N
G_mE_min(:, n) = g_nE_min(:,n)*conj(g_nE_min(:,n));
end
% p_V(1,N) = p_v(1,N)'*p_v(1,N);
for m=1:1:M
for n=1:1:N
M2(m) = sum(q(1:m-1).* h_mE_min(1:m-1))+sum((p_V(1:n).* G_mE_min(1:n))) +n_E;
end
end
for m=1:1:M
M3 = sum(q(1:m-1).*h_mB(1:m-1))+n_B;%log2
end
for n=1:1:N
for m=1:1:M
M4(m) = ((sum(q(1:m-1).* h_mE_min(1:m-1))+sum(q(m+1:M).* h_mE_min(m+1:M))+...
sum(p_V(1:n-1).* G_mE_min(1:n-1))+sum(p_V(n+1:N).* G_mE_min(n+1:N))+n_E)+q(m)*h_mB(m));
end
end
maximize t
subject to:
t >= cm_req;
p_V >= 0;
exp(x_k+y_l-t_k-r_l_k)>=2^(t/W);
M1 >= exp(x_k);
M2(m) >= exp(y_l);
for m=1:1:M
for n = 1:1:N
10*M3 <= 10*exp(T_K(n)) * (t_k - T_K(n) + 1);
10*M4(m) <= 10*exp(R_l_K(n)) * (r_l_k - R_l_K(n) + 1);
end
end
for m=1:1:M
sum((p_V(1:m)).^2) <= P;
end
cvx_end
T_K(n) = t_k;
R_l_K(n) = r_l_k;
result = [result, cvx_optval];
if length(result) > l && abs(result(end) - result(end - 1)) < 0.01
break;
end
end
opt_v = p_V;
sol = result(end);
This is the output
Successive approximation method to be employed.
For improved efficiency, SDPT3 is solving the dual problem.
SDPT3 will be called several times to refine the solution.
Original size: 197 variables, 34 equality constraints
1 exponentials add 8 variables, 5 equality constraints
Cones | Errors |
Mov/Act | Centering Exp cone Poly cone | Status
--------±--------------------------------±--------
1/ 1 | 5.081e+00 1.588e+00 0.000e+00 | Failed
0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Failed
0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Failed
1/ 1 | 1.804e+00 1.648e-01 0.000e+00 | Failed
0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Failed
Status: Failed
Optimal value (cvx_optval): NaN
Successive approximation method to be employed.
For improved efficiency, SDPT3 is solving the dual problem.
SDPT3 will be called several times to refine the solution.
Original size: 197 variables, 34 equality constraints
1 exponentials add 8 variables, 5 equality constraints
Cones | Errors |
Mov/Act | Centering Exp cone Poly cone | Status
--------±--------------------------------±--------
1/ 1 | 8.000e+00 2.259e+01 0.000e+00 | Unbounded
1/ 1 | 8.000e+00s 1.425e+01 0.000e+00 | Unbounded
1/ 1 | 8.000e+00s 5.418e+00 0.000e+00 | Unbounded
1/ 1 | 1.295e+00 5.412e-02 0.000e+00 | Unbounded
0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Unbounded
Status: Infeasible
Optimal value (cvx_optval): -Inf
错误使用 + (第 83 行)
Disciplined convex programming
error:
Illegal operation: {real
affine} - {invalid}
出错 - (第 21 行)
z = plus( x, y, true, cheat );
出错 beamforming (第 85 行)
10M3 <=
10exp(T_K(n)) * (t_k
- T_K(n) + 1);