What is causing the final Status: Inaccurate/Solved? and how can I modify my code to get it Solved?

I can’t figure out why the result I get has status inaccurate/solved.

I have the following optimization problem:

I have formulated the above optimization problem as follows:

K= 2;
N= 2;
NumberOfUsersInSubcarrier (1:N)=0;
NOMA_max = 2;
UE_SCid (1:K) = 0;
R_max = 140;
L = 15 * 10^4;
B_sub = B/N;
z = 10^-28; % effective capacitance coefficient
C = 10^2; % number of CPU cycles required per bit

for i=1:K
CG (i) = complex(randn(1),randn(1))/sqrt(2); % exponential random distribution with mean value 1

for i=1:K
SC_id = randi(N);
while (NumberOfUsersInSubcarrier(SC_id)>=NOMA_max) % each SBS can serve up to NOMA_max_users*N users
SC_id = randi(N);
NumberOfUsersInSubcarrier(SC_id)=NumberOfUsersInSubcarrier(SC_id) + 1;
UE_SCid (i) = SC_id; % save the UE’s subcarrier

variable p(2)
variable l(2)
variable r(2)

minimize sum(z*C^3*pow_p(l,3)/T^2+p*T)

subject to
    r >= (L-l)./(B_sub*T)   % Rate constraint
    p >= 0                  % Power constraint
    l >= 0                  % Local data constraint 1
    l <= L                  % Local data constraint 2

    % MAC contraints
    r(1) <= log(1+p(1)*norm(CG(1))^2)
    r(2) <= log(1+p(2)*norm(CG(2))^2)
    r(1)+r(2) <= log(1+p(1)*norm(CG(1))^2 + p(2)*norm(CG(2))^2)


After running the problem I get the following message result:

>> cvx_code
CVX Warning:
_ Models involving “log” 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: 29 variables, 10 equality constraints_
_ 3 exponentials add 24 variables, 15 equality constraints_
_ Cones | Errors |_
Mov/Act | Centering Exp cone Poly cone | Status
_ 2/ 2 | 7.550e+00 4.276e+00 0.000e+00 | Inaccurate/Solved_
_ 2/ 2 | 2.650e+00 4.322e-01 0.000e+00 | Solved_
_ 2/ 2 | 9.921e-02 6.676e-04 0.000e+00 | Solved_
_ 2/ 2 | 1.059e-02 7.579e-06 0.000e+00 | Solved_
_ 0/ 0 | 1.288e-03 0.000e+00 0.000e+00 | Inaccurate/Solved_
_ 0/ 0 | 1.268e-04 0.000e+00 0.000e+00 | Inaccurate/Solved_
_ 0/ 0 | 1.752e-04 0.000e+00 0.000e+00 | Inaccurate/Solved_
Status: Inaccurate/Solved
Optimal value (cvx_optval): +67.8698

Can someone please help me with what might be the cause of the Inaccurate/Solved status and what should I do in order to reach a solved status?

I think Inaccurate/solved is resulting because of the poor scaling n the problem. In particular ,z = 1e-28 is causing difficulty in the objective function, because it makes the first additive term in the objective function of vastly different order of magnitude than the second term. As a result, the variable l is not well determined numerically to the solver. So as is, the optimal objective value is determined fairly well, but l is not well determined at all.

If z is chosen substantially larger, then the problem becomes better behaved.

Given your use of log, I advise you to follow the advice in CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions . In particular, change the MAC constraints to

r(1) <= -rel_entr(1,1+p(1)*norm(CG(1))^2)
r(2) <= -rel_entr(1,1+p(2)*norm(CG(2))^2)
r(1)+r(2) <= -rel_entr(1,1+p(1)*norm(CG(1))^2 + p(2)*norm(CG(2))^2)

However, this does not fix the Inaccurate/solved issue. You need to change z to do that.

1 Like

You were absolutely right. I have made the changes to the code you recommended and I have also changed the value of z to 10^-16 based on your suggestions and the final status now is always ‘Solved’. Thanks a million!

However I am having another problem which I think is relevant to this topic, therefore I will ask here instead of opening another thread.

The final values of p after the cvx has been solved, are always greater or equal to zero (which has been set as one of the constraint) and the maximum value I have gotten after running my code 1 million times was more or less around 2000. However, after adding another constraint for the maximum value of p:

p <= P_max

