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 namespace shogun
00028 {
00029 
00030 enum E_QPB_SOLVER
00031 {
00032     QPB_SOLVER_SCA, // sequential coordinate wise (gaussian seidel based)
00033     QPB_SOLVER_SCAS,    // sequential coordinate wise selecting the variable
00034     // gaining 'best' improved
00035     QPB_SOLVER_SCAMV, // sequential coordinate wise selecting variable most violating kkt's
00036     QPB_SOLVER_PRLOQO,// via pr_loqo
00037     QPB_SOLVER_CPLEX,  // via cplex
00038     QPB_SOLVER_GS,  // gaussian seidel
00039     QPB_SOLVER_GRADDESC  // gaussian seidel
00040 };
00041 
00043 class CQPBSVMLib: public CSGObject
00044 {
00045     public:
00047         CQPBSVMLib(void);
00048 
00057         CQPBSVMLib(
00058             float64_t* H, int32_t n, float64_t* f, int32_t m, float64_t UB=1.0);
00059 
00061         int32_t solve_qp(float64_t* result, int32_t len);
00062 
00067         inline void set_solver(E_QPB_SOLVER solver)
00068         {
00069             m_solver=solver;
00070         }
00071 
00072         virtual ~CQPBSVMLib();
00073 
00074     protected:
00080         inline float64_t* get_col(int32_t col)
00081         {
00082             return &m_H[m_dim*col];
00083         }
00084 
00087         int32_t qpbsvm_sca(
00088             float64_t *x, float64_t *Nabla, int32_t *ptr_t,
00089             float64_t **ptr_History, int32_t verb);
00092         int32_t qpbsvm_scas(
00093             float64_t *x, float64_t *Nabla, int32_t *ptr_t,
00094             float64_t **ptr_History, int32_t verb);
00097         int32_t qpbsvm_scamv(
00098             float64_t *x, float64_t *Nabla, int32_t *ptr_t,
00099             float64_t **ptr_History, int32_t verb);
00102         int32_t qpbsvm_prloqo(
00103             float64_t *x, float64_t *Nabla, int32_t *ptr_t,
00104             float64_t **ptr_History, int32_t verb);
00107         int32_t qpbsvm_gauss_seidel(
00108             float64_t *x, float64_t *Nabla, int32_t *ptr_t,
00109             float64_t **ptr_History, int32_t verb);
00112         int32_t qpbsvm_gradient_descent(
00113             float64_t *x, float64_t *Nabla, int32_t *ptr_t,
00114             float64_t **ptr_History, int32_t verb);
00115 #ifdef USE_CPLEX
00116 
00118         int32_t qpbsvm_cplex(
00119             float64_t *x, float64_t *Nabla, int32_t *ptr_t,
00120             float64_t **ptr_History, int32_t verb);
00121 #endif
00122 
00124         inline virtual const char* get_name() const { return "QPBSVMLib"; }
00125 
00126     protected:
00128         float64_t* m_H;
00130         float64_t* m_diag_H;
00132         int32_t m_dim;
00133 
00135         float64_t* m_f;
00136 
00138         float64_t m_UB;
00139 
00141         int32_t m_tmax;
00143         float64_t m_tolabs;
00145         float64_t m_tolrel;
00147         float64_t m_tolKKT;
00149         E_QPB_SOLVER m_solver;
00150 };
00151 }
00152 #endif //QPBSVMLIB_H__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation