shark::QpMcSimplexDecomp< Matrix > Class Template Reference

#include <shark/Algorithms/QP/QpMcSimplexDecomp.h>

Classes

struct  Example
 data structure describing one training example More...
 
struct  PreferedSelectionStrategy
 Working set selection eturning th S2DO working set. More...
 
struct  Variable
 data structure describing one variable of the problem More...
 

Public Types

typedef Matrix::QpFloatType QpFloatType
 

Public Member Functions

 QpMcSimplexDecomp (Matrix &kernel, QpSparseArray< QpFloatType > const &M, Data< unsigned int > const &target, RealMatrix const &linearMat, double C)
 
void setShrinking (bool shrinking=true)
 enable/disable shrinking
 
RealMatrix solution () const
 Returns the solution found.
 
RealMatrix solutionGradient () const
 Returns the gradient of the solution.
 
double functionValue () const
 Compute the objective value of the current solution.
 
unsigned int label (std::size_t i)
 
std::size_t dimensions () const
 
std::size_t cardP () const
 
std::size_t getNumExamples () const
 
void addDeltaLinear (RealMatrix const &deltaLinear)
 change the linear part of the problem by some delta
 
void updateSMO (std::size_t v, std::size_t w)
 
bool shrink (double epsilon)
 Shrink the problem.
 
void unshrink ()
 Activate all m_numVariables.
 
double selectWorkingSet (std::size_t &i, std::size_t &j)
 select the working set
 
double checkKKT () const
 return the largest KKT violation
 

Protected Member Functions

std::pair< std::pair< std::size_t, std::size_t >, double > maxGainBox (std::size_t i) const
 Finds the second variable of a working set using maximum gain and returns the pair and gain.
 
std::pair< std::pair< std::size_t, std::size_t >, double > maxGainSimplex (std::size_t e) const
 Returns the best variable pair (i,j) and gain for a given example.
 
std::pair< std::pair< double, std::size_t >, std::pair< double, std::size_t > > getSimplexMVP (Example const &ex) const
 For a given simplex returns the MVP indicies (max_up,min_down)
 
void updateVarsum (std::size_t exampleId, double mu)
 
void gradientUpdate (std::size_t r, double mu, QpFloatType *q)
 
void deactivateVariable (std::size_t v)
 shrink a variable
 
void deactivateExample (std::size_t e)
 shrink an example
 
std::size_t originalIndex (std::size_t v) const
 Returns the original index of the example of a variable in the dataset before optimization.
 

Protected Attributes

Matrix & m_kernelMatrix
 kernel matrix (precomputed matrix or matrix cache)
 
QpSparseArray< QpFloatType > const & m_M
 kernel modifiers
 
double m_C
 complexity constant; upper bound on all variabless
 
std::size_t m_classes
 number of classes in the problem
 
std::size_t m_cardP
 number of dual variables per example
 
std::size_t m_numExamples
 number of examples in the problem (size of the kernel matrix)
 
std::size_t m_numVariables
 number of variables in the problem = m_numExamples * m_cardP
 
RealVector m_linear
 linear part of the objective function
 
RealVector m_alpha
 solution candidate
 
RealVector m_gradient
 
std::vector< Examplem_examples
 information about each training example
 
std::vector< Variablem_variables
 information about each variable of the problem
 
std::vector< std::size_t > m_storage1
 space for the example[i].var pointers
 
std::vector< std::size_t > m_storage2
 space for the example[i].avar pointers
 
std::size_t m_activeEx
 number of currently active examples
 
std::size_t m_activeVar
 number of currently active variables
 
bool m_useShrinking
 should the m_problem use the shrinking heuristics?
 
bool bUnshrinked
 true if the problem has already been unshrinked
 

Detailed Description

template<class Matrix>
class shark::QpMcSimplexDecomp< Matrix >

Definition at line 50 of file QpMcSimplexDecomp.h.

Member Typedef Documentation

◆ QpFloatType

template<class Matrix >
typedef Matrix::QpFloatType shark::QpMcSimplexDecomp< Matrix >::QpFloatType

Definition at line 53 of file QpMcSimplexDecomp.h.

Constructor & Destructor Documentation

◆ QpMcSimplexDecomp()

Member Function Documentation

◆ addDeltaLinear()

◆ cardP()

template<class Matrix >
std::size_t shark::QpMcSimplexDecomp< Matrix >::cardP ( ) const
inline

Definition at line 167 of file QpMcSimplexDecomp.h.

References shark::QpMcSimplexDecomp< Matrix >::m_cardP.

◆ checkKKT()

◆ deactivateExample()

◆ deactivateVariable()

◆ dimensions()

template<class Matrix >
std::size_t shark::QpMcSimplexDecomp< Matrix >::dimensions ( ) const
inline

◆ functionValue()

template<class Matrix >
double shark::QpMcSimplexDecomp< Matrix >::functionValue ( ) const
inline

Compute the objective value of the current solution.

Definition at line 156 of file QpMcSimplexDecomp.h.

References shark::QpMcSimplexDecomp< Matrix >::m_alpha, shark::QpMcSimplexDecomp< Matrix >::m_gradient, and shark::QpMcSimplexDecomp< Matrix >::m_linear.

◆ getNumExamples()

