shark::BoxConstrainedProblem< SVMProblem > Class Template Reference

Quadratic program with box constraints. More...

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

Public Types

typedef SVMProblem::QpFloatType QpFloatType
 
typedef SVMProblem::MatrixType MatrixType
 
typedef MaximumGainCriterion PreferedSelectionStrategy
 

Public Member Functions

 BoxConstrainedProblem (SVMProblem &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
 
bool isDeactivated (std::size_t i) const
 
MatrixTypequadratic ()
 representation of the quadratic part of the objective function
 
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
 
virtual void updateSMO (std::size_t i, std::size_t j)
 Does an update of SMO given a working set with indices i and j.
 
double functionValue () const
 Returns the current function value of the problem.
 
bool shrink (double)
 
void reshrink ()
 
void unshrink ()
 
void setInitialSolution (RealVector const &alpha, RealVector const &gradient)
 Define the initial solution for the iterative solver.
 
void setInitialSolution (RealVector const &alpha)
 Define the initial solution for the iterative solver.
 
void deactivateVariable (std::size_t i)
 Remove the i-th example from the problem.
 
void activateVariable (std::size_t i)
 Reactivate an previously deactivated variable.
 
void flipCoordinates (std::size_t i, std::size_t j)
 exchange two variables via the permutation
 
virtual void setLinear (std::size_t i, double newValue)
 adapts the linear part of the problem and updates the internal data structures accordingly.
 
double checkKKT () const
 

Protected Member Functions

void updateAlphaStatus (std::size_t i)
 
bool testShrinkVariable (std::size_t a, double largestUp, double smallestDown) const
 

Protected Attributes

SVMProblem & m_problem
 
RealVector m_gradient
 gradient of the objective function at the current alpha
 
std::size_t m_active
 
std::vector< char > m_alphaStatus
 

Detailed Description

template<class SVMProblem>
class shark::BoxConstrainedProblem< SVMProblem >

Quadratic program with box constraints.

An instance of this class represents a quadratic program of the type TODO: write documentation!

Definition at line 138 of file BoxConstrainedProblems.h.

Member Typedef Documentation

◆ MatrixType

template<class SVMProblem >
typedef SVMProblem::MatrixType shark::BoxConstrainedProblem< SVMProblem >::MatrixType

Definition at line 141 of file BoxConstrainedProblems.h.

◆ PreferedSelectionStrategy

template<class SVMProblem >
typedef MaximumGainCriterion shark::BoxConstrainedProblem< SVMProblem >::PreferedSelectionStrategy

Definition at line 142 of file BoxConstrainedProblems.h.

◆ QpFloatType

template<class SVMProblem >
typedef SVMProblem::QpFloatType shark::BoxConstrainedProblem< SVMProblem >::QpFloatType

Definition at line 140 of file BoxConstrainedProblems.h.

Constructor & Destructor Documentation

◆ BoxConstrainedProblem()

Member Function Documentation

◆ activateVariable()

template<class SVMProblem >
void shark::BoxConstrainedProblem< SVMProblem >::activateVariable ( std::size_t  i)
inline

◆ active()

◆ alpha()

◆ boxMax()

◆ boxMin()

◆ checkKKT()

◆ deactivateVariable()

◆ diagonal()

template<class SVMProblem >
double shark::BoxConstrainedProblem< SVMProblem >::diagonal ( std::size_t  i) const
inline

◆ dimensions()

◆ flipCoordinates()

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

◆ functionValue()

template<class SVMProblem >
double shark::BoxConstrainedProblem< SVMProblem >::functionValue ( ) const
inline

Returns the current function value of the problem.

Definition at line 269 of file BoxConstrainedProblems.h.

References shark::BoxConstrainedProblem< SVMProblem >::m_gradient, and shark::BoxConstrainedProblem< SVMProblem >::m_problem.

◆ getUnpermutedAlpha()

◆ gradient()

◆ isDeactivated()

template<class SVMProblem >
bool shark::BoxConstrainedProblem< SVMProblem >::isDeactivated ( std::size_t  i) const
inline

◆ isLowerBound()

◆ isUpperBound()

◆ linear()

template<class SVMProblem >
double shark::BoxConstrainedProblem< SVMProblem >::linear ( std::size_t  i) const
inline

◆ permutation()

template<class SVMProblem >
std::size_t shark::BoxConstrainedProblem< SVMProblem >::permutation ( std::size_t  i) const
inline

◆ quadratic()

◆ reshrink()

template<class SVMProblem >
void shark::BoxConstrainedProblem< SVMProblem >::reshrink ( )
inline

Definition at line 274 of file BoxConstrainedProblems.h.

◆ setInitialSolution() [1/2]

template<class SVMProblem >
void shark::BoxConstrainedProblem< SVMProblem >::setInitialSolution ( RealVector const &  alpha)
inline

Define the initial solution for the iterative solver.

This method can be used to warm-start the solver. It requires a feasible solution (alpha), for which it computes the gradient of the dual objective function. Note that this is a quadratic time operation in the number of non-zero coefficients.

Definition at line 303 of file BoxConstrainedProblems.h.

References shark::BoxConstrainedProblem< SVMProblem >::alpha(), shark::BoxConstrainedProblem< SVMProblem >::dimensions(), shark::BoxConstrainedProblem< SVMProblem >::gradient(), shark::BoxConstrainedProblem< SVMProblem >::m_problem, shark::BoxConstrainedProblem< SVMProblem >::setInitialSolution(), and SIZE_CHECK.

◆ setInitialSolution() [2/2]

template<class SVMProblem >
void shark::BoxConstrainedProblem< SVMProblem >::setInitialSolution ( RealVector const &  alpha,
RealVector const &  gradient 
)
inline

◆ setLinear()

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

◆ shrink()

template<class SVMProblem >
bool shark::BoxConstrainedProblem< SVMProblem >::shrink ( double  )
inline

Definition at line 273 of file BoxConstrainedProblems.h.

◆ testShrinkVariable()

template<class SVMProblem >
bool shark::BoxConstrainedProblem< SVMProblem >::testShrinkVariable ( std::size_t  a,
double  largestUp,
double  smallestDown 
) const
inlineprotected

◆ unshrink()

template<class SVMProblem >
void shark::BoxConstrainedProblem< SVMProblem >::unshrink ( )
inline

Definition at line 275 of file BoxConstrainedProblems.h.

◆ updateAlphaStatus()

◆ updateSMO()

Member Data Documentation

◆ m_active

template<class SVMProblem >
std::size_t shark::BoxConstrainedProblem< SVMProblem >::m_active
protected

◆ m_alphaStatus

◆ m_gradient

◆ m_problem


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