Hi, everyone. My problem is that the objective function with obtained optimal solution is not equal to cvx_optval.
Specifically, the optimization problem is a convex problem. There are only two variables X and Y in cvx code. The objective function is a sum_log like function. And there is a for-while iteration containing the convex problem. In each iteration, I use variable sum_r4 to calculate the objective function with the optimal solution, but it’s not equal to cvx_optval. I wonder whether cvx has obtained the real optimal solution in my case.
I have read several topics such as substituting log function with rel_entr_quad by CVXQUAD. Also using cvx 2.2 and mosek 9.1.9. However, it doesn’t work.
I give the complete matlab code as follows which is reproducible.
Thank you.
%% Parameters
BW=180000;
K=15;
M=K;
N=K;
noise_density_dBm=-140;
noise=10^(noise_density_dBm/10)*BW;
Pu_max_dBm=24;%dBm
Pu_max=10^(Pu_max_dBm/10);
Pd_max_dBm=43;
Pd_max=10^(Pd_max_dBm/10);
Pu=Pu_max*ones(M,K);
Pd=Pu;
%% distance
radius=500;
theta_user=zeros(M,N);
d_user=zeros(M,N);
theta_U=random('uniform',0,2*pi,M,1);
d_U=random('uniform',100,radius,M,1);
theta_D=random('uniform',0,2*pi,N,1);
d_D=random('uniform',100,radius,N,1);
H=zeros(M,N,K);
for i=1:M
theta_user(i,:)=abs(theta_U(i)-theta_D);
end
theta_user(theta_user>pi)=2*pi-theta_user(theta_user>pi);
for x=1:M
for y=1:N
d_user(x,y)=sqrt(d_U(x)^2+d_D(y)^2-2*d_U(x)*d_D(y)*cos(theta_user(x,y)));
end
end
fc=2e9;
lambda=3e8/fc;
PL=3; %pass loss
d0=150;
sigma=3;
beta_BU_dB=-20*log10(lambda/(4*pi*d0))+10*PL*log10(d_U/d0)+sigma*randn(size(d_U));
beta_BU=10.^(-beta_BU_dB/10);
beta_BD_dB=-20*log10(lambda/(4*pi*d0))+10*PL*log10(d_D/d0)+sigma*randn(size(d_D));
beta_BD=10.^(-beta_BD_dB/10);
beta_user_dB=-20*log10(lambda/(4*pi*d0))+10*PL*log10(d_user/d0)+sigma*randn(size(d_user));
beta_user=10.^(-beta_user_dB/10);
h_bb_dB=100;
h_mk=sqrt(beta_BU).*(randn(M,K)+1j*randn(M,K))/sqrt(2);
h_nk=sqrt(beta_BD).*(randn(N,K)+1j*randn(N,K))/sqrt(2);
h_bbk=sqrt(10.^(-h_bb_dB/10))*(randn(1,K)+1j*randn(1,K))/sqrt(2);
for k=1:K
h_user=sqrt(beta_user).*(randn(M,N)+1j*randn(M,N))/sqrt(2);
H(:,:,k)=h_user;
end
%% Initial (Greedy) RB assignments to X and Y.
X_i=zeros(M,K);
G_u=abs(h_mk).^2;
for k=1:K
mm=find(G_u(:,k)==max(G_u(:,k)));
X_i(mm,k)=1;
end
Y_i=zeros(N,K);
G_d=abs(h_nk).^2;
for k=1:K
mm=find(G_d(:,k)==max(G_d(:,k)));
Y_i(mm,k)=1;
end
%% CVX: compute the optimal X and P for FD RBs
opt=[];sum_l=0;delta=1;time=0;
while delta>0.01
f2_i=M*sum(log2(noise+sum(Y_i.*Pd.*(abs(h_bbk).^2),1)))+sum(sum(log2(noise+sum((shiftdim((X_i').*ones(K,M,N),1)).*(shiftdim((Pu').*ones(K,M,N),1)).*(abs(H).^2),1))));
grad_x=squeeze(sum(shiftdim(Pu'.*ones(K,M,N),1).*(abs(H).^2)./(noise+sum(shiftdim(X_i'.*ones(K,M,N),1).*shiftdim(Pu'.*ones(K,M,N),1).*(abs(H).^2),1))/log(2),2));
gradx=reshape(grad_x,1,M*K);
grad_y=M*Pd.*(abs(h_bbk).^2)./(noise+sum(Y_i.*Pd.*(abs(h_bbk).^2),1))./log(2);
grady=reshape(grad_y,1,N*K);
cvx_begin
cvx_solver mosek
variables X(M,K) Y(N,K)
minimize(-(sum(sum( log(noise+repmat(sum(Y.*Pd.*(abs(h_bbk).^2.*ones(N,K)),1),M,1)+X.*Pu.*(abs(h_mk).^2))/log(2) ))+ ...
sum(sum( log(noise+ squeeze(sum(shiftdim(repmat((X.*Pu)',[1,1,N]),1).*(abs(H).^2),1)) +Y.*Pd.*(abs(h_nk).^2))/log(2) )) - ...
(f2_i+gradx*(reshape(X-X_i,1,M*K))'+grady*(reshape(Y-Y_i,1,N*K))')));
subject to
X>=0
X<=1
Y>=0
Y<=1
sum(X,1)<=1
sum(X,2)==1
sum(Y,1)<=1
sum(Y,2)==1
cvx_end
sum_r3=sum(sum(log2(1+(X.*Pu.*(abs(h_mk).^2))./(noise+sum(Y.*Pd.*(abs(h_bbk).^2),1)))))+ ...
sum(sum(log2(1+(Y.*Pd.*(abs(h_nk).^2))./(noise+squeeze(sum(shiftdim((X.*Pu)'.*ones(K,M,N),1).*(abs(H).^2),1))))));
sum_r4=-(sum(sum( log(noise+repmat(sum(Y.*Pd.*(abs(h_bbk).^2.*ones(N,K)),1),M,1)+X.*Pu.*(abs(h_mk).^2))/log(2) ))+ ...
sum(sum( log(noise+ squeeze(sum(shiftdim(repmat((X.*Pu)',[1,1,N]),1).*(abs(H).^2),1)) +Y.*Pd.*(abs(h_nk).^2))/log(2) )) - ...
(f2_i+gradx*(reshape(X-X_i,1,M*K))'+grady*(reshape(Y-Y_i,1,N*K))'));
delta=abs(sum_r3-sum_l);
sum_l=sum_r3;
time=time+1;
if time>50
break;
end
X_i=X;
Y_i=Y;
end