|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
#include <skeleton_solver_function.h>
Public Member Functions | |
| SkeletonSolverFunctionT (const Character &character, const ParameterTransformT< T > ¶meterTransform, std::span< const std::shared_ptr< SkeletonErrorFunctionT< T > > > errorFunctions={}) | |
| ~SkeletonSolverFunctionT () override | |
| SkeletonSolverFunctionT (const SkeletonSolverFunctionT &)=delete | |
| SkeletonSolverFunctionT & | operator= (const SkeletonSolverFunctionT &)=delete |
| SkeletonSolverFunctionT (SkeletonSolverFunctionT &&)=delete | |
| SkeletonSolverFunctionT & | operator= (SkeletonSolverFunctionT &&)=delete |
| double | getError (const Eigen::VectorX< T > ¶meters) final |
| double | getGradient (const Eigen::VectorX< T > ¶meters, Eigen::VectorX< T > &gradient) final |
| void | initializeJacobianComputation (const Eigen::VectorX< T > ¶meters) override |
| size_t | getJacobianBlockCount () const override |
| Returns the number of Jacobian blocks available. | |
| size_t | getJacobianBlockSize (size_t blockIndex) const override |
| Returns the maximum number of rows for a specific Jacobian block. | |
| double | computeJacobianBlock (const Eigen::VectorX< T > ¶meters, size_t blockIndex, Eigen::Ref< Eigen::MatrixX< T > > jacobianBlock, Eigen::Ref< Eigen::VectorX< T > > residualBlock, size_t &actualRows) override |
| void | finalizeJacobianComputation () override |
| Optional cleanup after all Jacobian blocks have been computed. | |
| double | getSolverDerivatives (const Eigen::VectorX< T > ¶meters, Eigen::MatrixX< T > &hess, Eigen::VectorX< T > &grad) override |
| void | updateParameters (Eigen::VectorX< T > ¶meters, const Eigen::VectorX< T > &delta) final |
| void | setEnabledParameters (const ParameterSet &ps) final |
| Specifies which parameters should be optimized. | |
| void | addErrorFunction (std::shared_ptr< SkeletonErrorFunctionT< T > > solvable) |
| void | clearErrorFunctions () |
| const std::vector< std::shared_ptr< SkeletonErrorFunctionT< T > > > & | getErrorFunctions () const |
| const Character & | getCharacter () const |
| Provides access to the full character (replaces getSkeleton and getParameterTransform). | |
| const Skeleton * | getSkeleton () const |
| Legacy compatibility (delegates to character_.skeleton). | |
| const ParameterTransformT< T > * | getParameterTransform () const |
| Provides access to the parameter transform. | |
| void | updateMeshState (const ModelParametersT< T > ¶meters, const SkeletonStateT< T > &state) |
| Updates mesh state if any error functions require it. | |
| bool | needsMeshState () const |
| Checks if any error functions require mesh state. | |
| Public Member Functions inherited from momentum::SolverFunctionT< T > | |
| virtual | ~SolverFunctionT ()=default |
| virtual double | getError (const VectorX< T > ¶meters)=0 |
| Evaluates the objective function at the given parameter values. | |
| virtual double | getGradient (const VectorX< T > ¶meters, VectorX< T > &gradient)=0 |
| Computes the gradient of the objective function. | |
| double | getJacobian (const VectorX< T > ¶meters, MatrixX< T > &jacobian, VectorX< T > &residual, size_t &actualRows) |
| Computes the Jacobian matrix for least squares problems. | |
| virtual void | getHessian (const VectorX< T > ¶meters, MatrixX< T > &hessian) |
| Computes the Hessian matrix of second derivatives. | |
| virtual double | getJtJR (const VectorX< T > ¶meters, MatrixX< T > &jtj, VectorX< T > &jtr) |
| Computes JᵀJ and JᵀR for Gauss-Newton optimization. | |
| virtual double | getJtJR_Sparse (const VectorX< T > ¶meters, SparseMatrix< T > &jtj, VectorX< T > &jtr) |
| Computes sparse JᵀJ and JᵀR for large-scale problems. | |
| virtual void | initializeJacobianComputation (const VectorX< T > ¶meters)=0 |
| Initializes Jacobian computation for the given parameters. | |
| virtual double | computeJacobianBlock (const VectorX< T > ¶meters, size_t blockIndex, Eigen::Ref< MatrixX< T > > jacobianBlock, Eigen::Ref< VectorX< T > > residualBlock, size_t &actualRows)=0 |
| Computes a specific Jacobian block. | |
| virtual double | getSolverDerivatives (const VectorX< T > ¶meters, MatrixX< T > &hess, VectorX< T > &grad) |
| Computes derivatives needed by the solver. | |
| virtual void | updateParameters (VectorX< T > ¶meters, const VectorX< T > &gradient)=0 |
| Updates parameters using the computed step direction. | |
| size_t | getNumParameters () const |
| Returns the total number of parameters in the optimization problem. | |
| size_t | getActualParameters () const |
| Returns the number of parameters currently enabled for optimization. | |
| virtual void | storeHistory (std::unordered_map< std::string, MatrixX< T > > &history, size_t iteration, size_t maxIterations_) |
| Records solver state for debugging and analysis. | |
Additional Inherited Members | |
| Protected Attributes inherited from momentum::SolverFunctionT< T > | |
| size_t | numParameters_ {} |
| Total number of parameters in the optimization problem. | |
| size_t | actualParameters_ {} |
| Number of parameters currently enabled for optimization. | |
| ResizeableMatrix< T > | tJacobian_ |
| Pre-allocated temporary storage for block-wise JtJ computation. | |
| ResizeableMatrix< T > | tResidual_ |
Definition at line 21 of file skeleton_solver_function.h.
| momentum::SkeletonSolverFunctionT< T >::SkeletonSolverFunctionT | ( | const Character & | character, |
| const ParameterTransformT< T > & | parameterTransform, | ||
| std::span< const std::shared_ptr< SkeletonErrorFunctionT< T > > > | errorFunctions = {} ) |
Definition at line 25 of file skeleton_solver_function.cpp.
References momentum::SolverFunctionT< T >::actualParameters_, addErrorFunction(), and momentum::SolverFunctionT< T >::numParameters_.
|
overridedefault |
|
delete |
|
delete |
| void momentum::SkeletonSolverFunctionT< T >::addErrorFunction | ( | std::shared_ptr< SkeletonErrorFunctionT< T > > | solvable | ) |
Definition at line 162 of file skeleton_solver_function.cpp.
Referenced by momentum::setupGloveErrorFunctions(), and SkeletonSolverFunctionT().
| void momentum::SkeletonSolverFunctionT< T >::clearErrorFunctions | ( | ) |
Definition at line 172 of file skeleton_solver_function.cpp.
|
override |
Definition at line 235 of file skeleton_solver_function.cpp.
References MT_PROFILE_FUNCTION.
|
overridevirtual |
Optional cleanup after all Jacobian blocks have been computed.
Called after all blocks have been processed. Default implementation does nothing.
Reimplemented from momentum::SolverFunctionT< T >.
Definition at line 264 of file skeleton_solver_function.cpp.
|
inlinenodiscard |
Provides access to the full character (replaces getSkeleton and getParameterTransform).
Definition at line 66 of file skeleton_solver_function.h.
Referenced by momentum::d_modelParams_d_inputs().
|
final |
Definition at line 64 of file skeleton_solver_function.cpp.
References needsMeshState(), and updateMeshState().
|
nodiscard |
Definition at line 178 of file skeleton_solver_function.cpp.
Referenced by momentum::d_modelParams_d_inputs().
|
final |
Definition at line 86 of file skeleton_solver_function.cpp.
References needsMeshState(), and updateMeshState().
|
nodiscardoverridevirtual |
Returns the number of Jacobian blocks available.
Each block corresponds to one error function or constraint group
Implements momentum::SolverFunctionT< T >.
Definition at line 217 of file skeleton_solver_function.cpp.
|
nodiscardoverridevirtual |
Returns the maximum number of rows for a specific Jacobian block.
This is the maximum size; actual rows may be fewer (returned via actualRows)
| blockIndex | Index of the block (0 to getJacobianBlockCount()-1) |
Implements momentum::SolverFunctionT< T >.
Definition at line 222 of file skeleton_solver_function.cpp.
|
inlinenodiscard |
Provides access to the parameter transform.
Definition at line 76 of file skeleton_solver_function.h.
|
inlinenodiscard |
Legacy compatibility (delegates to character_.skeleton).
Definition at line 71 of file skeleton_solver_function.h.
Referenced by momentum::TrustRegionQRT< T >::doIteration().
|
override |
Definition at line 115 of file skeleton_solver_function.cpp.
References momentum::SolverFunctionT< T >::actualParameters_, MT_PROFILE_EVENT, MT_PROFILE_FUNCTION, needsMeshState(), and updateMeshState().
|
override |
Definition at line 200 of file skeleton_solver_function.cpp.
References MT_PROFILE_EVENT, MT_PROFILE_FUNCTION, needsMeshState(), and updateMeshState().
|
nodiscard |
Checks if any error functions require mesh state.
Definition at line 183 of file skeleton_solver_function.cpp.
Referenced by momentum::d_modelParams_d_inputs(), getError(), getGradient(), getSolverDerivatives(), initializeJacobianComputation(), and updateMeshState().
|
delete |
|
delete |
|
finalvirtual |
Specifies which parameters should be optimized.
Default implementation does nothing
| parameterSet | Bitset where each bit indicates if the corresponding parameter is enabled |
Reimplemented from momentum::SolverFunctionT< T >.
Definition at line 45 of file skeleton_solver_function.cpp.
References momentum::SolverFunctionT< T >::actualParameters_, and momentum::SolverFunctionT< T >::numParameters_.
| void momentum::SkeletonSolverFunctionT< T >::updateMeshState | ( | const ModelParametersT< T > & | parameters, |
| const SkeletonStateT< T > & | state ) |
Updates mesh state if any error functions require it.
Definition at line 188 of file skeleton_solver_function.cpp.
References needsMeshState().
Referenced by getError(), getGradient(), getSolverDerivatives(), and initializeJacobianComputation().
|
final |
Definition at line 153 of file skeleton_solver_function.cpp.
References MT_CHECK.