qpbsvmlib.h

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------
00002  *
00003  * This program is free software; you can redistribute it and/or modify
00004  * it under the terms of the GNU General Public License as published by
00005  * the Free Software Foundation; either version 3 of the License, or
00006  * (at your option) any later version.
00007  *
00008  * Library for solving QP task required for learning SVM without bias term. 
00009  *
00010  * Written (W) 1999-2008 Vojtech Franc, xfrancv@cmp.felk.cvut.cz
00011  * Copyright (C) 1999-2008 Center for Machine Perception, CTU FEL Prague 
00012  *
00013  -------------------------------------------------------------------- */
00014 
00015 #ifndef QPBSVMLIB_H__
00016 #define QPBSVMLIB_H__
00017 
00018 #include <math.h>
00019 #include <limits.h>
00020 
00021 #include "base/SGObject.h"
00022 #include "lib/io.h"
00023 #include "lib/config.h"
00024 #include "lib/common.h"
00025 #include "kernel/Kernel.h"
00026 
00027 enum E_QPB_SOLVER
00028 {
00029     QPB_SOLVER_SCA, // sequential coordinate wise (gaussian seidel based)
00030     QPB_SOLVER_SCAS,    // sequential coordinate wise selecting the variable
00031     // gaining 'best' improved
00032     QPB_SOLVER_SCAMV, // sequential coordinate wise selecting variable most violating kkt's
00033     QPB_SOLVER_PRLOQO,// via pr_loqo
00034     QPB_SOLVER_CPLEX,  // via cplex
00035     QPB_SOLVER_GS,  // gaussian seidel
00036     QPB_SOLVER_GRADDESC  // gaussian seidel
00037 };
00038 
00040 class CQPBSVMLib: public CSGObject
00041 {
00042     public:
00051         CQPBSVMLib(DREAL* H, INT n, DREAL* f, INT m, DREAL UB=1.0);
00052 
00054         INT solve_qp(DREAL* result, INT len);
00055 
00060         inline void set_solver(E_QPB_SOLVER solver)
00061         {
00062             m_solver=solver;
00063         }
00064 
00065         ~CQPBSVMLib();
00066 
00067     protected:
00073         inline DREAL* get_col(INT col)
00074         {
00075             return &m_H[m_dim*col];
00076         }
00077 
00080         INT qpbsvm_sca(DREAL *x, DREAL *Nabla, INT *ptr_t, DREAL **ptr_History, INT verb);
00083         INT qpbsvm_scas(DREAL *x, DREAL *Nabla, INT *ptr_t, DREAL **ptr_History, INT verb);
00086         INT qpbsvm_scamv(DREAL *x, DREAL *Nabla, INT *ptr_t, DREAL **ptr_History, INT verb);
00089         INT qpbsvm_prloqo(DREAL *x, DREAL *Nabla, INT *ptr_t, DREAL **ptr_History, INT verb);
00092         INT qpbsvm_gauss_seidel(DREAL *x, DREAL *Nabla, INT *ptr_t, DREAL **ptr_History, INT verb);
00095         INT qpbsvm_gradient_descent(DREAL *x, DREAL *Nabla, INT *ptr_t, DREAL **ptr_History, INT verb);
00096 #ifdef USE_CPLEX
00097 
00099         INT qpbsvm_cplex(DREAL *x, DREAL *Nabla, INT *ptr_t, DREAL **ptr_History, INT verb);
00100 #endif
00101 
00102     protected:
00104         DREAL* m_H;
00106         DREAL* m_diag_H;
00108         INT m_dim;
00109 
00111         DREAL* m_f;
00112 
00114         DREAL m_UB;
00115 
00117         INT m_tmax;
00119         DREAL m_tolabs;
00121         DREAL m_tolrel;
00123         DREAL m_tolKKT;
00125         E_QPB_SOLVER m_solver;
00126 };
00127 #endif //QPBSVMLIB_H__

SHOGUN Machine Learning Toolbox - Documentation