Exercise 4.27: Matrix fractional minimization using second-order cone programming
randn('state',0);
m = 16; n = 8;
A = randn(m,n);
b = randn(m,1);
B = randn(m,n);
disp('Computing optimal solution for 1st formulation...');
cvx_begin
variable x1(n)
minimize( matrix_frac(A*x1 + b , eye(m) + B*diag(x1)*B') )
x1 >= 0;
cvx_end
opt1 = cvx_optval;
disp('Computing optimal solution for 2nd formulation...');
cvx_begin
variable x2(n)
variable Y(n,n) diagonal
minimize( matrix_frac(A*x2 + b , eye(m) + B*Y*B') )
x2 >= 0;
Y == diag(x2);
cvx_end
opt2 = cvx_optval;
disp('Computing optimal solution for 3rd formulation...');
cvx_begin
variables x3(n) w(n) v(m)
minimize( square_pos(norm(v)) + matrix_frac(w, diag(x3)) )
v + B*w == A*x3 + b;
x3 >= 0;
cvx_end
opt3 = cvx_optval;
disp('Computing optimal solution for 4th formulation...');
cvx_begin
variables x4(n) w(n) v(m)
variable Y(n,n) diagonal
minimize( square_pos(norm(v)) + matrix_frac(w, Y) )
v + B*w == A*x4 + b;
x4 >= 0;
Y == diag(x4);
cvx_end
opt4 = cvx_optval;
disp('------------------------------------------------------------------------');
disp('The optimal value for each of the 4 formulations is: ');
[opt1 opt2 opt3 opt4]
disp('They should be equal!')
Computing optimal solution for 1st formulation...
Calling sedumi: 161 variables, 9 equality constraints
For improved efficiency, sedumi is solving the dual problem.
------------------------------------------------------------
SeDuMi 1.21 by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 9, order n = 26, dim = 298, blocks = 2
nnz(A) = 1225 + 0, nnz(ADA) = 81, nnz(L) = 45
it : b*y gap delta rate t/tP* t/tD* feas cg cg prec
0 : 3.39E+01 0.000
1 : -2.62E+00 9.95E+00 0.000 0.2932 0.9000 0.9000 1.31 1 1 1.2E+01
2 : -3.95E+00 3.75E+00 0.000 0.3767 0.9000 0.9000 1.25 1 1 4.0E+00
3 : -4.65E+00 1.03E+00 0.000 0.2736 0.9000 0.9000 1.25 1 1 9.4E-01
4 : -4.97E+00 3.95E-01 0.000 0.3851 0.9000 0.9000 0.95 1 1 3.8E-01
5 : -5.14E+00 8.42E-02 0.000 0.2131 0.9000 0.9000 1.01 1 1 8.1E-02
6 : -5.18E+00 6.78E-03 0.093 0.0806 0.9900 0.9900 1.02 1 1 6.4E-03
7 : -5.18E+00 2.58E-04 0.363 0.0381 0.9901 0.9900 1.00 1 1 2.8E-04
8 : -5.18E+00 1.09E-05 0.251 0.0421 0.9000 0.0000 1.00 1 1 5.8E-05
9 : -5.18E+00 8.97E-07 0.000 0.0824 0.9121 0.9000 1.00 1 1 6.7E-06
10 : -5.18E+00 1.19E-07 0.000 0.1321 0.9097 0.9000 1.00 1 1 9.9E-07
11 : -5.18E+00 1.97E-08 0.000 0.1665 0.9111 0.9000 1.00 1 1 1.8E-07
12 : -5.18E+00 1.16E-09 0.000 0.0588 0.9901 0.9900 1.00 1 1 1.1E-08
iter seconds digits c*x b*y
12 0.0 Inf -5.1824773412e+00 -5.1824772176e+00
|Ax-b| = 5.4e-09, [Ay-c]_+ = 1.9E-08, |x|= 6.9e+00, |y|= 5.2e+00
Detailed timing (sec)
Pre IPM Post
1.000E-02 5.000E-02 0.000E+00
Max-norms: ||b||=1, ||c|| = 2.976981e+00,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 204.898.
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +5.18248
Computing optimal solution for 2nd formulation...
Calling sedumi: 161 variables, 9 equality constraints
For improved efficiency, sedumi is solving the dual problem.
------------------------------------------------------------
SeDuMi 1.21 by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 9, order n = 26, dim = 298, blocks = 2
nnz(A) = 1225 + 0, nnz(ADA) = 81, nnz(L) = 45
it : b*y gap delta rate t/tP* t/tD* feas cg cg prec
0 : 3.39E+01 0.000
1 : -2.62E+00 9.95E+00 0.000 0.2932 0.9000 0.9000 1.31 1 1 1.2E+01
2 : -3.95E+00 3.75E+00 0.000 0.3767 0.9000 0.9000 1.25 1 1 4.0E+00
3 : -4.65E+00 1.03E+00 0.000 0.2736 0.9000 0.9000 1.25 1 1 9.4E-01
4 : -4.97E+00 3.95E-01 0.000 0.3851 0.9000 0.9000 0.95 1 1 3.8E-01
5 : -5.14E+00 8.42E-02 0.000 0.2131 0.9000 0.9000 1.01 1 1 8.1E-02
6 : -5.18E+00 6.78E-03 0.093 0.0806 0.9900 0.9900 1.02 1 1 6.4E-03
7 : -5.18E+00 2.58E-04 0.363 0.0381 0.9901 0.9900 1.00 1 1 2.8E-04
8 : -5.18E+00 1.09E-05 0.251 0.0421 0.9000 0.0000 1.00 1 1 5.8E-05
9 : -5.18E+00 8.97E-07 0.000 0.0824 0.9121 0.9000 1.00 1 1 6.7E-06
10 : -5.18E+00 1.19E-07 0.000 0.1321 0.9097 0.9000 1.00 1 1 9.9E-07
11 : -5.18E+00 1.97E-08 0.000 0.1665 0.9111 0.9000 1.00 1 1 1.8E-07
12 : -5.18E+00 1.16E-09 0.000 0.0588 0.9901 0.9900 1.00 1 1 1.1E-08
iter seconds digits c*x b*y
12 0.1 Inf -5.1824773412e+00 -5.1824772176e+00
|Ax-b| = 5.4e-09, [Ay-c]_+ = 1.9E-08, |x|= 6.9e+00, |y|= 5.2e+00
Detailed timing (sec)
Pre IPM Post
1.000E-02 5.000E-02 0.000E+00
Max-norms: ||b||=1, ||c|| = 2.976981e+00,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 204.898.
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +5.18248
Computing optimal solution for 3rd formulation...
Calling sedumi: 74 variables, 20 equality constraints
For improved efficiency, sedumi is solving the dual problem.
------------------------------------------------------------
SeDuMi 1.21 by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 20, order n = 23, dim = 112, blocks = 4
nnz(A) = 286 + 0, nnz(ADA) = 360, nnz(L) = 190
it : b*y gap delta rate t/tP* t/tD* feas cg cg prec
0 : 1.66E+00 0.000
1 : -1.32E+00 8.85E-01 0.000 0.5315 0.9000 0.9000 0.91 1 1 4.6E+00
2 : -2.73E+00 2.42E-01 0.000 0.2730 0.9000 0.9000 1.35 1 1 9.9E-01
3 : -4.09E+00 6.38E-02 0.000 0.2641 0.9000 0.9000 1.12 1 1 2.4E-01
4 : -4.85E+00 1.73E-02 0.000 0.2718 0.9000 0.9000 0.98 1 1 6.7E-02
5 : -5.11E+00 3.61E-03 0.000 0.2081 0.9000 0.9000 1.01 1 1 1.4E-02
6 : -5.17E+00 5.15E-04 0.000 0.1428 0.9008 0.9000 0.99 1 1 2.4E-03
7 : -5.18E+00 3.16E-05 0.000 0.0613 0.9000 0.8620 1.00 1 1 4.7E-04
8 : -5.18E+00 3.74E-06 0.000 0.1183 0.9451 0.9450 1.00 1 1 5.6E-05
9 : -5.18E+00 6.82E-07 0.000 0.1823 0.9009 0.9000 1.00 1 1 1.0E-05
10 : -5.18E+00 1.34E-07 0.172 0.1968 0.9029 0.9000 1.00 1 1 2.0E-06
11 : -5.18E+00 2.63E-08 0.186 0.1959 0.9049 0.9000 1.00 1 1 4.1E-07
12 : -5.18E+00 5.15E-09 0.171 0.1961 0.9030 0.9000 1.00 1 1 8.0E-08
13 : -5.18E+00 1.01E-09 0.178 0.1961 0.9004 0.9000 1.00 1 1 1.6E-08
14 : -5.18E+00 1.99E-10 0.216 0.1966 0.9000 0.9014 1.00 2 2 3.1E-09
iter seconds digits c*x b*y
14 0.1 Inf -5.1824773990e+00 -5.1824773889e+00
|Ax-b| = 3.7e-09, [Ay-c]_+ = 2.5E-09, |x|= 1.2e+01, |y|= 4.9e+00
Detailed timing (sec)
Pre IPM Post
0.000E+00 9.000E-02 0.000E+00
Max-norms: ||b||=1, ||c|| = 1.488490e+00,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 43.1756.
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +5.18248
Computing optimal solution for 4th formulation...
Calling sedumi: 74 variables, 20 equality constraints
For improved efficiency, sedumi is solving the dual problem.
------------------------------------------------------------
SeDuMi 1.21 by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 20, order n = 23, dim = 112, blocks = 4
nnz(A) = 286 + 0, nnz(ADA) = 360, nnz(L) = 190
it : b*y gap delta rate t/tP* t/tD* feas cg cg prec
0 : 1.66E+00 0.000
1 : -1.32E+00 8.85E-01 0.000 0.5315 0.9000 0.9000 0.91 1 1 4.6E+00
2 : -2.73E+00 2.42E-01 0.000 0.2730 0.9000 0.9000 1.35 1 1 9.9E-01
3 : -4.09E+00 6.38E-02 0.000 0.2641 0.9000 0.9000 1.12 1 1 2.4E-01
4 : -4.85E+00 1.73E-02 0.000 0.2718 0.9000 0.9000 0.98 1 1 6.7E-02
5 : -5.11E+00 3.61E-03 0.000 0.2081 0.9000 0.9000 1.01 1 1 1.4E-02
6 : -5.17E+00 5.15E-04 0.000 0.1428 0.9008 0.9000 0.99 1 1 2.4E-03
7 : -5.18E+00 3.16E-05 0.000 0.0613 0.9000 0.8620 1.00 1 1 4.7E-04
8 : -5.18E+00 3.74E-06 0.000 0.1183 0.9451 0.9450 1.00 1 1 5.6E-05
9 : -5.18E+00 6.82E-07 0.000 0.1823 0.9009 0.9000 1.00 1 1 1.0E-05
10 : -5.18E+00 1.34E-07 0.172 0.1968 0.9029 0.9000 1.00 1 1 2.0E-06
11 : -5.18E+00 2.63E-08 0.186 0.1959 0.9049 0.9000 1.00 1 1 4.1E-07
12 : -5.18E+00 5.15E-09 0.171 0.1961 0.9030 0.9000 1.00 1 1 8.0E-08
13 : -5.18E+00 1.01E-09 0.178 0.1961 0.9004 0.9000 1.00 1 1 1.6E-08
14 : -5.18E+00 1.99E-10 0.216 0.1966 0.9000 0.9014 1.00 2 2 3.1E-09
iter seconds digits c*x b*y
14 0.1 Inf -5.1824773990e+00 -5.1824773889e+00
|Ax-b| = 3.7e-09, [Ay-c]_+ = 2.5E-09, |x|= 1.2e+01, |y|= 4.9e+00
Detailed timing (sec)
Pre IPM Post
1.000E-02 8.000E-02 0.000E+00
Max-norms: ||b||=1, ||c|| = 1.488490e+00,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 43.1756.
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +5.18248
------------------------------------------------------------------------
The optimal value for each of the 4 formulations is:
ans =
5.1825 5.1825 5.1825 5.1825
They should be equal!