# The confusion about the result of minimizing a l2-norm function minus an affine function

Hi, all

Specifically, I’m trying to solve a problem with the objective function of a l2-norm minus an affine function as follow,
f=||w||_2^2-(a*(y-x))
where w and y are optimization variables, a and x are kown parameters.

My confusion is that the final result is different from the iterative information. As you can see in the following, the iterative information shows that the result would be -2.67. However, the CVX demonstrates that the optimal value is -1.88. So could you please help me to explain this phenomenon? And which is the real optimal value?

I appreciate your kind help!

The following is the iterative information.

## Calling SDPT3 4.0: 1097 variables, 513 equality constraints

num. of constraints = 513
dim. of socp var = 1097, num. of socp blk = 43

SDPT3: Infeasible path-following algorithms

## number of iterations = 35 primal objective value = -2.67312018e+00 dual objective value = -2.67312007e+00 gap := trace(XZ) = 6.42e-08 relative gap = 1.01e-08 actual relative gap = -1.70e-08 rel. primal infeas (scaled problem) = 9.51e-10 rel. dual " " " = 1.09e-10 rel. primal infeas (unscaled problem) = 0.00e+00 rel. dual " " " = 0.00e+00 norm(X), norm(y), norm(Z) = 3.4e+03, 4.0e-01, 5.9e-01 norm(A), norm(b), norm© = 1.1e+04, 1.1e+01, 1.5e+00 Total CPU time (secs) = 1.09 CPU time per iteration = 0.03 termination code = 0 DIMACS: 3.3e-09 0.0e+00 1.5e-10 0.0e+00 -1.7e-08 1.0e-08

Status: Solved
Optimal value (cvx_optval): -1.88714

What happens if you evaluate your objective function at the solution?

CVX performs a variety of transformations on your model before solve it. It’s possible there is some sort of transformation that is modifying the objective function. I would trust CVX’s output over the solvers because of that.

Still, verify as well…

mcg can come along and hopefully expand on/confirm the following.

cvx_optval should be the optimal value of the objective of your problem as entered in CVX. You are seeing the output from the SDPT3 solver solving the problem which CVX provided it. But CVX may have transformed the problem from what you entered, resulting in a different objective function. After solution by the solver, CVX untransforms back to the problem you entered, and cvx_optval is the resulting optimal objective value after this untransformation has been performed by CVX.

Thank you very much for your kind help. What do you mean by “evaluate your objective function at the solution”? To calculate the objective function through the given solutions? If so, that would equal to the value of the cvx_optval.

Yes, take the numeric values of w and y and compute the numeric value of the objective function. We would expect them to match the value of cvx_optval.

Thank you very much for your kind help

@mcg @Mark_L_Stone. Thank you very much for your kind help. I have another problem when solving the same problem. Given some specifical parameters, it will result in the ‘Failed’ status. I tried to change the precision using cvx_precision([1.49e-08,1.49e-08,1.0e-02]). Then it can be solved. However, the precision is too much lower for me. So could you explain for me how this ‘Failed’ happens, and is there any solution to solve this without changing the precision?

## Calling SDPT3 4.0: 1102 variables, 460 equality constraints

num. of constraints = 460
dim. of socp var = 1098, num. of socp blk = 38
dim. of linear var = 4

SDPT3: Infeasible path-following algorithms

## number of iterations = 25 primal objective value = -3.36401349e+00 dual objective value = -3.36175194e+00 gap := trace(XZ) = 1.76e-03 relative gap = 2.27e-04 actual relative gap = -2.93e-04 rel. primal infeas (scaled problem) = 9.07e-11 rel. dual " " " = 3.37e-06 rel. primal infeas (unscaled problem) = 0.00e+00 rel. dual " " " = 0.00e+00 norm(X), norm(y), norm(Z) = 1.9e+03, 8.1e-01, 1.1e+00 norm(A), norm(b), norm© = 1.0e+05, 1.1e+01, 2.5e+00 Total CPU time (secs) = 0.44 CPU time per iteration = 0.02 termination code = -5 DIMACS: 3.2e-10 0.0e+00 4.2e-06 0.0e+00 -2.9e-04 2.3e-04

Status: Failed
Optimal value (cvx_optval): NaN

Try the other solvers in CVX and see if they do a better job. See the documentation—we talk about just these kinds of issues.

Thank you very much!
I have tried the sedumi and scs, but sometimes they also result in ‘Failed’.
Also I have scanned the document, the explanation of the ‘Failed’ status is all about the precision. Is changing the precision the only way to solve this problem?