Disciplined convex programming error: Illegal operation: log( {convex} ).
Code:
while 1
cvx_begin
% variable q1_opt(1,2)
% variable q2_opt(1,2)
variable q1_xopt(1,length(H))
variable q1_yopt(1,length(H))
variable q2_xopt(1,length(H))
variable q2_yopt(1,length(H))
expression tempRate3(2U,Omax)
expression f3(2U,Omax)
expression g3(1,Omax)
expression E3(2,Omax)
expression M3(Omax)
q1_opt=[q1_xopt(1,zz) q1_yopt(1,zz)];
q2_opt=[q2_xopt(1,zz) q2_yopt(1,zz)];
for jre1=1:U
% re2(jre1)=sum((q1_opt-W(jre1,:)).^2 ,2);
re2(jre1)=pow_pos((q1_xopt(1,zz)-W(jre1,1)),2)+pow_pos((q1_yopt(1,zz)-W(jre1,2)),2);
end
for jre2=U+1:U*2
% re2(jre2)=sum((q2_opt-W(jre2,:)).^2 ,2);
re2(jre2)=pow_pos((q2_xopt(1,zz)-W(jre1,1)),2)+pow_pos((q2_yopt(1,zz)-W(jre1,2)),2);
end
re=re2’;
%%
% 计算f1
for l=1:L % 2
for k=1:K %12 组
for wn=1:WN %2
pkn=pSolution3((l-1)*K*WN+(k-1)*WN+1)+pSolution3((l-1)*K*WN+(k-1)*WN+wn);
tempRate3((l-1)*K*WN+(k-1)*WN+wn)=log(alpha*(H(zz)^2+re((l-1)*K*WN+(k-1)*WN+wn,zz))+pkn)/log(2);
f3((l-1)*K*WN+(k-1)*WN+wn)=sum(tempRate3(1:(l-1)*K*WN+(k-1)*WN+wn));
end
end
end
% 计算g
for l=1:L
E3(l)=c1*norm(vSolution1(l))^3+c2/norm(vSolution1(l));
end
g3(1,o)=sum(E3(:));
M3(o)=f3(48)-elta3(o)*g3(1,o); % M无限小
cvx_end
elta3(o+1)=f3(48)/g3(1,o); % elta(c)趋于稳定,就是最后的maxEE
y3(zz)=f3(48);
if abs(M3(o)-EESolution3)>delta && o<Omax
o=o+1;
else
q1x(zz)=q1_xopt;
q1y(zz)=q1_yopt;
q2x(zz)=q2_xopt;
q2y(zz)=q2_yopt;
break;
end
end
end