Figure 8.9: Robust linear discrimination problem
n = 2;
randn('state',3);
N = 10; M = 6;
Y = [1.5+1*randn(1,M); 2*randn(1,M)];
X = [-1.5+1*randn(1,N); 2*randn(1,N)];
T = [-1 1; 1 1];
Y = T*Y; X = T*X;
cvx_begin
variables a(n) b(1) t(1)
maximize (t)
X'*a - b >= t;
Y'*a - b <= -t;
norm(a) <= 1;
cvx_end
linewidth = 0.5;
t_min = min([X(1,:),Y(1,:)]);
t_max = max([X(1,:),Y(1,:)]);
tt = linspace(t_min-1,t_max+1,100);
p = -a(1)*tt/a(2) + b/a(2);
p1 = -a(1)*tt/a(2) + (b+t)/a(2);
p2 = -a(1)*tt/a(2) + (b-t)/a(2);
graph = plot(X(1,:),X(2,:), 'o', Y(1,:), Y(2,:), 'o');
set(graph(1),'LineWidth',linewidth);
set(graph(2),'LineWidth',linewidth);
set(graph(2),'MarkerFaceColor',[0 0.5 0]);
hold on;
plot(tt,p, '-r', tt,p1, '--r', tt,p2, '--r');
axis equal
title('Robust linear discrimination problem');
Calling SeDuMi: 21 variables (2 free), 17 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 2 free variables
eqs m = 17, order n = 23, dim = 24, blocks = 2
nnz(A) = 113 + 0, nnz(ADA) = 289, nnz(L) = 153
it : b*y gap delta rate t/tP* t/tD* feas cg cg prec
0 : 8.80E-001 0.000
1 : 7.88E-002 2.46E-001 0.000 0.2792 0.9000 0.9000 2.35 1 1 1.1E+000
2 : -2.99E-002 7.25E-002 0.000 0.2948 0.9000 0.9000 1.91 1 1 7.3E-001
3 : -1.83E-001 2.55E-002 0.000 0.3522 0.9000 0.9000 0.01 1 1 1.2E-001
4 : -4.59E-001 8.74E-003 0.000 0.3424 0.9000 0.9000 0.76 1 1 6.1E-002
5 : -5.06E-001 6.41E-004 0.000 0.0734 0.9900 0.9900 0.89 1 1 4.4E-003
6 : -5.11E-001 2.89E-006 0.000 0.0045 0.9990 0.9990 0.99 1 1 1.9E-005
7 : -5.11E-001 9.07E-010 0.000 0.0003 0.9999 0.9986 1.00 1 1 1.5E-008
iter seconds digits c*x b*y
7 0.1 Inf -5.1122989496e-001 -5.1122988683e-001
|Ax-b| = 1.5e-008, [Ay-c]_+ = 6.0E-009, |x|= 9.2e+000, |y|= 8.1e-001
Detailed timing (sec)
Pre IPM Post
0.000E+000 9.013E-002 0.000E+000
Max-norms: ||b||=1, ||c|| = 1,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 1.92116.
------------------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +0.51123