template<class Matrix >
std::size_t shark::QpMcSimplexDecomp< Matrix >::getNumExamples ( ) const
inline

◆ getSimplexMVP()

template<class Matrix >
std::pair< std::pair< double, std::size_t >, std::pair< double, std::size_t > > shark::QpMcSimplexDecomp< Matrix >::getSimplexMVP ( Example const &  ex) const
inlineprotected

◆ gradientUpdate()

◆ label()

template<class Matrix >
unsigned int shark::QpMcSimplexDecomp< Matrix >::label ( std::size_t  i)
inline

◆ maxGainBox()

template<class Matrix >
std::pair< std::pair< std::size_t, std::size_t >, double > shark::QpMcSimplexDecomp< Matrix >::maxGainBox ( std::size_t  i) const
inlineprotected

◆ maxGainSimplex()

◆ originalIndex()

template<class Matrix >
std::size_t shark::QpMcSimplexDecomp< Matrix >::originalIndex ( std::size_t  v) const
inlineprotected

Returns the original index of the example of a variable in the dataset before optimization.

Shrinking is an internal detail so the communication with the outside world uses the original indizes.

Definition at line 823 of file QpMcSimplexDecomp.h.

References shark::QpMcSimplexDecomp< Matrix >::m_examples, and shark::QpMcSimplexDecomp< Matrix >::m_variables.

Referenced by shark::QpMcSimplexDecomp< Matrix >::addDeltaLinear(), shark::QpMcSimplexDecomp< Matrix >::solution(), and shark::QpMcSimplexDecomp< Matrix >::solutionGradient().

◆ selectWorkingSet()

template<class Matrix >
double shark::QpMcSimplexDecomp< Matrix >::selectWorkingSet ( std::size_t &  i,
std::size_t &  j 
)
inline

select the working set

Select one or two numVariables for the sub-problem and return the maximal KKT violation. The method MAY select the same index for i and j. In that case the working set consists of a single variables. The working set may be invalid if the method reports a KKT violation of zero, indicating optimality.

Definition at line 406 of file QpMcSimplexDecomp.h.

References shark::QpMcSimplexDecomp< Matrix >::getSimplexMVP(), shark::QpMcSimplexDecomp< Matrix >::m_activeEx, shark::QpMcSimplexDecomp< Matrix >::m_C, shark::QpMcSimplexDecomp< Matrix >::m_examples, shark::QpMcSimplexDecomp< Matrix >::m_variables, shark::QpMcSimplexDecomp< Matrix >::maxGainBox(), shark::QpMcSimplexDecomp< Matrix >::maxGainSimplex(), and shark::QpMcSimplexDecomp< Matrix >::Example::varsum.

◆ setShrinking()

template<class Matrix >
void shark::QpMcSimplexDecomp< Matrix >::setShrinking ( bool  shrinking = true)
inline

enable/disable shrinking

Definition at line 131 of file QpMcSimplexDecomp.h.

References shark::QpMcSimplexDecomp< Matrix >::m_useShrinking.

◆ shrink()

◆ solution()

◆ solutionGradient()

◆ unshrink()

◆ updateSMO()

◆ updateVarsum()

template<class Matrix >
void shark::QpMcSimplexDecomp< Matrix >::updateVarsum ( std::size_t  exampleId,
double  mu 
)
inlineprotected

Member Data Documentation

◆ bUnshrinked

template<class Matrix >
bool shark::QpMcSimplexDecomp< Matrix >::bUnshrinked
protected

true if the problem has already been unshrinked

Definition at line 881 of file QpMcSimplexDecomp.h.

Referenced by shark::QpMcSimplexDecomp< Matrix >::QpMcSimplexDecomp(), and shark::QpMcSimplexDecomp< Matrix >::shrink().

◆ m_activeEx

◆ m_activeVar

◆ m_alpha

◆ m_C

◆ m_cardP

◆ m_classes

◆ m_examples

◆ m_gradient

◆ m_kernelMatrix

◆ m_linear

◆ m_M

◆ m_numExamples

template<class Matrix >
std::size_t shark::QpMcSimplexDecomp< Matrix >::m_numExamples
protected

◆ m_numVariables

◆ m_storage1

template<class Matrix >
std::vector<std::size_t> shark::QpMcSimplexDecomp< Matrix >::m_storage1
protected

space for the example[i].var pointers

Definition at line 866 of file QpMcSimplexDecomp.h.

Referenced by shark::QpMcSimplexDecomp< Matrix >::QpMcSimplexDecomp().

◆ m_storage2

template<class Matrix >
std::vector<std::size_t> shark::QpMcSimplexDecomp< Matrix >::m_storage2
protected

space for the example[i].avar pointers

Definition at line 869 of file QpMcSimplexDecomp.h.

Referenced by shark::QpMcSimplexDecomp< Matrix >::QpMcSimplexDecomp().

◆ m_useShrinking

template<class Matrix >
bool shark::QpMcSimplexDecomp< Matrix >::m_useShrinking
protected

should the m_problem use the shrinking heuristics?

Definition at line 878 of file QpMcSimplexDecomp.h.

Referenced by shark::QpMcSimplexDecomp< Matrix >::setShrinking(), and shark::QpMcSimplexDecomp< Matrix >::shrink().

◆ m_variables


The documentation for this class was generated from the following file: