# cvx_optval different from opt_val?

Hey,
I am trying to work with the code given below to find optimal values of X. W,Y,k_1,k_2,k_3,h are all positive constants. But the optimal value that I get is not the same as cvx_optval. I would be thankful if you could please tell why this is happening and also suggest ways to remove this error.

cvx_begin quiet

``````cvx_precision best
cvx_solver SDPT3
variable X(1,N)
y = inv_pos(min(W*(log(Y+X)/log(2))-W*(log(Y)/log(2))))*(k_2 + k_3) + k_4;
x = k_1 + (1/N)*sum(inv_pos(W*(log(Y+X)/log(2))-W*(log(Y)/log(2)))) + y ;
minimize x
X >= 0
sum(X) <= 0.01
sum(X.*h) <= 10^-8
``````

cvx_end

For N=5
cvx_optval = 1.2805e-005

X = 0.1718
0.2196
0.1915
0.1977
0.1922

opt_val = 1.4012e-007

There is no way we can diagnose this for you without the actual data. But I’m thinking it is a combination of a) a scaling issue and b) the use of the experimental successive approximation.

By ‘scaling issue’ I mean the fact that your optimal value is close to zero. The solver may very well consider both values to be within tolerance.

The data that I am using and corresponding results are:
Data: k_1 = k_2 =0; W = 6*10^6; Y = 1.0e-007 * [0.1296 0.0798 0.0711 0.0515 0.0432]; k_3 = 0.1427 ; k_4 = 2.6393e-008; RESULT : X = [0.0044 0.0007 0.0007 0.0014 0.0027]; cvx_optval =2.9918e-005 ;opt_val=1.4169e-005

Yeah, I’m pretty sure there’s a scaling issue there. The small values of Y and k_4 are of the same magnitude as the solver’s default tolerance.

The results are only correct for a few set of values even when I have scaled the values to a suitable magnitude.I require it to work for all possible values. Do you think Mosek will work better? Can you plz suggest any other solver ,as SeDuMi and SDPT3 are not giving desired results.

No, sorry. We specifically warn people about the use of log/exp/etc. in models. See here, again.