Hi,
Providing the data is impossible with the 60K limit and no attachments...
The AlgLib part of my application does nothing different than the demo code - see below. 'ir_svm' just creates the (symmetric) N-D Hessian and (N+1)-D constraints matrices etc.
The constraints are: all Xi > 0 and sigma(Xi * Yi, i=1..N) = 0, where N, the number of training points, was at most 770 - but might need to be larger, Xi, i=1..N, are the LaGarange multipliers - and the QP unknowns, where Yi, i=1..N, are either 1 or -1 according to Ti being a 'true' or 'false' training point. Scales were set uniformly for all N - as 0.1, 1, 10, 100, 1000 - with no appreciable effect. No initial guess for Xi is available - so initialized with ones.
The QP having converged successfully, W, defining the the M-dimensional (58) hyperplane separating the 'true' training points from the 'false' ones can be calculated - and a scalar b such that (1) <w . Ti> - b should be >= 1 for 'true' M-dimensional Training points and <w . Ti> - b should be <= -1 for 'false' Training points; <w . Ti> here is the inner product between the two M-dimensional vectors.
The distance between the two sets of training points is 2 / ||W||.
The result of the QP yields small but non-zero distance between the two sets - but the conditions (1) don't hold correctly - the training points for which the Lagrange multiplies came out identically zero full fill - not (1) - rather, in most cases, a weaker version (2) <w . Ti> - b should be >= f1 for 'true' Training points and <w . Ti> - b should be <= -f2 for 'false' Training points; where 0< f1 & f2 < 1 - and in isolated cases not even (2) holds...
int _tmain(int argc, _TCHAR* argv[]) { try { double *pa, *pb, *pc, *ps, *px; int *pct;
int N = ir_svm(&pa, &pb, &pc, &pct, &ps, &px);
real_2d_array a; a.setcontent(N, N, pa);
real_1d_array b; b.setcontent(N, pb);
real_1d_array s; s.setcontent(N, ps);
real_2d_array c; c.setcontent(N + 1, N + 1, pc);
integer_1d_array ct; ct.setcontent(N + 1, pct);
real_1d_array x; x.setcontent(N, px);
minqpstate state; minqpreport rep;
// create solver, set quadratic/linear terms minqpcreate(N, state); minqpsetquadraticterm(state, a); minqpsetlinearterm(state, b); minqpsetlc(state, c, ct);
// NOTE: for convex problems you may try using minqpsetscaleautodiag() // which automatically determines variable scales. minqpsetscale(state, s);
// // Solve problem with BLEIC-based QP solver. // // This solver is intended for problems with moderate (up to 50) number // of general linear constraints and unlimited number of box constraints. // // Default stopping criteria are used. //
//minqpsetalgobleic(state, 0.0, 0.0, 0.0, 0); minqpsetalgodenseaul(state, 1.0e-15, 5.0e+4, 10);
minqpoptimize(state); minqpresults(state, x, rep); printf("inneriterationscount %u\n" "ncholesky %u, nmv %u\n" "outeriterationscount %u\n" "terminationtype %d\n" , rep.inneriterationscount, rep.ncholesky, rep.nmv, rep.outeriterationscount, rep.terminationtype); } catch(ap_error) { printf("Exception!\n"); getchar(); } return 0; }
|