shark::SvmProblem< Problem > Class Template Reference

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

+ Inheritance diagram for shark::SvmProblem< Problem >:

Public Types

typedef Problem::QpFloatType QpFloatType
 
typedef Problem::MatrixType MatrixType
 
typedef LibSVMSelectionCriterion PreferedSelectionStrategy
 

Public Member Functions

 SvmProblem (Problem &problem)
 
std::size_t dimensions () const
 
std::size_t active () const
 
double boxMin (std::size_t i) const
 
double boxMax (std::size_t i) const
 
bool isLowerBound (std::size_t i) const
 
bool isUpperBound (std::size_t i) const
 
MatrixTypequadratic ()
 representation of the quadratic part of the objective function More...
 
double linear (std::size_t i) const
 
double alpha (std::size_t i) const
 
double diagonal (std::size_t i) const
 
double gradient (std::size_t i) const
 
std::size_t permutation (std::size_t i) const
 
RealVector getUnpermutedAlpha () const
 
void updateSMO (std::size_t i, std::size_t j)
 Does an update of SMO given a working set with indices i and j. More...
 
double functionValue () const
 Returns the current function value of the problem. More...
 
bool shrink (double)
 
void reshrink ()
 
void unshrink ()
 
void deactivateVariable (std::size_t i)
 Remove the i-th example from the problem while taking the equality constraint into account. More...
 
void activateVariable (std::size_t i)
 Reactivate an previously deactivated variable. More...
 
void flipCoordinates (std::size_t i, std::size_t j)
 exchange two variables via the permutation More...
 
void scaleBoxConstraints (double factor, double variableScalingFactor)
 Scales all box constraints by a constant factor and adapts the solution using a separate scaling. More...
 
virtual void setLinear (std::size_t i, double newValue)
 adapts the linear part of the problem and updates the internal data structures accordingly. More...
 
double checkKKT () const
 

Protected Member Functions

virtual void applyStep (std::size_t i, std::size_t j, double step)
 Update the problem by a proposed step i taking the box constraints into account. More...
 
void updateAlphaStatus (std::size_t i)
 

Protected Attributes

Problem m_problem
 
RealVector m_gradient
 gradient of the objective function at the current alpha More...
 
std::size_t m_active
 
std::vector< char > m_alphaStatus
 Stores the status, whther alpha is on the lower or upper bound, or whether it is free. More...
 

Detailed Description

template<class Problem>
class shark::SvmProblem< Problem >

Definition at line 288 of file SvmProblems.h.

Member Typedef Documentation

§ MatrixType

template<class Problem >
typedef Problem::MatrixType shark::SvmProblem< Problem >::MatrixType

Definition at line 291 of file SvmProblems.h.

§ PreferedSelectionStrategy

template<class Problem >
typedef LibSVMSelectionCriterion shark::SvmProblem< Problem >::PreferedSelectionStrategy

Definition at line 292 of file SvmProblems.h.

§ QpFloatType

template<class Problem >
typedef Problem::QpFloatType shark::SvmProblem< Problem >::QpFloatType

Definition at line 290 of file SvmProblems.h.

Constructor & Destructor Documentation

§ SvmProblem()

template<class Problem >
shark::SvmProblem< Problem >::SvmProblem ( Problem &  problem)
inline

Definition at line 294 of file SvmProblems.h.

Member Function Documentation

§ activateVariable()

template<class Problem >
void shark::SvmProblem< Problem >::activateVariable ( std::size_t  i)
inline

Reactivate an previously deactivated variable.

Definition at line 408 of file SvmProblems.h.

References shark::AlphaFree, and SIZE_CHECK.

§ active()

template<class Problem >
std::size_t shark::SvmProblem< Problem >::active ( ) const
inline

Definition at line 314 of file SvmProblems.h.

§ alpha()

template<class Problem >
double shark::SvmProblem< Problem >::alpha ( std::size_t  i) const
inline

Definition at line 340 of file SvmProblems.h.

§ applyStep()

template<class Problem >
virtual void shark::SvmProblem< Problem >::applyStep ( std::size_t  i,
std::size_t  j,
double  step 
)
inlineprotectedvirtual

Update the problem by a proposed step i taking the box constraints into account.

A step length 0<=lambda<=1 is found so that boxMin(i) <= alpha(i)+lambda*step <= boxMax(i) and boxMin(j) <= alpha(j)-lambda*step <= boxMax(j) the update is performed in a numerically stable way and the internal data structures are also updated.

Reimplemented in shark::SvmShrinkingProblem< Problem >.

Definition at line 477 of file SvmProblems.h.

References shark::blas::min(), and SIZE_CHECK.

§ boxMax()

template<class Problem >
double shark::SvmProblem< Problem >::boxMax ( std::size_t  i) const
inline

Definition at line 321 of file SvmProblems.h.

References shark::AlphaDeactivated.

§ boxMin()

template<class Problem >
double shark::SvmProblem< Problem >::boxMin ( std::size_t  i) const
inline

Definition at line 318 of file SvmProblems.h.

References shark::AlphaDeactivated.

§ checkKKT()

template<class Problem >
double shark::SvmProblem< Problem >::checkKKT ( ) const
inline

Definition at line 446 of file SvmProblems.h.

