There is something wrong during the optimization process with CVX

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

I check the input of "rate " and "rate_solved ", and test_s=s,test_mu=mu. So why "rate " and "rate_solved " have the same input and expression , but have different outputs

The answer is the same as the previous times I’ve answered your same question.

rateis an expression. In order to reliably have the optimal values of expressions after CVX completes, they must be reconstructed starting from CVX variable values. That is due to a design decision in CVX. CVX could have been designed to automatically do this, but it does not. However, the correct values of the expressions are used internally in performing the optimization.

Thanks for your answer. Can I understand your explanation as follows: Although the value of the expression “rate” is displayed incorrectly, the CVX is still based on the correct expression value of "rate"to get the optimization result, so the optimization result is reliable?
If so, the correct value of “rate” is smaller than R_req_1, which means the last constraint is not satisied. In this case, why the optimization stops?

The optimization problem should be solved correctly. if you want to verify whether constraints are satisfied, within solver tolerance, you should compute each side of the constraint, starting from variable values, not expression values.

I calculate “rate” by using the optimization result “s”(because the only value I can derive is the result), that is “rate_solved”, obviously the balue of “rate_solved” is smaller than “R_req_1”, which means the constraint is not satisfied, what is wrong,? can you give me some advice?:thinking:

Just as shown in my codes, the value of R_req_1 is over 200, but the caculated “rate_solved” is only 20,the last constraint is not satisfied, but the optimization stops and shows “solved”, i donnot know why

I checked, and yes, there is an apparent constraint violation. I believe the constraint “violation” is caused by delt elements being 3e-16, which is way too small to make double precision solvers happy, and havoc ensures in the solution process…

Mosek does warn about near zero elements in the input data. You need to improve the scaling of the model so that there are no very small or large magnitude numbers, otherwise, the results are unreliable, as you have seen.