I wonder why the values of “rate” and “rate_solved” are different, because via the expression variable, I can find that the inputs of “rate” and “rate_solved” are the same. And the error in “rate” will mislead the CVX to satisfy the last constraint and stop optimizing. Is there something wrong with the function “rel_entr” ?
clear all; clc; close all;
M = 4;
N = 5;
L = 8;
K_m = 8;
P_max = 251;
delt = 3e-16*ones(M,K_m,N);
R_req_1 = randi([200,250],M,K_m);
fai =10;
cvx_begin
cvx_solver sdpt3
variable s(M,K_m,N) nonnegative
variable mu(M,K_m,N)
variable P(M,K_m,N)
expression rate(M,K_m)
expression test_s(M,K_m)
minimize(sum(sum(sum(mu)))+ sum(sum(sum(fai*s))));
% Constraints
subject to
%s
0<= s <=1;
for n = 1:N
sum(sum(s(:,:,n)))<= L;
end
for m =1:M
for k = 1:K_m
sum(s(m,k,:)) >= 1;
end
end
%power
sum(sum(sum(mu))) <= P_max;
mu <= P_max.*s;
mu <= P;
mu >= 0;
mu >= P-(1-s).*P_max;
%% 排查一下rel_entr的问题
test_s = s;
test_mu = mu;
for m = 1:M
for k = 1:K_m
rate(m,k) = sum(- rel_entr(s(m,k,:).*delt(m,k,:),s(m,k,:).*delt(m,k,:)+mu(m,k,:).*0.3)./delt(m,k,:)./log(2));
end
end
% 结论:不是因为变量相关,通过观察中间变量,知道了rate代入的s和mu是对的,
rate >= R_req_1;
cvx_end
cvx_clear
cvx_status
for m = 1:M
for k = 1:K_m
rate_solved(m,k) = sum(- rel_entr(test_s(m,k,:).*delt(m,k,:),test_s(m,k,:).*delt(m,k,:)+test_mu(m,k,:).*0.3)./delt(m,k,:)./log(2));
end
end
rate
rate_solved
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
And this is the result:
CVX Warning:
Models involving “rel_entr” or other functions in the log, exp, and entropy
family are solved using an experimental successive approximation method.
This method is slower and less reliable than the method CVX employs for
other models. Please see the section of the user’s guide entitled
The successive approximation method
for more details about the approach, and for instructions on how to
suppress this warning message in the future.
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: 1670 variables, 640 equality constraints
160 exponentials add 1280 variables, 800 equality constraints
Cones | Errors |
Mov/Act | Centering Exp cone Poly cone | Status
--------±--------------------------------±--------
0/ 0 | 0.000e+00 0.000e+00 0.000e+00 | Solved
Status: Solved
Optimal value (cvx_optval): +320
cvx_status =
'Solved'
rate =
1.0e+05 *
5.4928 5.4926 5.4926 5.4929 5.4925 5.4925 5.4929 5.4927
5.4929 5.4928 5.4929 5.4927 5.4929 5.4925 5.4928 5.4926
5.4929 5.4925 5.4925 5.4925 5.4929 5.4929 5.4925 5.4928
5.4929 5.4929 5.4926 5.4928 5.4927 5.4927 5.4925 5.4926
rate_solved =
20.7213 20.7213 20.7213 20.7213 20.7213 20.7213 20.7213 20.7213
20.7213 20.7213 20.7213 20.7213 20.7213 20.7213 20.7213 20.7213
20.7213 20.7213 20.7213 20.7213 20.7213 20.7213 20.7213 20.7213
20.7213 20.7213 20.7213 20.7213 20.7213 20.7213 20.7213 20.7213