References shark::blas::max(), and shark::blas::min().

§ deactivateVariable()

template<class Problem >
void shark::SvmProblem< Problem >::deactivateVariable ( std::size_t  i)
inline

Remove the i-th example from the problem while taking the equality constraint into account.

The i-th element is first set to zero and as well as an unspecified set corrected so that the constraint is fulfilled. after the call boxMin(i) and boxMax(i) are zero.

Definition at line 394 of file SvmProblems.h.

References shark::AlphaDeactivated, and SIZE_CHECK.

§ diagonal()

template<class Problem >
double shark::SvmProblem< Problem >::diagonal ( std::size_t  i) const
inline

Definition at line 344 of file SvmProblems.h.

§ dimensions()

template<class Problem >
std::size_t shark::SvmProblem< Problem >::dimensions ( ) const
inline

Definition at line 310 of file SvmProblems.h.

§ flipCoordinates()

template<class Problem >
void shark::SvmProblem< Problem >::flipCoordinates ( std::size_t  i,
std::size_t  j 
)
inline

exchange two variables via the permutation

Definition at line 415 of file SvmProblems.h.

References SIZE_CHECK, and shark::swap().

§ functionValue()

template<class Problem >
double shark::SvmProblem< Problem >::functionValue ( ) const
inline

Returns the current function value of the problem.

Definition at line 381 of file SvmProblems.h.

References shark::blas::inner_prod().

§ getUnpermutedAlpha()

template<class Problem >
RealVector shark::SvmProblem< Problem >::getUnpermutedAlpha ( ) const
inline

Definition at line 356 of file SvmProblems.h.

§ gradient()

template<class Problem >
double shark::SvmProblem< Problem >::gradient ( std::size_t  i) const
inline

Definition at line 348 of file SvmProblems.h.

§ isLowerBound()

template<class Problem >
bool shark::SvmProblem< Problem >::isLowerBound ( std::size_t  i) const
inline

Definition at line 324 of file SvmProblems.h.

References shark::AlphaLowerBound.

§ isUpperBound()

template<class Problem >
bool shark::SvmProblem< Problem >::isUpperBound ( std::size_t  i) const
inline

Definition at line 327 of file SvmProblems.h.

References shark::AlphaUpperBound.

§ linear()

template<class Problem >
double shark::SvmProblem< Problem >::linear ( std::size_t  i) const
inline

Definition at line 336 of file SvmProblems.h.

§ permutation()

template<class Problem >
std::size_t shark::SvmProblem< Problem >::permutation ( std::size_t  i) const
inline

Definition at line 352 of file SvmProblems.h.

§ quadratic()

template<class Problem >
MatrixType& shark::SvmProblem< Problem >::quadratic ( )
inline

representation of the quadratic part of the objective function

Definition at line 332 of file SvmProblems.h.

§ reshrink()

template<class Problem >
void shark::SvmProblem< Problem >::reshrink ( )
inline

Definition at line 386 of file SvmProblems.h.

§ scaleBoxConstraints()

template<class Problem >
void shark::SvmProblem< Problem >::scaleBoxConstraints ( double  factor,
double  variableScalingFactor 
)
inline

Scales all box constraints by a constant factor and adapts the solution using a separate scaling.

Definition at line 427 of file SvmProblems.h.

References shark::AlphaDeactivated.

§ setLinear()

template<class Problem >
virtual void shark::SvmProblem< Problem >::setLinear ( std::size_t  i,
double  newValue 
)
inlinevirtual

adapts the linear part of the problem and updates the internal data structures accordingly.

Reimplemented in shark::SvmShrinkingProblem< Problem >.

Definition at line 440 of file SvmProblems.h.

§ shrink()

template<class Problem >
bool shark::SvmProblem< Problem >::shrink ( double  )
inline

Definition at line 385 of file SvmProblems.h.

§ unshrink()

template<class Problem >
void shark::SvmProblem< Problem >::unshrink ( )
inline

Definition at line 387 of file SvmProblems.h.

§ updateAlphaStatus()

template<class Problem >
void shark::SvmProblem< Problem >::updateAlphaStatus ( std::size_t  i)
inlineprotected

§ updateSMO()

template<class Problem >
void shark::SvmProblem< Problem >::updateSMO ( std::size_t  i,
std::size_t  j 
)
inline

Does an update of SMO given a working set with indices i and j.

Definition at line 364 of file SvmProblems.h.

References shark::blas::max(), and SIZE_CHECK.

Member Data Documentation

§ m_active

template<class Problem >
std::size_t shark::SvmProblem< Problem >::m_active
protected

Definition at line 464 of file SvmProblems.h.

§ m_alphaStatus

template<class Problem >
std::vector<char> shark::SvmProblem< Problem >::m_alphaStatus
protected

Stores the status, whther alpha is on the lower or upper bound, or whether it is free.

Definition at line 467 of file SvmProblems.h.

§ m_gradient

template<class Problem >
RealVector shark::SvmProblem< Problem >::m_gradient
protected

gradient of the objective function at the current alpha

Definition at line 462 of file SvmProblems.h.

§ m_problem

template<class Problem >
Problem shark::SvmProblem< Problem >::m_problem
protected

Definition at line 459 of file SvmProblems.h.


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