Exercise 4.38(b): Linear matrix inequalities with one variable

% From Boyd & Vandenberghe, "Convex Optimization"
% Joëlle Skaf - 09/26/05
%
% Finds the optimal t that would maximize c*t while still having A - t*B
% positive semidefinite by solving the following SDP:
%           minimize    c*t
%               s.t.    t*B <= A
% c can either be a positive or negative real number

% Generate input data
randn('state',0);
n = 4;
A = randn(n); A = 0.5*(A'+A); %A = A'*A;
B = randn(n); B = B'*B;
% can modify the value of c (>0 or <0)
c = -1;

% Create and solve the model
cvx_begin sdp
    variable t
    minimize ( c*t )
    A >= t * B;
cvx_end

% Display results
disp('------------------------------------------------------------------------');
disp('The optimal t obtained is');
disp(t);
 
Calling SeDuMi: 11 variables (1 free), 10 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 1 free variables
eqs m = 10, order n = 7, dim = 19, blocks = 2
nnz(A) = 30 + 0, nnz(ADA) = 100, nnz(L) = 55
 it :     b*y       gap    delta  rate   t/tP*  t/tD*   feas cg cg  prec
  0 :            3.07E+000 0.000
  1 :  2.85E+000 5.77E-001 0.000 0.1879 0.9000 0.9000  -0.13  1  1  1.8E+000
  2 :  1.04E+001 1.11E-001 0.000 0.1923 0.9000 0.9000  -0.24  1  1  1.2E+000
  3 :  7.35E+001 6.93E-003 0.000 0.0625 0.9900 0.9900  -0.68  1  1  5.5E-001
  4 :  6.79E+001 6.76E-004 0.000 0.0974 0.9900 0.9900   0.03  1  1  8.8E-002
  5 :  4.84E+001 6.55E-006 0.000 0.0097 0.9990 0.9990   1.02  1  1  8.3E-004
  6 :  4.84E+001 4.86E-007 0.000 0.0742 0.9000 0.7177   1.00  1  1  2.3E-004
  7 :  4.84E+001 9.20E-008 0.000 0.1892 0.9000 0.9032   1.00  1  2  4.1E-005
  8 :  4.84E+001 3.01E-009 0.000 0.0328 0.9813 0.9900   1.00  2  2  1.8E-006
  9 :  4.84E+001 6.70E-010 0.000 0.2224 0.9000 0.9000   1.00  2  2  4.1E-007
 10 :  4.84E+001 3.58E-011 0.000 0.0534 0.9900 0.9900   1.00  2  3  2.2E-008
 11 :  4.84E+001 3.38E-012 0.438 0.0945 0.9900 0.9900   1.00  3  3  2.1E-009

iter seconds digits       c*x               b*y
 11      0.1   Inf  4.8354031400e+001  4.8354031573e+001
|Ax-b| =  7.6e-010, [Ay-c]_+ =  1.0E-009, |x|= 5.4e+002, |y|= 1.4e+002

Detailed timing (sec)
   Pre          IPM          Post
0.000E+000    5.007E-002    0.000E+000    
Max-norms: ||b||=1.406028e+000, ||c|| = 1,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 177.293.
------------------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +48.354
------------------------------------------------------------------------
The optimal t obtained is
  -48.3540