File: crm_svm_quad_prog.h

package info (click to toggle)
crm114 20100106-10
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 3,184 kB
  • sloc: ansic: 34,910; sh: 617; makefile: 578; lisp: 208
file content (63 lines) | stat: -rw-r--r-- 2,625 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//	crm_svm_quad_prog.h - Support Vector Machine

////////////////////////////////////////////////////////////////////////
//    This code is originally copyright and owned by William
//    S. Yerazunis as file crm_neural_net.  In return for addition of 
//    significant derivative work, Jennifer Barry is hereby granted a full 
//    unlimited license to use this code, includng license to relicense under 
//    other licenses.
////////////////////////////////////////////////////////////////////////
//
// Copyright 2009 William S. Yerazunis.
// This file is under GPLv3, as described in COPYING.

#ifndef __CRM_SVM_QUAD_PROG__H
#define __CRM_SVM_QUAD_PROG__H

#include "crm_svm_matrix_util.h"
#include "crm_svm_matrix.h"

extern int MATR_DEBUG_MODE;     //debugging mode. see crm_svm_matrix_util.h for
                               //possible values.

int QP_DEBUG_MODE;

#define QP_DEBUG 2              //basic information about the qp solver

#define QP_DEBUG_LOOP 3         //prints some information during each qp loop
                                //useful if the svm is getting stuck during a QP
                                //problem

#define QP_LINEAR_SOLVER 4      //prints some information during each cg loop
                                //useful to discover if the run goes on forever
                                //because the cg isn't converging 
                                //(usually indicates a bug in the add or remove
                                //constraint functions!)

#define QP_CONSTRAINTS 5        //prints out information about adding and 
                                //removing constraints during the qp solver
                             

//the accuracy to which we run conjugate_gradient
//this should be a pretty small number!!!
#define QP_LINEAR_ACCURACY 1e-10
//we should never exceed this but here just in case
#define QP_MAX_ITERATIONS 1000

void run_qp(Matrix *G, Matrix *A, Vector *c, Vector *b, Vector *x);
void add_constraint(int toadd, Matrix *A, Matrix *Q, Matrix *R, 
		    Matrix **Z_ptr);
void delete_constraint(int toad, Matrix *A, Matrix *Q, Matrix *R, 
		       Matrix **Z_ptr);
int compute_lambda(Matrix *R, Matrix *Q, Vector *g);
void back_sub(Matrix *U, Vector *b, Vector *ret);
double find_direction(Matrix *Z, Matrix *G, Vector *g, Vector *p);
void conjugate_gradient(Matrix **A, int nmatrices, int maxrows,
			Vector *b, Vector *x);
void gradient_descent(Matrix **A, int nmatrices, int maxrows, Vector *v,
		      Vector *x);
void run_linear(Matrix *A, Vector *b, Vector *x);

//int main(int argc, char **argv);

#endif //crm_svm_quad_prog.h