SHOGUN  v3.0.0
 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 
15 #include <shogun/base/DynArray.h>
16 
17 namespace shogun
18 {
19 
24  enum EQPType
25  {
26  MOSEK=1,
28  };
29 
39  {
40  public:
42  CCCSOSVM();
43 
49 
51  virtual ~CCCSOSVM();
52 
54  inline virtual const char* get_name() const { return "CCSOSVM"; }
55 
61  {
62  REQUIRE(W.vlen == m_model->get_dim(), "Dimension of the initial "
63  "solution must match the model's dimension!\n");
64  m_w=W;
65  }
66 
71  inline void set_epsilon(float64_t eps)
72  {
73  m_eps = eps;
74  }
75 
80  inline float64_t get_epsilon() const
81  {
82  return m_eps;
83  }
84 
89  inline void set_C(float64_t C)
90  {
91  m_C = C;
92  }
93 
98  inline float64_t get_C() const
99  {
100  return m_C;
101  }
102 
107  inline void set_max_iter(index_t max_iter)
108  {
109  m_max_iter = max_iter;
110  }
111 
116  inline index_t get_max_iter() const
117  {
118  return m_max_iter;
119  }
120 
126  {
127  return m_primal_obj;
128  }
129 
134  inline float64_t get_max_rho() const
135  {
136  return m_max_rho;
137  }
138 
143  inline void set_max_rho(float64_t max_rho)
144  {
145  m_max_rho = max_rho;
146  }
147 
152  inline EQPType get_qp_type() const
153  {
154  return m_qp_type;
155  }
156 
161  inline void set_qp_type(EQPType type)
162  {
163  m_qp_type = type;
164  }
165 
171 
172  protected:
173  bool train_machine(CFeatures* data=NULL);
174 
175  private:
181  SGSparseVector<float64_t> find_cutting_plane(float64_t* margin);
182 
183  int32_t resize_cleanup(int32_t size_active, SGVector<int32_t>& idle, SGVector<float64_t>&alpha,
185  SGVector<float64_t>& proximal_rhs, float64_t ***ptr_G,
187 
188  int32_t mosek_qp_optimize(float64_t** G, float64_t* delta, float64_t* alpha, int32_t k, float64_t* dual_obj, float64_t rho);
189 
191  void init();
192 
193  private:
195  float64_t m_C;
197  float64_t m_eps;
199  float64_t m_primal_obj;
200  float64_t m_alpha_thrld;
201  float64_t m_max_rho;
202 
204  index_t m_max_iter;
206  index_t m_cleanup_check;
208  index_t m_idle_iter;
209 
211  EQPType m_qp_type;
212  };
213 }
214 
215 #endif

SHOGUN Machine Learning Toolbox - Documentation