where P_max = (zC^3L^3)/(T^2) = 33750000, I thought this constraint could not possibly cause any problems since the value of p always ends up to be significantly lower than that. But instead, now the final status has become:

Status: Failed
Optimal value (cvx_optval): NaN

and the final p values of the failed convex game end up being:

p =

1.0e+07 *


I can’t understand how this constraint is causing the cvx problem to fail, especially since the P_max has been set so high which should not cause any changes at all based on the greatest value of p when no maximum limit constraint has been set. Can someone share some wisdom pleeease?

Large input numbers anywhere in your problem specification can cause problems for the solvers called by CVX. it is true that the theoretical so0lution is unaffected by adding a non-binding constraint to what was the optimal solution, But doing so can cause havoc with solvers. Either use a relatively small magnitude bound constraint, or don;t use a bound constraint at all.

I have a question.
When the problem has good scaling, the ‘log’ is automatically approximated by the solver, e.g., SeDuMi.
Is there possible that the Successive approximation method employed for the ‘log’ function may result in the inaccurate\solved solution?

The the Successive approximation method is unreliable. Poor numerical scaling exacerbates the unreliability.

Always try to have good numerical scaling. If possible, use CVX 2.2 with Mosek 9.x. If Mosek is not available to you, follow the advice in the link in my first post of this thread,

OK. I will have a try.

Hello, I am facing the same problem and I know something wrong with me codes but I could not figured it out how to fix it.
I am trying to reconstruct my object from speckle pattern through cvx optimization .
for i=1:size(S_rand,2)

a=reshape(S_rand(:,i), [520 520]); %% this is my speckles 520*520 matrix 
xlabel('X ');
ylabel('Y ');
title(' Speckle pattern through MMF');


%% cropperd from center 3030
a1=a(1:30,1:30);%% centered cropped speckles 30
30 matrix
xlabel(‘X (\mum)’)
set(gca, ‘FontSize’, 10);
title(’ Centered Cropped Submatrix’);
xlabel(‘X (\mum)’);
ylabel(‘Y (\mum)’);
set(gca, ‘FontSize’, 10);

%% %% for 1objects randomly scattered;
minPositionX = 1;
maxPositionX = 20;
minPositionY = 1;
maxPositionY = 20; % Adjust this value based on your requirements

% Number of objects to scatter randomly
num_objects = 5;

% Generate random positions for the objects
positionsX = randi([minPositionX, maxPositionX], 1, num_objects);
positionsY = randi([minPositionY, maxPositionY], 1, num_objects);

% Initialize the o_test matrix

o_test_1 = zeros(length(a1)); %% my object with 30*30 matrix size

w1 = 1; % Width of the objects
% Loop to place each object at its random position
for i = 1:num_objects
x_position = round((length(a1) -10 - w1) / 2);

o_test_1(x_position : x_position + w1 - 1, positionsY(1)) = 1;


%% speckle*object%%


o_Im_norm_1 = o_Im / max(o_Im(:));

% CVX optimization;
n = size(a1, 2);
m = size(a1, 1);

% Define the known measurements (observed image)

% y = o_Im_norm_1(:); %% this is the change which I made if i use as vector this condition would not satisfy a1 * x_L1 == y but before that speckles I used as vector and cvx works perfectly
y = o_Im_norm_1;

variable x_L1(n m ) %% also made there change instead of (n) ı also add (m) variable because of a1 * x_L1 == y
minimize(norm(x_L1, 1))
subject to
% cvx_check = size(a1 * x_L1(:));

    a1 * x_L1 == y %#ok<NOPTS> 


% Retrieve the reconstructed object

o_rec_L_1 = reshape(x_L1, [m, length(a1)]);

% Display the reconstructed object

Please guide me where Im getting wrong.

Your CVX code looks very strange. It appears that you are constraining the only optimization variable (x_L1) to be equal to input data (y) You are further constraining a1*x_L1 to be equal to that same input data y. Based on that, unless a1 is the Identity matrix (or the scalar “1”, which is an Ideintiy matrix), I don’t see how this problem would even be feasible. And even if if were feasible, there would be no degrees of freedom (only one feasible solution), so the objective function is irrelevant. Am I misreading your code?

As general advice, for a program which makes some sense, if the solver is experiencing difficulties, such as producing a solution CVX reports to be Inaccurate/Solved: Please show all the CVX and solver output. Also, try another solver. if you have Mosek available, try that, as it is the most numerically robust solver, and has the best diagnostics.