The accuracy of "pow_p"

I have a constraint which has a part A1 = A^{-\alpha/2} , where \alpha = 3.4,
and I express it as A1 = pow_p( A, (-alpha/2) ).

The problem is solved by CVX and A=89.5139 , A1=3.8990*1e4.

A=89.5139 is reasonable for my problem.
Then, I calculate A1 with A=89.5139. A1=A^{-\alpha/2}=89^{-3.4/2}=4.8533

Therefore, I think the solution to A1 is incorrect.

Please show the complete program, together with all CVX and solver output. if you can include all the input data, that would be even better.

I would think it is the usual suspect: after optimization only variables have the correct values, while expressions do not, and have to be recomputed from the variables, just like you did. But since there is no reproducible code it is just a guess. You have also lost some 1e-4 in your final answer, I think.

1 Like

Part of the CVX code:

cvx_begin
cvx_solver MOSEK

variable ...
variable A2(1,N)
variable A3(1,N)
variable se(1,N)

expression ...
expression A2_p(Uk,N)
expression R4(1,N)

for n=1:N
A2_p(n) = pow_p(A2(n),-alpha/2);
end
for n=1:N
R4(n) = pow_pos(  A2_p(n) + inv_pos(A3(n)),2) ;
end
for n=1:N
se(n) >= pow_p(A2(n),-alpha) + pow_p(A3(n),-2) + 2*R4(n) ;
end

cvx_end



solver output: A2, A2_p

As per @Michal_Adamaszek 's post, after cvx_end, CVX variables are populated with their optimal values, but CVX expressions are not necessarily populated with their optimal values. So to get the optimal values of CVX expressions, you need to compute them after cvx_end, starting with the CVX optimal variable values.

However, the optimization is performed correctly even though the populated values for the expressions might not be correct.

But the value of the expression would affect other variableâs value.
The expression A1 is in a constrain.
Yes, some 1e-4 are 1e+4 (exprssion A1),and other variable has a larger value too(comparing to the normal value).

As I said, the optimization is done correctly, accounting for all dependencies. The optimal variable values and optimal objective value should all be correct. This purely relates to a CVX design decision to not make a final pass to update the population of CVX expressions. .Had it been designed to do so, the CVX calculations would take a little longer to run, and there would have been many fewer threads like this on the forum. The CVX Usersâ Guide should have made this clearer, but doesnât.

1 Like

I also have another question. Should we ignore that the variable se[n] has an abnormal value?

What do you mean by âabnormal valueâ? se is declared a variable, so after cvx_end, it should be populated with its optimal value, provided CVX reports the problem as being solved to optimality.

Thank you for your patience very much.

"abnormal value"
The first loop: se[n] has some value of (1e+12). but it is expected [0,100]
The second loop: se[n] is in the [0,100].

For example, if I optimize trajectory q[2,N], the optimal values of q and optimal objective value are both correct. The problem is solved even though expression or slack variable do not.

I donât know what your âloopsâ are. Are you solving a series of different CVX problems? The code you showed does not show that.

The portion of the code you showed would allow optimal se(n) in the range [minim_optimal_value,Inf], which would make se rather meaningless. So I presume there is additional code you havenât shown for the objective function and/or other constraints - but I have no idea what that code is.

The âloopâ is the while-loop of main-function.
No, I donât solve a series of different problem.

Yes, I only show you the constraint and expression about A2_p.

$main(): count = 0; R = 1000*ones(1,30); while(1){ count += 1; t = optimize_q (para); R(count) = R_cal(para); if( abs(R(count) - R(count)) <1e-4 && count != 1) { break; } }$ function optimize_q (para), Solver is MOSEK

CVX_begin

variable q(2,N)
variable t nonnegative
variable ze(Uk,N)
variable se(1,N)
variable A2(1,N)
variable A3(1,N)

expression A2_p(1,N)
expression R4(1,N)
expression Re(Uk,N)

for n=1:N
A2_p(n) = pow_p(A2(n),alpha);
R4(n) =pow_pos(  A2_p(n)+inv_pos(A3(n)), 2 ) ;
end

for n=1:N
for k=1:Uk
Re(k,n) = rel_entr( ze(k,n)/P(k,n),1+(ze(k,n)/P(k,n)) ) +rel_entr( 1+(ze(k,n)/P(k,n)),ze(k,n)/P(k,n) );
end
end

maximize t

subject to
for k=1:Uk
-sum(Re(k,:)) >= t;
end
for n=1:N
for k=1:Uk
ze(k,n) <=  2/se_f(n) - se(n)/(se_f(n)^2) ;
end
end
for n=1:N
se(n)>=  pow_p(A2(n),-alpha) +  pow_p(A3(n),-2) + 2* R4(n) ;
pow_pos(A3(n),2) <= power(norm(q_f(:,n)-q1(:)),2) + 2*(q_f(:,n)-q1(:))'*(q(:,n)-q_f(:,n)) + H3^2 ;
pow_pos(A2(n),2) <= power(norm(q_f(:,n)-q2(:)),2) + 2*(q_f(:,n)-q2(:))'*(q(:,n)-q_f(:,n)) + H2^2;
end

CVX_end


You havenât explained why the optimal solution is âabnormalâ. Do you have a compelling mathematical argument as for why the solution is abnormal? The readers of this forum are not knowledgeable in your model and application, so thinks which might be obvious (correctly or not) to you may not be to the forum readers.

âabnormalâ: se[n] has some value of (1e+12). but it is expected 0 <se[n]<100

When I get the CVX result, I checked my variable(including slack variable) and found some abnormal value. Then, I checked every expression to try to find where was the error.
And I found the value of pow_p(X,-3.4) is not correct. So I want to know why the doubt the accuracy of pow_p(X,3.4) .

But Mr.MIchal_Adamaszek and you have replied it for the âpow_pâ, and I understand it. As for the some abnormal value of pow_p, there may be still some error about my code I think.

You havenât provided a compelling mathematical argument as to why it is expected 0<se[n]<100. Perhaps your expectation is misplaced relative to your model and input data The forum readers are not knowledgeable in your model and application, so they donât necessarily share your expectation as to the âcorrectâ value of se.

If you constrain se to be less than (or equal to) 100, and the optimal objective value is lower (worse) than the optimal objective value of your current model, that would show you that it indeed would not be optimal in your current model for se to be less than 100. If the optimal objective value is the sane, that shows, at least for this particular input data, that the additional constraint se <= 100 can be imposed âfor freeâ, in the sense that it doesnât hurt the optimal objective value.