SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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/lib/config.h>
19 #ifdef USE_GPL_SHOGUN
20 #include <shogun/base/SGObject.h>
21 #include <shogun/io/SGIO.h>
22 #include <shogun/lib/common.h>
23 #include <shogun/kernel/Kernel.h>
24 
25 namespace shogun
26 {
27 
28 #ifndef DOXYGEN_SHOULD_SKIP_THIS
29 enum E_QPB_SOLVER
30 {
31  QPB_SOLVER_SCA, // sequential coordinate wise (gaussian seidel based)
32  QPB_SOLVER_SCAS, // sequential coordinate wise selecting the variable
33  // gaining 'best' improved
34  QPB_SOLVER_SCAMV, // sequential coordinate wise selecting variable most violating kkt's
35  QPB_SOLVER_PRLOQO,// via pr_loqo
36  QPB_SOLVER_CPLEX, // via cplex
37  QPB_SOLVER_GS, // gaussian seidel
38  QPB_SOLVER_GRADDESC // gaussian seidel
39 };
40 #endif
41 
43 class CQPBSVMLib: public CSGObject
44 {
45  public:
47  CQPBSVMLib();
48 
57  CQPBSVMLib(
58  float64_t* H, int32_t n, float64_t* f, int32_t m, float64_t UB=1.0);
59 
61  int32_t solve_qp(float64_t* result, int32_t len);
62 
67  inline void set_solver(E_QPB_SOLVER solver)
68  {
69  m_solver=solver;
70  }
71 
72  virtual ~CQPBSVMLib();
73 
74  protected:
80  inline float64_t* get_col(int32_t col)
81  {
82  return &m_H[m_dim*col];
83  }
84 
87  int32_t qpbsvm_sca(
88  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
89  float64_t **ptr_History, int32_t verb);
92  int32_t qpbsvm_scas(
93  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
94  float64_t **ptr_History, int32_t verb);
97  int32_t qpbsvm_scamv(
98  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
99  float64_t **ptr_History, int32_t verb);
102  int32_t qpbsvm_prloqo(
103  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
104  float64_t **ptr_History, int32_t verb);
107  int32_t qpbsvm_gauss_seidel(
108  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
109  float64_t **ptr_History, int32_t verb);
112  int32_t qpbsvm_gradient_descent(
113  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
114  float64_t **ptr_History, int32_t verb);
115 #ifdef USE_CPLEX
116 
118  int32_t qpbsvm_cplex(
119  float64_t *x, float64_t *Nabla, int32_t *ptr_t,
120  float64_t **ptr_History, int32_t verb);
121 #endif
122 
124  inline const char* get_name() const { return "QPBSVMLib"; }
125 
126  protected:
128  float64_t* m_H;
130  float64_t* m_diag_H;
132  int32_t m_dim;
133 
135  float64_t* m_f;
136 
138  float64_t m_UB;
139 
141  int32_t m_tmax;
143  float64_t m_tolabs;
145  float64_t m_tolrel;
147  float64_t m_tolKKT;
149  E_QPB_SOLVER m_solver;
150 };
151 }
152 #endif //USE_GPL_SHOGUN
153 #endif //QPBSVMLIB_H__
double float64_t
Definition: common.h:50
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18

SHOGUN Machine Learning Toolbox - Documentation