Skip to content

Commit

Permalink
Indentation fixed + getter/setter for bmrm parameters in CDualLibQPBM…
Browse files Browse the repository at this point in the history
…SOSVM
  • Loading branch information
uricamic committed Jun 13, 2012
1 parent c504412 commit 4c424e4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
16 changes: 6 additions & 10 deletions src/shogun/so/DualLibQPBMSOSVM.cpp
Expand Up @@ -26,25 +26,21 @@ CDualLibQPBMSOSVM::CDualLibQPBMSOSVM(
float64_t lambda)
:CLinearStructuredOutputMachine(model, loss, labs, features)
{
set_opitons(0.001, 0.0, 100);
set_TolRel(0.001);
set_TolAbs(0.0);
set_BufSize(100);
set_lambda(lambda);
}

CDualLibQPBMSOSVM::~CDualLibQPBMSOSVM()
{
}

void CDualLibQPBMSOSVM::set_opitons(float64_t TolRel, float64_t TolAbs, uint32_t BufSize)
{
m_TolRel=TolRel;
m_TolAbs=TolAbs;
m_BufSize=BufSize;
}

bool CDualLibQPBMSOSVM::train_machine(CFeatures* data)
{
// get dimension of w
//uint32_t nDim=m_risk_function->get_dim(data); //TODO: get_dim function accessible trough StructuredModel
// get dimension of w
uint32_t nDim=0;
//uint32_t nDim=m_risk_function->get_dim(data); //TODO: get_dim function accessible trough StructuredModel

// call the BMRM solver
bmrm_return_value_T result = svm_bmrm_solver(data, m_w.vector, m_TolRel, m_TolAbs, m_lambda,
Expand Down
22 changes: 20 additions & 2 deletions src/shogun/so/DualLibQPBMSOSVM.h
Expand Up @@ -34,8 +34,26 @@ class CDualLibQPBMSOSVM : public CLinearStructuredOutputMachine
/** set lambda */
inline void set_lambda(float64_t lambda) { m_lambda=lambda; }

/** set solver options */
void set_opitons(float64_t TolRel, float64_t TolAbs, uint32_t BufSize);
/** get lambda */
inline float64_t get_lambda() { return m_lambda; }

/** set relative tolerance */
inline void set_TolRel(float64_t TolRel) { m_TolRel=TolRel; }

/** get relative tolerance */
inline float64_t get_TolRel() { return m_TolRel; }

/** set absolute tolerance */
inline void set_TolAbs(float64_t TolAbs) { m_TolAbs=TolAbs; }

/** get absolute tolerance */
inline float64_t get_TolAbs() { return m_TolAbs; }

/** set size of cutting plane buffer */
inline void set_BufSize(uint32_t BufSize) { m_BufSize=BufSize; }

/** get size of cutting plane buffer */
inline uint32_t get_BufSize() { return m_BufSize; }

protected:
/** train dual SO-SVM
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/so/RiskFunction.h
Expand Up @@ -35,12 +35,12 @@ class CRiskFunction : public CSGObject
*
*/
//virtual void risk(void* data, float64_t* R, SGVector< float64_t > subgrad, SGVector< float64_t > w) = 0;
virtual void risk(void* data, float64_t* R, float64_t* subgrad, float64_t* W) = 0;
virtual void risk(void* data, float64_t* R, float64_t* subgrad, float64_t* W) = 0;

/** get the dimension of joint feature vector w
/** get the dimension of joint feature vector w
*
*/
//virtual uint32_t get_dim(void* data) = 0; //TODO: Delete, will be accessible from StructuredModel
//virtual uint32_t get_dim(void* data) = 0; //TODO: Delete, will be accessible from StructuredModel

/** @return name of SGSerializable */
virtual const char* get_name() const { return "RiskFunction"; }
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/so/libbmrm.cpp
Expand Up @@ -30,7 +30,7 @@ static uint32_t BufSize;
----------------------------------------------------------------------*/
static const float64_t *get_col( uint32_t i)
{
return( &H[ BufSize*i ] );
return( &H[ BufSize*i ] );
}

bmrm_return_value_T svm_bmrm_solver(
Expand All @@ -42,7 +42,7 @@ bmrm_return_value_T svm_bmrm_solver(
uint32_t _BufSize,
uint32_t nDim,
CRiskFunction* risk_function)
//void (*risk_function)(void*, float64_t*, float64_t*, float64_t*))
//void (*risk_function)(void*, float64_t*, float64_t*, float64_t*))
{
bmrm_return_value_T bmrm = {0, 0, 0, 0, 0, 0};
libqp_state_T qp_exitflag;
Expand Down Expand Up @@ -205,7 +205,7 @@ bmrm_return_value_T svm_bmrm_solver(
if (bmrm.Fp - bmrm.Fd <= TolAbs) bmrm.exitflag = 2;
if (bmrm.nCP >= BufSize) bmrm.exitflag = -1;

} /* end of main loop */
} /* end of main loop */

cleanup:

Expand Down

0 comments on commit 4c424e4

Please sign in to comment.