/* 
 * sdpsol source which finds most spherical ellipsoid separating two
 * sets of points (x_i and y_j). That is,
 * min gamma
 * x_i^TAx_i + b^Tx_i + c \leq 0, \forall i\in [1,kx]
 * y_j^TAy_j + b^Ty_i + c \geq 0, \forall j\in [1,ky]
 * I \leq A \leq gamma*I
 *
 * See: 
 *   L. Vandenberghe and S. Boyd, "Semidefinite Programming", Submitted
 *   SIAM review, July 1994, Sec. 2
 */

include("pointdata.mat");    /* load x,y */
n = rows(x);                 /* dimension */
kx = cols(x);                /* number of x^i */
ky = cols(y);                /* number of y^j */

/*variable A(n,n) symmetric;*/
variable A(n,n);
variable b(n,1);
variable c, gamma scalar;

int = diag(x'*A*x) + (b'*x)' + c*ones(kx,1);  /* interior points */
ext = diag(y'*A*y) + (b'*y)' + c*ones(ky,1);  /* exterior points */

constraint INT     int .< 0;   /* interior constraint (componentwise) */
constraint EXT     ext .> 0;   /* exterior constraint (componentwise) */

constraint SPHERE  A > eye(n); /* condition constraint (A > I) */
constraint WORST   A < gamma;  /* condition constraint (A < gamma*I) */

constraint SYM     A == A';


NU = 10;          /* customized SP parameters */
MAXITER = 50;
ABSTOL = 1e-7;
RELTOL = 1e-5;

minimize condition = gamma;