% Boyd & Vandenberghe "Convex Optimization"
% JoÃ«lle Skaf - 04/24/08
%
% Suppose y \in\reals^n is a Gaussian random variable with zero mean and
% covariance matrix R = \Expect(yy^T). We want to estimate the covariance
% matrix R based on N independent samples y1,...,yN drawn from the
% distribution, and using prior knowledge about R (lower and upper bounds
% on R)
%           L <= R <= U
% Let S be R^{-1}. The maximum likelihood (ML) estimate of S is found
% by solving the problem
%           maximize    logdet(S) - tr(SY)
%           subject to  U^{-1} <= S <= L^{-1}
% where Y is the sample covariance of y1,...,yN.

% Input data
randn('state',0);
n = 10;
N = 1000;
tmp = randn(n);
L = tmp*tmp';
tmp = randn(n);
U = L + tmp*tmp';
R = (L+U)/2;
y_sample = sqrtm(R)*randn(n,N);
Y = cov(y_sample');
Ui = inv(U); Ui = 0.5*(Ui+Ui');
Li = inv(L); Li = 0.5*(Li+Li');

% Maximum likelihood estimate of R^{-1}
cvx_begin sdp
variable S(n,n) symmetric
maximize( log_det(S) - trace(S*Y) );
S >= Ui;
S <= Li;
cvx_end
R_hat = inv(S);


Successive approximation method to be employed.
sedumi will be called several times to refine the solution.
Original size: 357 variables, 234 equality constraints
1 exponentials add 8 variables, 5 equality constraints
-----------------------------------------------------------------
Cones  |             Errors              |
Mov/Act | Centering  Exp cone   Poly cone | Status
--------+---------------------------------+---------
1/  1 | 1.981e+00  2.907e-01  9.261e-08 | Solved
1/  1 | 9.437e-02  6.354e-04  3.371e-07 | Solved
1/  1 | 3.752e-03  1.347e-06  3.674e-07 | Solved
0/  1 | 1.626e-04  3.727e-07  3.698e-07 | Solved
-----------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): -30.6698