Section 4.3.1: Compute the Chebyshev center of a polyhedron

% Boyd & Vandenberghe "Convex Optimization"
% Joëlle Skaf - 08/16/05
%
% The goal is to find the largest Euclidean ball (i.e. its center and
% radius) that lies in a polyhedron described by linear inequalites in this
% fashion: P = {x : a_i'*x <= b_i, i=1,...,m}

% Generate the data
randn('state',0);
n = 10; m = 2*n;
A = randn(m,n);
b = A*rand(n,1) + 2*rand(m,1);
norm_ai = sum(A.^2,2).^(.5);

% Build and execute model
fprintf(1,'Computing Chebyshev center...');
cvx_begin
    variable r(1)
    variable x_c(n)
    dual variable y
    maximize ( r )
    y: A*x_c + r*norm_ai <= b;
cvx_end
fprintf(1,'Done! \n');

% Display results
fprintf(1,'The Chebyshev center coordinates are: \n');
disp(x_c);
fprintf(1,'The radius of the largest Euclidean ball is: \n');
disp(r);
Computing Chebyshev center... 
Calling SeDuMi: 31 variables (11 free), 20 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 11 free variables
eqs m = 20, order n = 43, dim = 43, blocks = 1
nnz(A) = 460 + 0, nnz(ADA) = 400, nnz(L) = 210
 it :     b*y       gap    delta  rate   t/tP*  t/tD*   feas cg cg  prec
  0 :            6.02E-001 0.000
  1 : -1.10E-002 1.22E-001 0.000 0.2022 0.9000 0.9000   1.00  1  1  2.0E+000
  2 : -1.15E-001 3.91E-002 0.000 0.3218 0.9000 0.9000   2.70  1  1  9.1E-001
  3 : -2.45E-001 1.07E-002 0.000 0.2739 0.9000 0.9000   1.93  1  1  8.2E-002
  4 : -2.96E-001 2.98E-003 0.000 0.2776 0.9000 0.9000   1.03  1  1  2.0E-002
  5 : -3.16E-001 8.64E-004 0.000 0.2903 0.9000 0.9000   1.08  1  1  5.1E-003
  6 : -3.22E-001 4.31E-005 0.000 0.0499 0.9900 0.9900   1.21  1  1  2.3E-004
  7 : -3.23E-001 1.67E-007 0.000 0.0039 0.9990 0.9990   1.06  1  1  
iter seconds digits       c*x               b*y
  7      0.1   Inf -3.2276133170e-001 -3.2276133170e-001
|Ax-b| =  6.1e-015, [Ay-c]_+ =  2.1E-016, |x|= 8.9e+000, |y|= 1.5e-001

Detailed timing (sec)
   Pre          IPM          Post
0.000E+000    7.010E-002    0.000E+000    
Max-norms: ||b||=4.197234e+000, ||c|| = 1,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 1.51389.
------------------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +0.322761
Done! 
The Chebyshev center coordinates are: 
    0.8511
   -0.6874
    1.1205
    0.3555
    0.2573
    0.3947
    1.1970
    1.4711
    1.7486
    1.0573

The radius of the largest Euclidean ball is: 
    0.3228