# How to check the answer when the sdp programming is solved by mosek

I solved my semidefinite programming by mosek and use lots of constraints. They are about n / 2 semidefinite constraints with n around 30 and thousands of linear constraints.
After solving that, the solver told me the STATUS is solved and provided a nice answer. But now, I am wondering the correctness of the answer and try to check it by figuring out all primal and dual constraints to ensure the answer is optimal.
How could I do for this?
Here is one of my result.

## Calling Mosek 9.1.9: 27336 variables, 1442 equality constraints For improved efficiency, Mosek is solving the dual problem.

MOSEK Version 9.1.9 (Build date: 2019-11-21 11:34:40)
Platform: Windows/64-X86

MOSEK warning 52: A numerically large lower bound value -1.3e+08 is specified for constraint ‘’ (0).
MOSEK warning 53: A numerically large upper bound value -1.3e+08 is specified for constraint ‘’ (0).
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 1442
Cones : 0
Scalar variables : 6689
Matrix variables : 14
Integer variables : 0

Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator started.
Freed constraints in eliminator : 284
Eliminator terminated.
Eliminator - tries : 2 time : 0.00
Lin. dep. - tries : 1 time : 0.02
Lin. dep. - number : 0
Presolve terminated. Time: 0.08
Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 1442
Cones : 0
Scalar variables : 6689
Matrix variables : 14
Integer variables : 0

Optimizer - solved problem : the primal
Optimizer - Constraints : 409
Optimizer - Cones : 1
Optimizer - Scalar variables : 1292 conic : 371
Optimizer - Semi-definite variables: 14 scalarized : 20647
Factor - setup time : 0.01 dense det. time : 0.00
Factor - ML order time : 0.00 GP order time : 0.00
Factor - nonzeros before factor : 4.55e+04 after factor : 6.03e+04
Factor - dense dim. : 2 flops : 2.17e+07
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 1.9e+00 1.0e+00 2.0e+00 0.00e+00 1.000000000e+00 0.000000000e+00 1.0e+00 0.13
1 1.6e+00 8.2e-01 1.8e+00 -2.66e-01 1.175428946e+00 3.378814873e-01 8.2e-01 0.33
2 9.6e-01 5.0e-01 1.4e+00 -4.30e-01 1.884709630e+00 1.664163271e+00 5.0e-01 0.34
3 2.2e-01 1.1e-01 7.6e-01 -7.67e-01 1.107722909e+01 1.925567650e+01 1.1e-01 0.38
4 3.5e-02 1.8e-02 4.1e-01 -1.26e+00 1.252747523e+02 2.461352726e+02 1.8e-02 0.39
5 5.2e-03 2.7e-03 1.6e-01 -1.23e+00 9.351506857e+02 1.863989678e+03 2.7e-03 0.41
6 9.6e-04 5.0e-04 6.8e-02 -1.15e+00 5.213633755e+03 9.856640440e+03 5.0e-04 0.42
7 4.8e-04 2.5e-04 6.5e-03 4.01e-01 6.950408531e+03 7.117574678e+03 2.5e-04 0.45
8 1.6e-04 8.1e-05 1.5e-03 1.08e+00 5.557091035e+03 5.644764620e+03 8.1e-05 0.47
9 9.4e-05 4.9e-05 8.0e-04 1.71e+00 4.273216562e+03 4.340881298e+03 4.9e-05 0.48
10 3.0e-05 1.5e-05 1.6e-04 1.77e+00 3.625480516e+03 3.652738907e+03 1.5e-05 0.52
11 1.6e-05 8.4e-06 6.1e-05 1.37e+00 3.432214778e+03 3.445428180e+03 8.4e-06 0.53
12 6.7e-06 3.5e-06 1.3e-05 1.66e+00 3.281632721e+03 3.285215331e+03 3.5e-06 0.55
13 5.1e-06 2.7e-06 8.3e-06 1.58e+00 3.235757321e+03 3.238144462e+03 2.7e-06 0.58
14 1.3e-06 6.8e-07 8.4e-07 1.50e+00 3.185035440e+03 3.185415300e+03 6.8e-07 0.59
15 5.3e-07 2.7e-07 1.9e-07 1.41e+00 3.175260609e+03 3.175374120e+03 2.7e-07 0.61
16 1.4e-07 7.3e-08 1.7e-08 1.44e+00 3.171203561e+03 3.171217118e+03 7.3e-08 0.63
17 7.2e-08 3.7e-08 5.5e-09 1.52e+00 3.170505129e+03 3.170510531e+03 3.7e-08 0.66
18 1.8e-08 9.0e-09 5.6e-10 1.33e+00 3.170105230e+03 3.170106213e+03 9.0e-09 0.67
19 8.0e-09 2.5e-09 7.4e-11 1.16e+00 3.170027167e+03 3.170027387e+03 2.5e-09 0.69
20 3.3e-09 1.0e-09 1.8e-11 1.16e+00 3.170010515e+03 3.170010592e+03 1.0e-09 0.73
21 2.3e-09 7.2e-10 9.9e-12 1.28e+00 3.170006704e+03 3.170006751e+03 7.2e-10 0.78
22 1.2e-09 3.6e-10 3.1e-12 1.27e+00 3.170002969e+03 3.170002987e+03 3.6e-10 0.81
23 6.4e-10 2.1e-10 1.2e-12 1.27e+00 3.170001542e+03 3.170001551e+03 2.1e-10 0.86
24 3.1e-10 1.0e-10 3.9e-13 1.24e+00 3.170000703e+03 3.170000707e+03 1.0e-10 0.91
25 9.1e-11 3.1e-11 5.9e-14 1.19e+00 3.170000198e+03 3.170000199e+03 3.1e-11 0.94
Optimizer terminated. Time: 1.03

Interior-point solution summary
Problem status : PRIMAL_AND_DUAL_FEASIBLE
Solution status : OPTIMAL
Primal. obj: 3.1700001978e+03 nrm: 4e+09 Viol. con: 6e-01 var: 4e+03 barvar: 0e+00
Dual. obj: 3.1700001987e+03 nrm: 3e+03 Viol. con: 0e+00 var: 5e-10 barvar: 5e-09
Optimizer summary
Optimizer - time: 1.03
Interior-point - iterations : 25 time: 0.95
Basis identification - time: 0.00
Primal - iterations : 0 time: 0.00
Dual - iterations : 0 time: 0.00
Clean primal - iterations : 0 time: 0.00
Clean dual - iterations : 0 time: 0.00
Simplex - time: 0.00
Primal simplex - iterations : 0 time: 0.00
Dual simplex - iterations : 0 time: 0.00
Mixed integer - relaxations: 0 time: 0.00

Status: Solved
Optimal value (cvx_optval): +3170

Let us assume you have the constraint

x+z \leq1

then you check the solution satisfies this constraint. Similarly you can check whether the solution satisfies your constraints.

Assume Cvx could do it for you. How can you be sure that the Cvx check is correct then?
To conclude you must be able to check independently of Cvx.

On top of that you check whether the solution make sense for the problem at hand.

You already have the primal problem because that is your cvx formulation, so checking primal feasibility is easy. You dualize it by hand, get the correct duals from cvx, and then check all the rest.

Unless your model has some horrible numerical properties, what you will get should be of similar orders of violation as what you see in the MOSEK solution summary.

By the way the primal violations shown by MOSEK are quite large so you may expect the same from the dual violations in your cvx model. Surely having coefficients of order 1e+8 in the model degrades numerical stability so you could work on that first. The huge norm could indicate your problem is borderline infeasible/unbounded or some other borderline illposedness like that. That is also bad.