SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CCSOSVM.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2012 Viktor Gal
8  * Copyright (C) 2008 Chun-Nam Yu
9  */
10 
11 #ifndef __CCSOSVM_H__
12 #define __CCSOSVM_H__
13 
14 #include <shogun/lib/config.h>
16 #include <shogun/base/DynArray.h>
17 
18 #ifdef USE_MOSEK
19 #include <mosek.h>
20 #endif
21 
22 namespace shogun
23 {
24 
29  enum EQPType
30  {
31  MOSEK=1,
33  };
34 
44  {
45  public:
47  CCCSOSVM();
48 
54 
56  virtual ~CCCSOSVM();
57 
59  inline virtual const char* get_name() const { return "CCSOSVM"; }
60 
66  {
67  REQUIRE(W.vlen == m_model->get_dim(), "Dimension of the initial "
68  "solution must match the model's dimension!\n");
69  m_w=W;
70  }
71 
76  inline void set_epsilon(float64_t eps)
77  {
78  m_eps = eps;
79  }
80 
85  inline float64_t get_epsilon() const
86  {
87  return m_eps;
88  }
89 
94  inline void set_C(float64_t C)
95  {
96  m_C = C;
97  }
98 
103  inline float64_t get_C() const
104  {
105  return m_C;
106  }
107 
112  inline void set_max_iter(index_t max_iter)
113  {
114  m_max_iter = max_iter;
115  }
116 
121  inline index_t get_max_iter() const
122  {
123  return m_max_iter;
124  }
125 
131  {
132  return m_primal_obj;
133  }
134 
139  inline float64_t get_max_rho() const
140  {
141  return m_max_rho;
142  }
143 
148  inline void set_max_rho(float64_t max_rho)
149  {
150  m_max_rho = max_rho;
151  }
152 
157  inline EQPType get_qp_type() const
158  {
159  return m_qp_type;
160  }
161 
166  inline void set_qp_type(EQPType type)
167  {
168  m_qp_type = type;
169  }
170 
176 
177  protected:
178  bool train_machine(CFeatures* data=NULL);
179 
180  private:
186  SGSparseVector<float64_t> find_cutting_plane(float64_t* margin);
187 
188  int32_t resize_cleanup(int32_t size_active, SGVector<int32_t>& idle, SGVector<float64_t>&alpha,
190  SGVector<float64_t>& proximal_rhs, float64_t ***ptr_G,
192 
193  int32_t mosek_qp_optimize(float64_t** G, float64_t* delta, float64_t* alpha, int32_t k, float64_t* dual_obj, float64_t rho);
194 
196  void init();
197 
198  private:
200  float64_t m_C;
202  float64_t m_eps;
204  float64_t m_primal_obj;
205  float64_t m_alpha_thrld;
206  float64_t m_max_rho;
207 
209  index_t m_max_iter;
211  index_t m_cleanup_check;
213  index_t m_idle_iter;
214 
216  EQPType m_qp_type;
217 #ifdef USE_MOSEK
218 
219  MSKenv_t m_msk_env;
220 #endif
221  };
222 }
223 
224 #endif

SHOGUN Machine Learning Toolbox - Documentation