text: <!DOCTYPE HTML>
  <html>
  <head>
  <meta charset="UTF-8">
  <title>Section 4.3.1: Compute the Chebyshev center of a polyhedron</title>
  <link rel="canonical" href="/Users/mcgrant/Repos/CVX/examples/cvxbook/Ch04_cvx_opt_probs/html/chebyshev_center.html">
  <link rel="stylesheet" href="../../../examples.css" type="text/css">
  </head>
  <body>
  <div id="header">
  <h1>Section 4.3.1: Compute the Chebyshev center of a polyhedron</h1>
  Jump to:&nbsp;&nbsp;&nbsp;&nbsp;
  <a href="#source">Source code</a>&nbsp;&nbsp;&nbsp;&nbsp;
  <a href="#output">Text output</a>
  &nbsp;&nbsp;&nbsp;&nbsp;
  Plots
  &nbsp;&nbsp;&nbsp;&nbsp;<a href="../../../index.html">Library index</a>
  </div>
  <div id="content">
  <a id="source"></a>
  <pre class="codeinput">
  <span class="comment">% Boyd &amp; Vandenberghe "Convex Optimization"</span>
  <span class="comment">% Jo&euml;lle Skaf - 08/16/05</span>
  <span class="comment">%</span>
  <span class="comment">% The goal is to find the largest Euclidean ball (i.e. its center and</span>
  <span class="comment">% radius) that lies in a polyhedron described by linear inequalites in this</span>
  <span class="comment">% fashion: P = {x : a_i'*x &lt;= b_i, i=1,...,m}</span>
  
  <span class="comment">% Generate the data</span>
  randn(<span class="string">'state'</span>,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);
  
  <span class="comment">% Build and execute model</span>
  fprintf(1,<span class="string">'Computing Chebyshev center...'</span>);
  cvx_begin
      variable <span class="string">r(1)</span>
      variable <span class="string">x_c(n)</span>
      dual <span class="string">variable</span> <span class="string">y</span>
      maximize ( r )
      y: A*x_c + r*norm_ai &lt;= b;
  cvx_end
  fprintf(1,<span class="string">'Done! \n'</span>);
  
  <span class="comment">% Display results</span>
  fprintf(1,<span class="string">'The Chebyshev center coordinates are: \n'</span>);
  disp(x_c);
  fprintf(1,<span class="string">'The radius of the largest Euclidean ball is: \n'</span>);
  disp(r);
  </pre>
  <a id="output"></a>
  <pre class="codeoutput">
  Computing Chebyshev center... 
  Calling Mosek 9.1.9: 20 variables, 11 equality constraints
     For improved efficiency, Mosek is solving the dual problem.
  ------------------------------------------------------------
  
  MOSEK Version 9.1.9 (Build date: 2019-11-21 11:32:15)
  Copyright (c) MOSEK ApS, Denmark. WWW: mosek.com
  Platform: MACOSX/64-X86
  
  Problem
    Name                   :                 
    Objective sense        : min             
    Type                   : LO (linear optimization problem)
    Constraints            : 11              
    Cones                  : 0               
    Scalar variables       : 20              
    Matrix variables       : 0               
    Integer variables      : 0               
  
  Optimizer started.
  Presolve started.
  Linear dependency checker started.
  Linear dependency checker terminated.
  Eliminator started.
  Freed constraints in eliminator : 0
  Eliminator terminated.
  Eliminator - tries                  : 1                 time                   : 0.00            
  Lin. dep.  - tries                  : 1                 time                   : 0.00            
  Lin. dep.  - number                 : 0               
  Presolve terminated. Time: 0.00    
  Problem
    Name                   :                 
    Objective sense        : min             
    Type                   : LO (linear optimization problem)
    Constraints            : 11              
    Cones                  : 0               
    Scalar variables       : 20              
    Matrix variables       : 0               
    Integer variables      : 0               
  
  Optimizer  - threads                : 8               
  Optimizer  - solved problem         : the primal      
  Optimizer  - Constraints            : 11
  Optimizer  - Cones                  : 0
  Optimizer  - Scalar variables       : 20                conic                  : 0               
  Optimizer  - Semi-definite variables: 0                 scalarized             : 0               
  Factor     - setup time             : 0.00              dense det. time        : 0.00            
  Factor     - ML order time          : 0.00              GP order time          : 0.00            
  Factor     - nonzeros before factor : 66                after factor           : 66              
  Factor     - dense dim.             : 0                 flops                  : 3.15e+03        
  ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  
  0   3.1e+01  4.7e+00  4.2e+01  0.00e+00   1.800847484e+01   0.000000000e+00   4.8e+00  0.00  
  1   1.1e+00  1.7e-01  1.5e+00  -2.05e-01  8.329859321e-01   -1.351392910e-01  1.7e-01  0.01  
  2   2.3e-01  3.4e-02  3.1e-01  8.87e-01   4.003042853e-01   2.086959117e-01   3.5e-02  0.01  
  3   7.0e-02  1.1e-02  9.4e-02  7.24e-01   3.291684363e-01   2.681986266e-01   1.1e-02  0.01  
  4   1.4e-02  8.3e-04  1.2e-02  7.64e-01   3.127686118e-01   3.004715227e-01   1.9e-03  0.01  
  5   5.5e-03  3.3e-04  4.7e-03  -1.84e-01  3.243044563e-01   3.181611000e-01   7.3e-04  0.01  
  6   1.3e-03  7.8e-05  1.1e-03  7.76e-01   3.341258689e-01   3.326409576e-01   1.7e-04  0.01  
  7   8.5e-05  5.0e-06  7.2e-05  1.02e+00   3.368651344e-01   3.367873239e-01   1.1e-05  0.01  
  8   6.1e-07  3.6e-08  5.1e-07  1.00e+00   3.370587443e-01   3.370581838e-01   8.0e-08  0.01  
  9   6.1e-11  3.6e-12  5.2e-11  1.00e+00   3.370593981e-01   3.370593981e-01   8.0e-12  0.01  
  Basis identification started.
  Primal basis identification phase started.
  Primal basis identification phase terminated. Time: 0.00
  Dual basis identification phase started.
  Dual basis identification phase terminated. Time: 0.00
  Basis identification terminated. Time: 0.00
  Optimizer terminated. Time: 0.02    
  
  
  Interior-point solution summary
    Problem status  : PRIMAL_AND_DUAL_FEASIBLE
    Solution status : OPTIMAL
    Primal.  obj: 3.3705939813e-01    nrm: 1e+00    Viol.  con: 3e-10    var: 0e+00  
    Dual.    obj: 3.3705939807e-01    nrm: 1e+01    Viol.  con: 0e+00    var: 4e-12  
  
  Basic solution summary
    Problem status  : PRIMAL_AND_DUAL_FEASIBLE
    Solution status : OPTIMAL
    Primal.  obj: 3.3705939820e-01    nrm: 1e+00    Viol.  con: 2e-16    var: 0e+00  
    Dual.    obj: 3.3705939807e-01    nrm: 1e+01    Viol.  con: 0e+00    var: 2e-15  
  Optimizer summary
    Optimizer                 -                        time: 0.02    
      Interior-point          - iterations : 9         time: 0.01    
        Basis identification  -                        time: 0.00    
          Primal              - iterations : 0         time: 0.00    
          Dual                - iterations : 0         time: 0.00    
          Clean primal        - iterations : 0         time: 0.00    
          Clean dual          - iterations : 0         time: 0.00    
      Simplex                 -                        time: 0.00    
        Primal simplex        - iterations : 0         time: 0.00    
        Dual simplex          - iterations : 0         time: 0.00    
      Mixed integer           - relaxations: 0         time: 0.00    
  
  ------------------------------------------------------------
  Status: Solved
  Optimal value (cvx_optval): +0.337059
   
  Done! 
  The Chebyshev center coordinates are: 
     -0.1116
     -1.5760
      0.1079
     -2.1751
      3.2264
      3.5820
      4.3394
      3.0680
      0.4449
      0.3164
  
  The radius of the largest Euclidean ball is: 
      0.3371
  
  </pre>
  </div>
  </body>
  </html>