Section 4.5.4: Frobenius norm diagonal scaling (GP)

% Boyd & Vandenberghe "Convex Optimization"
% Joelle Skaf - 01/29/06
% Updated to use GP mode by Almir Mutapcic 02/08/06
%
% Given a square matrix M, the goal is to find a vector (with dii > 0)
% such that ||DMD^{-1}||_F is minimized, where D = diag(d).
% The problem can be cast as an unconstrained geometric program:
%           minimize sqrt( sum_{i,j=1}^{n} Mij^2*di^2/dj^2 )
%

rs = randn( 'state' );
randn( 'state', 0 );

% matrix size (M is an n-by-n matrix)
n = 4;
M = randn(n,n);

% formulating the problem as a GP
cvx_begin gp
  variable d(n)
  minimize( sqrt( sum( sum( diag(d.^2)*(M.^2)*diag(d.^-2) ) ) ) )
  % Alternate formulation: norm( diag(d)*abs(M)*diag(1./d), 'fro' )
cvx_end

% displaying results
D = diag(d);
disp('The matrix D that minimizes ||DMD^{-1}||_F is: ');
disp(D);
disp('The minimium Frobenius norm achieved is: ');
disp(norm(D*M*inv(D),'fro'));
disp('while the Frobunius norm of the original matrix M is: ');
disp(norm(M,'fro'));
 
Calling SeDuMi: 373 variables (5 free), 209 equality constraints
------------------------------------------------------------------------
SeDuMi 1.1 by AdvOL, 2005 and Jos F. Sturm, 1998, 2001-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
Split 5 free variables
eqs m = 209, order n = 139, dim = 619, blocks = 17
nnz(A) = 656 + 0, nnz(ADA) = 2977, nnz(L) = 1609
 it :     b*y       gap    delta  rate   t/tP*  t/tD*   feas cg cg  prec
  0 :            2.12E-001 0.000
  1 : -3.22E-001 1.01E-001 0.000 0.4779 0.9000 0.9000   2.78  1  1  1.5E+000
  2 :  2.63E+000 3.08E-002 0.000 0.3041 0.9000 0.9000   3.13  1  1  1.6E-001
  3 :  1.63E+000 1.09E-002 0.000 0.3548 0.9000 0.9000   1.48  1  1  5.3E-002
  4 :  1.33E+000 3.57E-003 0.000 0.3264 0.9000 0.9000   1.25  1  1  1.6E-002
  5 :  1.23E+000 1.01E-003 0.000 0.2845 0.9000 0.9000   1.22  1  1  4.4E-003
  6 :  1.19E+000 2.30E-004 0.000 0.2270 0.9000 0.9000   1.17  1  1  9.2E-004
  7 :  1.18E+000 5.12E-005 0.000 0.2222 0.9000 0.9000   1.10  1  1  1.9E-004
  8 :  1.18E+000 1.20E-005 0.000 0.2341 0.9000 0.9000   1.05  1  1  4.4E-005
  9 :  1.18E+000 2.73E-007 0.000 0.0228 0.9000 0.4205   1.02  1  1  1.4E-005
 10 :  1.18E+000 2.34E-008 0.000 0.0855 0.8832 0.9900   1.01  1  1  1.3E-006
 11 :  1.18E+000 1.52E-009 0.213 0.0650 0.9450 0.9474   1.00  1  2  1.0E-007
 12 :  1.18E+000 4.30E-010 0.115 0.2835 0.9000 0.7281   1.00  2  3  2.9E-008
 13 :  1.18E+000 2.77E-011 0.265 0.0644 0.9900 0.9900   1.00  2  3  1.9E-009

iter seconds digits       c*x               b*y
 13      0.2   Inf  1.1796360860e+000  1.1796360870e+000
|Ax-b| =  3.8e-008, [Ay-c]_+ =  5.7E-010, |x|= 2.6e+001, |y|= 1.7e+000

Detailed timing (sec)
   Pre          IPM          Post
0.000E+000    2.003E-001    0.000E+000    
Max-norms: ||b||=1.164207e+001, ||c|| = 5.000000e-001,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 122.795.
------------------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +3.25319
The matrix D that minimizes ||DMD^{-1}||_F is: 
    0.9742         0         0         0
         0    0.8179         0         0
         0         0    0.8731         0
         0         0         0    1.4585

The minimium Frobenius norm achieved is: 
    3.2523

while the Frobunius norm of the original matrix M is: 
    3.6126