Different solutions

I have question about CVX. When I ran the example in CVX, which is shown below

clear all
variable x(n)

The solver used is SDPT3, which is default. My question is why the cvx_optval gives a +2.00379, while the answer given in the solver (sdpt3) is −2.00379?

The following is the results if you want to refer to
Calling SDPT3 4.0: 17 variables, 9 equality constraints
   For improved efficiency, SDPT3 is solving the dual problem.

 num. of constraints =  9
 dim. of socp   var  = 17,   num. of socp blk  =  1
   SDPT3: Infeasible path-following algorithms
 version  predcorr  gam  expon  scale_data
    NT      1      0.000   1        0    
it pstep dstep pinfeas dinfeas  gap      prim-obj      dual-obj    cputime
 0|0.000|0.000|1.6e+00|1.4e+00|2.1e+01| 0.000000e+00  0.000000e+00| 0:0:00| chol  1  1 
 1|1.000|1.000|2.8e-06|2.2e-02|2.2e+00|-1.541481e+00 -3.662905e+00| 0:0:01| chol  1  1 
 2|1.000|0.959|5.1e-08|3.0e-03|7.4e-02|-1.961811e+00 -2.021858e+00| 0:0:01| chol  1  1 
 3|0.988|0.988|1.2e-08|2.6e-04|9.0e-04|-2.003281e+00 -2.003023e+00| 0:0:01| chol  1  1 
 4|0.989|0.989|1.0e-08|2.5e-05|9.9e-06|-2.003785e+00 -2.003684e+00| 0:0:01| chol  1  1 
 5|0.990|0.990|1.8e-10|2.6e-07|1.2e-07|-2.003791e+00 -2.003790e+00| 0:0:01| chol  1  1 
 6|0.990|0.990|2.7e-12|2.7e-09|1.4e-09|-2.003791e+00 -2.003791e+00| 0:0:01|
  stop: max(relative gap, infeasibilities) < 1.49e-08
 number of iterations   =  6

primal objective value = -2.00379086e+00

dual   objective value = -2.00379085e+00

gap := trace(XZ)       = 1.43e-09

relative gap           = 2.85e-10
 actual relative gap    = -2.12e-09
 rel. primal infeas (scaled problem)   = 2.68e-12
 rel. dual     "        "       "      = 2.66e-09
 rel. primal infeas (unscaled problem) = 0.00e+00
 rel. dual     "        "       "      = 0.00e+00
 norm(X), norm(y), norm(Z) = 1.4e+00, 2.6e+00, 2.8e+00
 norm(A), norm(b), norm(C) = 1.2e+01, 2.0e+00, 4.5e+00
 Total CPU time (secs)  = 0.59  
 CPU time per iteration = 0.10  
 termination code       =  0
 DIMACS: 2.7e-12  0.0e+00  4.7e-09  0.0e+00  -2.1e-09  2.8e-10

Status: Solved
Optimal value (cvx_optval): +2.00379

The key is this line:

For improved efficiency, SDPT3 is solving the dual problem.

This tells you that CVX is actually sending the dual of your problem to the solver, not the primal version. This dual problem has the same objective value as your primal problem, but it is a maximization. The solver only handles minimizations, so to handle that, the objective function is negated.

The bottom line: your problem is being solved correctly!

Thanks! I am happy now