When I used CVXQUAD,I still get Failed

(Li Yifei) #1

This is my code:

clc;clear
% 吞吐量和公平性权重因子
Lambda = 0.5;
% wifi系统用户数
N=10;
%% D2D-U系统仿真参数
R=500;L=50;
B=2010^6;PSD=-174;
Pm=20;M=5;
%% 变量
rth =1 ;%系统满足用户的最小速率
Rm=4;%MOS用户满意不超过4.5时的最大速率
Pmw=10^(Pm/10-3); %单位换算为w
BPSD=10^((10
log10(B)+PSD)/10-3); %单位换算

%% 撒点 生成g,p矩阵
g=[1.20400768243480e-09,1.97390048654673e-15,4.55482681665684e-14,2.88729797725590e-12,1.16263023804519e-08;2.03940187624467e-15,4.18357806194726e-08,1.55177799695453e-14,3.60251902390694e-15,1.92868749024042e-15;5.23383943203430e-14,1.29823956091715e-14,6.83827372245750e-08,7.86944277228367e-14,4.11367261904270e-14;7.21881610685714e-13,3.82543091213158e-15,7.78273974757130e-14,7.80449461386999e-10,8.82427223501170e-13;1.33229063264012e-08,2.07861873054549e-15,5.81092379365689e-14,1.98577179569490e-12,2.72611292094715e-10];

P = Pmw.*ones(1,M);

tf2 = zeros(1,M);
%% 迭代初始量
Sdp=1;SdP=0;

%% 使用cvx工具箱算p
cvx_begin

``````variable p(1,M)

% 计算凹函数  f2
a=0;f2=0;
for m=1:1:M
for j=1:1:M
a = P(1,j)*g(j,m)+a;
end
b = a-P(1,m)*g(m,m);
f2 = log2(b+BPSD)+f2;
end
%梯度 f2
c=0;d=0;
for m=1:M
for l=1:1:M
for i=1:1:M
c = P(1,i)*g(i,l)+c;
end
c = c - P(1,l)*g(l,l);
d = d + g(m,l)/(log(2*c)+BPSD);
end
h=0;
for i=1:1:M
h = P(1,i)*g(i,m)+h;
end
h = h - P(1,m)*g(m,m);

tf2m = d-g(m,m)/(log(2*h)+BPSD);
tf2(1,m)=tf2m;
end
% D2D-U系统SINR
e=0;
for j=1:1:M
e = P(1,j)*g(j,m)+ e;
end
f = e-P(1,m)*g(m,m);
r = P(1,m)*g(m,m)/f;

%f1
a1 = 0;f1=0;
for m=1:1:M
for j=1:1:M
a1 = p(1,j)*g(j,m)+a1;
end
a2=a1+BPSD;
f1 = -rel_entr(1,a2) / log(2)+f1;
end

F = f1 - ( f2 + tf2 * ((p(1,M)-P)'));

maximize( F );

subject to
%C1
e1=0;
for m=1:M
for j=1:1:M
e1 = P(1,j)*g(j,m)+ e1;
end
f = e1-P(1,m)*g(m,m);
p(1,m)*g(m,m)+(1-2^rth)*(f+BPSD) >= 0;
end
%C2
e2=0;
for m=1:M
for j=1:1:M
e2 = P(1,j)*g(j,m)+ e2;
end
f = e2-P(1,m)*g(m,m);
(2^Rm-1)*(f+BPSD)- p(1,m)*g(m,m) >= 0;
end
%C3
for m=1:M
Pmw-p(1,m) >= 0;
end
%C4
for m=1:M
p(1,m) >= 0;
end
%C5
e3=0;
for m=1:M
e3=e3+p(1,m);
end
M * Pmw >= e3;

cvx_end
``````

Cones | Errors | Mov/Act | Centering Exp cone Poly cone | Status --------±--------------------------------±-------- 5/ 5 | 8.000e+00 1.136e+01 0.000e+00 | Failed 5/ 5 | 9.428e-01 1.478e-02 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 0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Failed

Status: Failed
Optimal value (cvx_optval): NaN

I get a optimal solution with cvx, but I can't get the same result when I use the optimal solution
(Mark L. Stone) #2

You must not have correctly followed the instructions in the link below because your output shows that the Successive Approximation mthod was used.

(Erling D.Andersen) #3

Your model contains some really crazy numbers e.g. B and g. I recommend you think about the scaling of your problem.

(Mark L. Stone) #4