% Joëlle Skaf - 04/29/08
%
% The weighted analytic center of a set of linear inequalities:
%           a_i^Tx <= b_i   i=1,...,m,
% is the solution of the unconstrained minimization problem
%           minimize    -sum_{i=1}^m w_i*log(b_i-a_i^Tx),
% where w_i>0

% Input data
randn('state', 0);
rand('state', 0);
n = 10;
m = 50;
tmp = randn(n,1);
A = randn(m,n);
b = A*tmp + 2*rand(m,1);
w = rand(m,1);

% Analytic center
cvx_begin
    variable x(n)
    minimize -sum(w.*log(b-A*x))
cvx_end

disp('The weighted analytic center of the set of linear inequalities is: ');
disp(x);
 
Successive approximation method to be employed.
   sedumi will be called several times to refine the solution.
   Original size: 160 variables, 100 equality constraints
   50 exponentials add 400 variables, 250 equality constraints
-----------------------------------------------------------------
 Cones  |             Errors              |
Mov/Act | Centering  Exp cone   Poly cone | Status
--------+---------------------------------+---------
 50/ 50 | 2.579e+00  4.986e-01  6.898e-07 | Inaccurate/Solved
 50/ 50 | 1.695e-01  2.052e-03  1.506e-07 | Solved
 36/ 46 | 2.282e-02  3.118e-05  2.120e-07 | Solved
  0/ 38 | 6.894e-04  2.432e-07  2.130e-07 | Solved
-----------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +5.99254
The weighted analytic center of the set of linear inequalities is: 
   -0.5100
   -1.4794
    0.3397
    0.1944
   -1.0444
    1.1956
    1.3927
   -0.2815
    0.2862
    0.3779