Section 4.3.1: Compute and display the Chebyshev center of a 2D polyhedron
a1 = [ 2; 1];
a2 = [ 2; -1];
a3 = [-1; 2];
a4 = [-1; -2];
b = ones(4,1);
cvx_begin
variable r(1)
variable x_c(2)
maximize ( r )
a1'*x_c + r*norm(a1,2) <= b(1);
a2'*x_c + r*norm(a2,2) <= b(2);
a3'*x_c + r*norm(a3,2) <= b(3);
a4'*x_c + r*norm(a4,2) <= b(4);
cvx_end
x = linspace(-2,2);
theta = 0:pi/100:2*pi;
plot( x, -x*a1(1)./a1(2) + b(1)./a1(2),'b-');
hold on
plot( x, -x*a2(1)./a2(2) + b(2)./a2(2),'b-');
plot( x, -x*a3(1)./a3(2) + b(3)./a3(2),'b-');
plot( x, -x*a4(1)./a4(2) + b(4)./a4(2),'b-');
plot( x_c(1) + r*cos(theta), x_c(2) + r*sin(theta), 'r');
plot(x_c(1),x_c(2),'k+')
xlabel('x_1')
ylabel('x_2')
title('Largest Euclidean ball lying in a 2D polyhedron');
axis([-1 1 -1 1])
axis equal
Calling SDPT3: 4 variables, 3 equality constraints
For improved efficiency, SDPT3 is solving the dual problem.
------------------------------------------------------------
num. of constraints = 3
dim. of linear var = 4
number of nearly dependent constraints = 1
To remove these constraints, re-run sqlp.m with OPTIONS.rmdepconstr = 1.
*******************************************************************
SDPT3: Infeasible path-following algorithms
*******************************************************************
version predcorr gam expon scale_data
NT 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap mean(obj) cputime
-------------------------------------------------------------------
0|0.000|0.000|8.7e+00|3.0e+00|4.4e+01| 4.000000e+00| 0:0:00| chol 1 1
1|1.000|1.000|2.2e-06|6.7e-02|2.2e+00|-6.073019e-01| 0:0:00| chol 1 1
2|1.000|0.989|5.8e-08|7.3e-03|2.3e-02| 4.379310e-01| 0:0:00| chol 1 1
3|1.000|0.989|1.6e-08|7.4e-04|2.6e-04| 4.473327e-01| 0:0:00| chol 1 1
4|1.000|0.989|4.9e-09|7.4e-05|2.8e-06| 4.472370e-01| 0:0:00| chol 1 1
5|1.000|0.997|4.0e-09|1.9e-07|3.9e-08| 4.472136e-01| 0:0:00| chol 1 1
6|1.000|0.999|5.7e-12|3.1e-10|4.9e-10| 4.472136e-01| 0:0:00|
stop: max(relative gap, infeasibilities) < 1.49e-08
-------------------------------------------------------------------
number of iterations = 6
primal objective value = 4.47213596e-01
dual objective value = 4.47213595e-01
gap := trace(XZ) = 4.93e-10
relative gap = 2.60e-10
actual relative gap = 1.53e-10
rel. primal infeas = 5.68e-12
rel. dual infeas = 3.11e-10
norm(X), norm(y), norm(Z) = 2.4e-01, 4.5e-01, 2.6e-09
norm(A), norm(b), norm(C) = 7.3e+00, 2.0e+00, 3.0e+00
Total CPU time (secs) = 0.1
CPU time per iteration = 0.0
termination code = 0
DIMACS: 5.7e-12 0.0e+00 4.7e-10 0.0e+00 1.5e-10 2.6e-10
-------------------------------------------------------------------
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +0.447214