SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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__

SHOGUN Machine Learning Toolbox - Documentation