SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
QPBSVMLib.h
Go to the documentation of this file.
1 /*-----------------------------------------------------------------------
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * Library for solving QP task required for learning SVM without bias term.
9  *
10  * Written (W) 1999-2008 Vojtech Franc, xfrancv@cmp.felk.cvut.cz
11  * Copyright (C) 1999-2008 Center for Machine Perception, CTU FEL Prague
12  *
13  -------------------------------------------------------------------- */
14 
15 #ifndef QPBSVMLIB_H__
16 #define QPBSVMLIB_H__
17 
18 #include <shogun/base/SGObject.h>
19 #include <shogun/io/SGIO.h>
20 #include <shogun/lib/config.h>
21 #include <shogun/lib/common.h>
22 #include <shogun/kernel/Kernel.h>
23 
24 namespace shogun
25 {
26 
27 #ifndef DOXYGEN_SHOULD_SKIP_THIS
28 enum E_QPB_SOLVER
29 {
30  QPB_SOLVER_SCA, // sequential coordinate wise (gaussian seidel based)
31  QPB_SOLVER_SCAS, // sequential coordinate wise selecting the variable
32  // gaining 'best' improved
33  QPB_SOLVER_SCAMV, // sequential coordinate wise selecting variable most violating kkt's
34  QPB_SOLVER_PRLOQO,// via pr_loqo
35  QPB_SOLVER_CPLEX, // via cplex
36  QPB_SOLVER_GS, // gaussian seidel
37  QPB_SOLVER_GRADDESC // gaussian seidel
38 };
39 #endif
40 
42 class CQPBSVMLib: public CSGObject
43 {
44  public:
46  CQPBSVMLib();
47 
56  CQPBSVMLib(
57  float64_t* H, int32_t n, float64_t* f, int32_t m, float64_t UB=1.0);
58 
60  int32_t solve_qp(float64_t* result, int32_t len);
61 
66  inline void set_solver(E_QPB_SOLVER solver)
67  {
68  m_solver=solver;
69  }
70 
71  virtual ~CQPBSVMLib();
72 
73  protected:
79  inline float64_t* get_col(int32_t col)
80  {
81  return &m_H[m_dim*col];
82  }
83 
86  int32_t qpbsvm_sca(
87  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
88  float64_t **ptr_History, int32_t verb);
91  int32_t qpbsvm_scas(
92  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
93  float64_t **ptr_History, int32_t verb);
96  int32_t qpbsvm_scamv(
97  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
98  float64_t **ptr_History, int32_t verb);
101  int32_t qpbsvm_prloqo(
102  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
103  float64_t **ptr_History, int32_t verb);
106  int32_t qpbsvm_gauss_seidel(
107  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
108  float64_t **ptr_History, int32_t verb);
111  int32_t qpbsvm_gradient_descent(
112  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
113  float64_t **ptr_History, int32_t verb);
114 #ifdef USE_CPLEX
115 
117  int32_t qpbsvm_cplex(
118  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
119  float64_t **ptr_History, int32_t verb);
120 #endif
121 
123  inline const char* get_name() const { return "QPBSVMLib"; }
124 
125  protected:
131  int32_t m_dim;
132 
135 
138 
140  int32_t m_tmax;
148  E_QPB_SOLVER m_solver;
149 };
150 }
151 #endif //QPBSVMLIB_H__
static float64_t * H
Definition: libbmrm.cpp:27
int32_t qpbsvm_scamv(float64_t *x, float64_t *Nabla, int32_t *ptr_t, float64_t **ptr_History, int32_t verb)
Definition: QPBSVMLib.cpp:465
float64_t * get_col(int32_t col)
Definition: QPBSVMLib.h:79
float64_t * m_f
Definition: QPBSVMLib.h:134
int32_t qpbsvm_sca(float64_t *x, float64_t *Nabla, int32_t *ptr_t, float64_t **ptr_History, int32_t verb)
Definition: QPBSVMLib.cpp:170
void set_solver(E_QPB_SOLVER solver)
Definition: QPBSVMLib.h:66
float64_t * m_diag_H
Definition: QPBSVMLib.h:129
float64_t m_tolabs
Definition: QPBSVMLib.h:142
float64_t m_tolKKT
Definition: QPBSVMLib.h:146
int32_t qpbsvm_gauss_seidel(float64_t *x, float64_t *Nabla, int32_t *ptr_t, float64_t **ptr_History, int32_t verb)
Definition: QPBSVMLib.cpp:588
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:112
const char * get_name() const
Definition: QPBSVMLib.h:123
double float64_t
Definition: common.h:50
int32_t qpbsvm_prloqo(float64_t *x, float64_t *Nabla, int32_t *ptr_t, float64_t **ptr_History, int32_t verb)
Definition: QPBSVMLib.cpp:552
E_QPB_SOLVER m_solver
Definition: QPBSVMLib.h:148
int32_t qpbsvm_gradient_descent(float64_t *x, float64_t *Nabla, int32_t *ptr_t, float64_t **ptr_History, int32_t verb)
Definition: QPBSVMLib.cpp:619
int32_t qpbsvm_scas(float64_t *x, float64_t *Nabla, int32_t *ptr_t, float64_t **ptr_History, int32_t verb)
Definition: QPBSVMLib.cpp:311
float64_t m_UB
Definition: QPBSVMLib.h:137
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual ~CQPBSVMLib()
Definition: QPBSVMLib.cpp:101
float64_t m_tolrel
Definition: QPBSVMLib.h:144
class QPBSVMLib
Definition: QPBSVMLib.h:42
int32_t qpbsvm_cplex(float64_t *x, float64_t *Nabla, int32_t *ptr_t, float64_t **ptr_History, int32_t verb)
Definition: QPBSVMLib.cpp:656
int32_t solve_qp(float64_t *result, int32_t len)
result has to be allocated & zeroed
Definition: QPBSVMLib.cpp:106
float64_t * m_H
Definition: QPBSVMLib.h:127

SHOGUN Machine Learning Toolbox - Documentation