SHOGUN
v3.2.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2012 Fernando José Iglesias García 00008 * Copyright (C) 2012 Fernando José Iglesias García 00009 */ 00010 00011 #ifndef _PRIMAL_MOSEK_SOSVM__H__ 00012 #define _PRIMAL_MOSEK_SOSVM__H__ 00013 00014 #ifdef USE_MOSEK 00015 00016 #include <shogun/machine/LinearStructuredOutputMachine.h> 00017 #include <shogun/mathematics/Mosek.h> 00018 00019 namespace shogun 00020 { 00021 00032 class CPrimalMosekSOSVM : public CLinearStructuredOutputMachine 00033 { 00034 public: 00036 CPrimalMosekSOSVM(); 00037 00043 CPrimalMosekSOSVM(CStructuredModel* model, CStructuredLabels* labs); 00044 00046 ~CPrimalMosekSOSVM(); 00047 00052 inline SGVector< float64_t > get_slacks() const { return m_slacks; } 00053 00058 virtual float64_t compute_primal_objective() const; 00059 00061 virtual const char* get_name() const { return "PrimalMosekSOSVM"; } 00062 00067 virtual EMachineType get_classifier_type(); 00068 00073 void set_regularization(float64_t C); 00074 00079 void set_epsilon(float64_t epsilon); 00080 00081 protected: 00087 virtual bool train_machine(CFeatures* data = NULL); 00088 00089 private: 00090 void init(); 00091 00097 float64_t compute_loss_arg(CResultSet* result) const; 00098 00104 bool insert_result(CList* result_list, CResultSet* result) const; 00105 00129 bool add_constraint(CMosek* mosek, CResultSet* result, index_t con_idx, index_t train_idx) const; 00130 00131 private: 00133 SGVector< float64_t > m_slacks; 00134 00136 float64_t po_value; 00137 00139 float64_t m_regularization; 00140 00142 float64_t m_epsilon; 00143 00144 }; /* class CPrimalMosekSOSVM */ 00145 00146 } /* namespace shogun */ 00147 00148 #endif /* USE_MOSEK */ 00149 #endif /* _PRIMAL_MOSEK_SOSVM__H__ */