/usr/include/shogun/structure/CCSOSVM.h is in libshogun-dev 3.2.0-7.3build4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | /*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2012 Viktor Gal
* Copyright (C) 2008 Chun-Nam Yu
*/
#ifndef __CCSOSVM_H__
#define __CCSOSVM_H__
#include <shogun/lib/config.h>
#include <shogun/machine/LinearStructuredOutputMachine.h>
#include <shogun/base/DynArray.h>
#ifdef USE_MOSEK
#include <mosek.h>
#endif
namespace shogun
{
/**
* Enum
* Training method selection
*/
enum EQPType
{
MOSEK=1, /**< MOSEK. */
SVMLIGHT=2 /**< SVM^Light */
};
/** @brief CCSOSVM
*
* Structured Output Support Vector Machine based on [1]
*
* [1] T. Joachims, T. Finley and C.-N. Yu,
* Cutting-Plane Training of Structural SVMs,
* Machine Learning Journal, 77(1):27-59
*/
class CCCSOSVM : public CLinearStructuredOutputMachine
{
public:
/** default constructor*/
CCCSOSVM();
/** constructor
* @param model structured output model
* @param w initial w (optional)
*/
CCCSOSVM(CStructuredModel* model, SGVector<float64_t> w = SGVector<float64_t>());
/** destructor */
virtual ~CCCSOSVM();
/** @return object name */
inline virtual const char* get_name() const { return "CCSOSVM"; }
/** set initial value of weight vector w
*
* @param W initial weight vector
*/
inline void set_w(SGVector< float64_t > W)
{
REQUIRE(W.vlen == m_model->get_dim(), "Dimension of the initial "
"solution must match the model's dimension!\n");
m_w=W;
}
/** set epsilon
*
* @param eps epsilon
*/
inline void set_epsilon(float64_t eps)
{
m_eps = eps;
}
/** get epsilon
*
* @return epsilon
*/
inline float64_t get_epsilon() const
{
return m_eps;
}
/** set C
*
* @param C constant
*/
inline void set_C(float64_t C)
{
m_C = C;
}
/** get C
*
* @return C constant
*/
inline float64_t get_C() const
{
return m_C;
}
/** set maximum number of iterations
*
* @param max_iter maximum number of iterations
*/
inline void set_max_iter(index_t max_iter)
{
m_max_iter = max_iter;
}
/** get maximum number of iterations
*
* @return maximum number of iterations
*/
inline index_t get_max_iter() const
{
return m_max_iter;
}
/** get the primal objective value
*
* @return primal objective value
*/
inline float64_t compute_primal_objective()
{
return m_primal_obj;
}
/** get maximum rho value
*
* @return max rho value
*/
inline float64_t get_max_rho() const
{
return m_max_rho;
}
/** set maximum rho value
*
* @param max_rho maximum rho value
*/
inline void set_max_rho(float64_t max_rho)
{
m_max_rho = max_rho;
}
/** get the currently used qp solver
*
* @return qp solver
*/
inline EQPType get_qp_type() const
{
return m_qp_type;
}
/** set the qp solver to be used
*
* @param type qp solver
*/
inline void set_qp_type(EQPType type)
{
m_qp_type = type;
}
/** get classifier type
*
* @return classifier type CT_CCSOSVM
*/
virtual EMachineType get_classifier_type();
protected:
bool train_machine(CFeatures* data=NULL);
private:
/** find new cutting plane
*
* @param margin new margin value
* @return new cutting plane
*/
SGSparseVector<float64_t> find_cutting_plane(float64_t* margin);
int32_t resize_cleanup(int32_t size_active, SGVector<int32_t>& idle, SGVector<float64_t>&alpha,
SGVector<float64_t>& delta, SGVector<float64_t>& gammaG0,
SGVector<float64_t>& proximal_rhs, float64_t ***ptr_G,
DynArray<SGSparseVector<float64_t> >& dXc, SGVector<float64_t>& cut_error);
int32_t mosek_qp_optimize(float64_t** G, float64_t* delta, float64_t* alpha, int32_t k, float64_t* dual_obj, float64_t rho);
/** init class */
void init();
private:
/** C */
float64_t m_C;
/** epsilon */
float64_t m_eps;
/** primary objective value */
float64_t m_primal_obj;
float64_t m_alpha_thrld;
float64_t m_max_rho;
/** maximum number of iterations */
index_t m_max_iter;
/** number of iterations before checking for cleaning up idle cutting planes */
index_t m_cleanup_check;
/** maximum number of idle iterations before marking as an idle cutting plane */
index_t m_idle_iter;
/** QP solver type */
EQPType m_qp_type;
#ifdef USE_MOSEK
/** Mosek environment */
MSKenv_t m_msk_env;
#endif
};
}
#endif
|