# Why the solution of CVX does not satisfy the constraint

My code is presented as follow:
K = 6;
N = 15;
Tau_tau = 1.0e-08 * [0.2776 -0.2070 0.3216 0.0490 -0.2884 0.1545 -0.3055 0.1077 -0.1946 -0.2857 0.0664 0.2853 0.1174 0.1340 0.2672;
0.1846 -0.2613 0.0876 -0.3297 0.1671 -0.2954 0.1334 -0.3155 -0.2706 0.1717 0.3267 -0.1724 -0.3120 0.3052 -0.1992];

Tau_q0 = 1.0e-15 * [0.1051 0.0041 0.0021 0.0539 0.0010 0.0307 0.0312 0.0824 0.0261 0.0172 0.0501 0.0610 0.0300 0.0135 0.0025];
Tau_q = diag(Tau_q0);
alpha = 4.9005e-19;
Tau0 = Tau_q-alpha*eye(N);
B = [29.4673,-9.5067;-9.5067,12.5240];

D = 1.0e+09 * [0.0265 0.0177;
-0.5766 -0.7277;
1.9592 0.5338;
0.0092 -0.0618;
-5.8854 3.4102;
0.0512 -0.0978;
-0.0993 0.0434;
0.0131 -0.0385;
-0.0760 -0.1056;
-0.1708 0.1026;
0.0134 0.0658;
0.0471 -0.0285;
0.0398 -0.1056;
0.1032 0.2352;
1.3320 -0.9930];

cvx_solver sedumi
cvx_begin SDP
% cvx_precision best
variable w(N,1);
variable W(N,N);
variable V(2,2);
variable Z(2,2);
minimize (trace(Z));

C = 1/alpha*(diag(w,0)-1/K*W);

subject to
[B-V eye(2,2);eye(2,2) Z] == semidefinite(4);
[V D';D (inv(Tau0)+C)] == semidefinite(2+N);
repmat(1,N,1)'*w == K;
diag(W) == w;
[W w;w' 1] == semidefinite(1+N);

cvx_end
w
Z
K1 = repmat(1,15,1)'w
the result is shown as follows:
The coefficient matrix is not full row rank, numerical problems may occur.
SeDuMi 1.3.4 by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
Split 1 free variables
eqs m = 126, order n = 40, dim = 564, blocks = 4
nnz(A) = 294 + 0, nnz(ADA) = 15156, nnz(L) = 7641
it : b
y gap delta rate t/tP* t/tD* feas cg cg prec
0 : 1.39E+18 0.000
1 : -9.52E+16 6.29E+16 0.000 0.0454 0.9900 0.9900 1.67 1 1 1.1E+17
2 : 9.44E+12 6.12E+12 0.000 0.0001 1.0000 1.0000 1.06 1 1 1.0E+13
3 : 9.44E+05 6.13E+05 0.000 0.0000 1.0000 1.0000 1.00 1 1 1.0E+06
4 : -4.91E+02 4.08E+02 0.000 0.0007 0.9999 0.9999 0.99 1 1 6.7E+02
5 : -7.08E+04 2.44E+01 0.000 0.0599 0.9900 0.9900 -0.80 1 1 4.0E+03
6 : -1.85E+05 1.42E+01 0.000 0.5822 0.9000 0.9000 -0.96 1 1 3.8E+03
7 : -5.68E+05 6.10E+00 0.000 0.4290 0.9000 0.9000 -0.78 1 1 3.0E+03
8 : -2.04E+07 1.50E-01 0.000 0.0246 0.9900 0.9900 -0.97 1 1 2.7E+03
9 : -2.28E+09 1.34E-03 0.000 0.0090 0.9990 0.9990 -1.00 1 1 2.7E+03
10 : -2.55E+11 1.20E-05 0.000 0.0089 0.9990 0.9990 -1.00 1 1 2.7E+03
11 : -2.78E+13 1.07E-07 0.000 0.0089 0.9990 0.9990 -1.00 1 1 2.6E+03
12 : -4.77E+14 5.91E-09 0.000 0.0550 0.9900 0.9900 -0.98 3 3 2.4E+03

iter seconds digits cx by
12 0.1 -0.1 6.1244006392e+13 -4.7716440829e+14
|Ax-b| = 8.3e+03, [Ay-c]_+ = 1.7E+04, |x|= 6.4e+12, |y|= 3.4e+14

## Detailed timing (sec) Pre IPM Post 1.100E-02 5.300E-02 2.002E-03 Max-norms: ||b||=1, ||c|| = 1960976566330032128, Cholesky |add|=2, |skip| = 0, ||L.L|| = 4.46816e+08.

Status: Solved
Optimal value (cvx_optval): +4.77164e+14

w =

85.6975
59.8323
48.8010
71.5193
75.6607
72.7010
67.7167
61.9014
47.7639
63.4847
44.0588
64.4428
72.3493
60.1859
53.9524

K1 =

950.0677
In addition, I’m not sure if the following constraints are correctly represented as the form of CVX

the result of w is not satisfied the constrait(repmat(1,N,1)’*w == K), bring the result of w into the expression repmat(1,N,1)’*w is 950.0677, while K is 6.

You create a semidefinite matrix with some entries of order 1e+9 and the objective value reported is +4.77164e+14 with some variables of similarly large norm and the objective if I see well has coefficients around 1e+20. That suggests everything can go as badly as it likes.

You need to work on the scaling of your problem.

Thank you very much for your reply, why does the coefficient too large affect the solution？