Skip to content

Commit

Permalink
Merge pull request #619 from uricamic/BM_SOL_EXAMPLE
Browse files Browse the repository at this point in the history
Inactive cutting plane removal for libbmrm
  • Loading branch information
Soeren Sonnenburg committed Jul 6, 2012
2 parents 312d90a + 5fa61fc commit 564295a
Show file tree
Hide file tree
Showing 4 changed files with 288 additions and 80 deletions.
11 changes: 7 additions & 4 deletions src/shogun/structure/DualLibQPBMSOSVM.cpp
Expand Up @@ -9,7 +9,6 @@
*/

#include <shogun/structure/DualLibQPBMSOSVM.h>
#include <shogun/structure/libbmrm.h>

using namespace shogun;

Expand All @@ -31,6 +30,10 @@ CDualLibQPBMSOSVM::CDualLibQPBMSOSVM(
set_TolAbs(0.0);
set_BufSize(1000);
set_lambda(lambda);
set_cleanICP(true);
set_cleanAfter(10);
set_K(0.4);
set_Tmax(100);
m_risk_function=risk_function;
}

Expand All @@ -53,10 +56,10 @@ bool CDualLibQPBMSOSVM::train_machine(CFeatures* data)
bmrm_data.w_dim=nDim;

// call the BMRM solver
bmrm_return_value_T result = svm_bmrm_solver(&bmrm_data, m_w.vector, m_TolRel, m_TolAbs, m_lambda,
m_BufSize, m_risk_function);
m_bmrm_result = svm_bmrm_solver(&bmrm_data, m_w.vector, m_TolRel, m_TolAbs, m_lambda,
m_BufSize, m_cleanICP, m_cleanAfter, m_K, m_Tmax, m_risk_function);

if (result.exitflag==1)
if (m_bmrm_result.exitflag==1)
{
return true;
} else {
Expand Down
43 changes: 43 additions & 0 deletions src/shogun/structure/DualLibQPBMSOSVM.h
Expand Up @@ -13,6 +13,7 @@

#include <shogun/machine/LinearStructuredOutputMachine.h>
#include <shogun/structure/RiskFunction.h>
#include <shogun/structure/libbmrm.h>

namespace shogun
{
Expand Down Expand Up @@ -55,6 +56,33 @@ class CDualLibQPBMSOSVM : public CLinearStructuredOutputMachine
/** get size of cutting plane buffer */
inline uint32_t get_BufSize() { return m_BufSize; }

/** set ICP removal flag */
inline void set_cleanICP(bool cleanICP) { m_cleanICP=cleanICP; }

/** get ICP removal flag */
inline bool get_cleanICP() { return m_cleanICP; }

/** set number of iterations for cleaning ICP */
inline void set_cleanAfter(uint32_t cleanAfter) { m_cleanAfter=cleanAfter; }

/** get number of iterations for cleaninng ICP */
inline uint32_t get_cleanAfter() { return m_cleanAfter; }

/** set K */
inline void set_K(float64_t K) { m_K=K; }

/** get K */
inline float64_t get_K() { return m_K; }

/** set Tmax */
inline void set_Tmax(uint32_t Tmax) { m_Tmax=Tmax; }

/** get Tmax */
inline uint32_t get_Tmax() { return m_Tmax; }

/** get bmrm result */
inline bmrm_return_value_T get_bmrm_result() { return m_bmrm_result; }

protected:
/** train dual SO-SVM
*
Expand All @@ -75,9 +103,24 @@ class CDualLibQPBMSOSVM : public CLinearStructuredOutputMachine
/** BufSize */
uint32_t m_BufSize;

/** Clean ICP */
bool m_cleanICP;

/** Clean ICP after n-th iteration */
uint32_t m_cleanAfter;

/** K */
float64_t m_K;

/** Tmax */
uint32_t m_Tmax;

/** Risk function */
CRiskFunction* m_risk_function;

/** BMRM result */
bmrm_return_value_T m_bmrm_result;

}; /* class CDualLibQPBMSOSVM */

} /* namespace shogun */
Expand Down

0 comments on commit 564295a

Please sign in to comment.