Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
momentum::LimitErrorFunctionT< T > Class Template Reference

Penalizes model/joint parameters that violate their configured limits. More...

#include <limit_error_function.h>

Inheritance diagram for momentum::LimitErrorFunctionT< T >:

Public Member Functions

 LimitErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt, const ParameterLimits &pl=ParameterLimits(), const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1))
 Constructor.
 LimitErrorFunctionT (const Character &character, const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1))
 A convenience constructor where character contains info of the skeleton, parameter transform, and parameter limits.
 LimitErrorFunctionT (const Character &character, const ParameterLimits &pl, const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1))
 A convenience constructor where character supplies the skeleton and parameter transform, with an explicit set of parameter limits.
double getError (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) final
double getGradient (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< Eigen::VectorX< T > > gradient) final
double getJacobian (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< Eigen::MatrixX< T > > jacobian, Ref< Eigen::VectorX< T > > residual, int &usedRows) final
size_t getJacobianSize () const final
void setLimits (const ParameterLimits &lm)
void setLimits (const Character &character)
Public Member Functions inherited from momentum::SkeletonErrorFunctionT< T >
 SkeletonErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt)
virtual ~SkeletonErrorFunctionT ()=default
const Skeleton & getSkeleton () const
const ParameterTransform & getParameterTransform () const
virtual const Character * getCharacter () const
 For mesh-based error functions, get access to the underlying character.
void setWeight (T w)
T getWeight () const
void setActiveJoints (const VectorX< bool > &aj)
void setEnabledParameters (const ParameterSet &ps)
virtual double getGradient (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::VectorX< T > >)
virtual double getJacobian (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::MatrixX< T > >, Eigen::Ref< Eigen::VectorX< T > >, int &usedRows)
virtual void getHessian (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::MatrixX< T > >)
virtual double getSolverDerivatives (const ModelParametersT< T > &parameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, const size_t actualParameters, Eigen::MatrixX< T > &hess, Eigen::VectorX< T > &grad)
virtual bool needsMesh () const

Additional Inherited Members

Protected Attributes inherited from momentum::SkeletonErrorFunctionT< T >
const Skeleton & skeleton_
const ParameterTransform & parameterTransform_
T weight_
VectorX< bool > activeJointParams_
ParameterSet enabledParameters_
bool useHessian_ {false}

Detailed Description

template<typename T>
class momentum::LimitErrorFunctionT< T >

Penalizes model/joint parameters that violate their configured limits.

Each limit contributes a squared residual (e.g., how far a parameter is past a min/max bound) that is transformed by the generalized loss function (see math/generalized_loss.h) before being weighted and accumulated. The default loss is L2 (alpha = 2, c = 1), which reproduces the classic quadratic penalty; other alpha values make the penalty robust to outliers.

Definition at line 25 of file limit_error_function.h.

Constructor & Destructor Documentation

◆ LimitErrorFunctionT() [1/3]

template<typename T>
momentum::LimitErrorFunctionT< T >::LimitErrorFunctionT ( const Skeleton & skel,
const ParameterTransform & pt,
const ParameterLimits & pl = ParameterLimits(),
const T & lossAlpha = GeneralizedLossT<T>::kL2,
const T & lossC = T(1) )

Constructor.

Parameters
[in]skelcharacter skeleton
[in]ptcharacter parameter transform
[in]plparameter limits to enforce
[in]lossAlphaalpha (shape) parameter for the generalized loss function
[in]lossCc (scale) parameter for the generalized loss function

Definition at line 790 of file limit_error_function.cpp.

References momentum::SkeletonErrorFunctionT< T >::SkeletonErrorFunctionT().

Referenced by LimitErrorFunctionT(), and LimitErrorFunctionT().

◆ LimitErrorFunctionT() [2/3]

template<typename T>
momentum::LimitErrorFunctionT< T >::LimitErrorFunctionT ( const Character & character,
const T & lossAlpha = GeneralizedLossT<T>::kL2,
const T & lossC = T(1) )
explicit

A convenience constructor where character contains info of the skeleton, parameter transform, and parameter limits.

Parameters
[in]charactercharacter definition
[in]lossAlphaalpha (shape) parameter for the generalized loss function
[in]lossCc (scale) parameter for the generalized loss function

Definition at line 799 of file limit_error_function.cpp.

References LimitErrorFunctionT().

◆ LimitErrorFunctionT() [3/3]

template<typename T>
momentum::LimitErrorFunctionT< T >::LimitErrorFunctionT ( const Character & character,
const ParameterLimits & pl,
const T & lossAlpha = GeneralizedLossT<T>::kL2,
const T & lossC = T(1) )

A convenience constructor where character supplies the skeleton and parameter transform, with an explicit set of parameter limits.

Parameters
[in]charactercharacter definition
[in]plparameter limits to enforce
[in]lossAlphaalpha (shape) parameter for the generalized loss function
[in]lossCc (scale) parameter for the generalized loss function

Definition at line 811 of file limit_error_function.cpp.

References LimitErrorFunctionT().

Member Function Documentation

◆ getError()

template<typename T>
double momentum::LimitErrorFunctionT< T >::getError ( const ModelParametersT< T > & params,
const SkeletonStateT< T > & state,
const MeshStateT< T > & meshState )
nodiscardfinalvirtual

◆ getGradient()

template<typename T>
double momentum::LimitErrorFunctionT< T >::getGradient ( const ModelParametersT< T > & params,
const SkeletonStateT< T > & state,
const MeshStateT< T > & meshState,
Ref< Eigen::VectorX< T > > gradient )
final

Definition at line 979 of file limit_error_function.cpp.

References MT_PROFILE_FUNCTION.

◆ getJacobian()

template<typename T>
double momentum::LimitErrorFunctionT< T >::getJacobian ( const ModelParametersT< T > & params,
const SkeletonStateT< T > & state,
const MeshStateT< T > & meshState,
Ref< Eigen::MatrixX< T > > jacobian,
Ref< Eigen::VectorX< T > > residual,
int & usedRows )
final

Definition at line 1124 of file limit_error_function.cpp.

References MT_PROFILE_FUNCTION.

◆ getJacobianSize()

◆ setLimits() [1/2]

template<typename T>
void momentum::LimitErrorFunctionT< T >::setLimits ( const Character & character)

Definition at line 1169 of file limit_error_function.cpp.

References momentum::Character::parameterLimits.

◆ setLimits() [2/2]

template<typename T>
void momentum::LimitErrorFunctionT< T >::setLimits ( const ParameterLimits & lm)

Definition at line 1164 of file limit_error_function.cpp.


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