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

Gauss-Newton solver that optimizes only a selected subset of parameters. More...

#include <subset_gauss_newton_solver.h>

Inheritance diagram for momentum::SubsetGaussNewtonSolverT< T >:

Public Member Functions

 SubsetGaussNewtonSolverT (const SolverOptions &options, SolverFunctionT< T > *solver)
 Creates a solver with the specified options and function to optimize.
std::string_view getName () const override
 Returns "SubsetGaussNewton" as the solver name.
void setOptions (const SolverOptions &options) final
 Updates solver configuration, handling both base and Subset Gauss-Newton specific options.
void setEnabledParameters (const ParameterSet &parameters) final
 Specifies which parameters should be optimized.
Public Member Functions inherited from momentum::SolverT< T >
 SolverT (const SolverOptions &options, SolverFunctionT< T > *solver)
 Constructor with solver options and function to optimize.
virtual ~SolverT ()=default
double solve (Eigen::VectorX< T > &params)
 Solves the optimization problem.
const ParameterSet & getActiveParameters () const
 Returns the current set of enabled parameters.
void setParameters (const Eigen::VectorX< T > &params)
 Sets the current parameter values without solving.
void setStoreHistory (bool b)
 Controls whether to store iteration history for debugging and analysis.
const std::unordered_map< std::string, Eigen::MatrixX< T > > & getHistory () const
 Returns the history of the solver's iterations.
size_t getMinIterations () const
 Returns the minimum number of iterations before checking convergence.
size_t getMaxIterations () const
 Returns the maximum number of iterations before terminating.
size_t getNumParameters () const
const std::vector< double > & getErrorHistory () const
 Returns the history of objective function values over the iterations of the solve.

Protected Member Functions

void doIteration () final
 Performs one iteration of the Subset Gauss-Newton algorithm.
void initializeSolver () final
 Initializes solver state before optimization begins.

Additional Inherited Members

Protected Attributes inherited from momentum::SolverT< T >
size_t numParameters_
 Total number of parameters in the optimization problem.
SolverFunctionT< T > * solverFunction_
 Function to be optimized.
Eigen::VectorX< T > parameters_
 Current parameter values.
ParameterSet activeParameters_
 Bitset indicating which parameters are enabled for optimization.
int actualParameters_
 Number of parameters currently enabled for optimization.
bool newParameterPattern_
 Flag indicating parameter structure has changed.
size_t iteration_ {}
 Current iteration count.
double error_ {}
 Current objective function value.
double lastError_ {}
 Previous iteration's objective function value.
bool storeHistory = false
 Whether to record optimization progress for analysis.
std::unordered_map< std::string, Eigen::MatrixX< T > > iterationHistory_
 Recorded data from optimization process.
std::vector< double > errorHistory_
 History of objective function values over the iterations.
bool verbose_ = false
 Whether to output detailed progress information.

Detailed Description

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

Gauss-Newton solver that optimizes only a selected subset of parameters.

This specialized solver efficiently handles cases where only some parameters need to be optimized while others remain fixed. It remaps the active parameters to a smaller optimization problem, reducing computational cost.

Definition at line 34 of file subset_gauss_newton_solver.h.

Constructor & Destructor Documentation

◆ SubsetGaussNewtonSolverT()

template<typename T>
momentum::SubsetGaussNewtonSolverT< T >::SubsetGaussNewtonSolverT ( const SolverOptions & options,
SolverFunctionT< T > * solver )

Member Function Documentation

◆ doIteration()

template<typename T>
void momentum::SubsetGaussNewtonSolverT< T >::doIteration ( )
finalprotectedvirtual

Performs one iteration of the Subset Gauss-Newton algorithm.

Computes the Jacobian, forms a reduced optimization problem for the enabled parameters, solves it, and updates the full parameter vector

Implements momentum::SolverT< T >.

Definition at line 72 of file subset_gauss_newton_solver.cpp.

References momentum::SolverT< T >::error_, MT_PROFILE_FUNCTION, momentum::SolverT< T >::parameters_, and momentum::SolverT< T >::solverFunction_.

◆ getName()

template<typename T>
std::string_view momentum::SubsetGaussNewtonSolverT< T >::getName ( ) const
nodiscardoverridevirtual

Returns "SubsetGaussNewton" as the solver name.

Implements momentum::SolverT< T >.

Definition at line 34 of file subset_gauss_newton_solver.cpp.

◆ initializeSolver()

template<typename T>
void momentum::SubsetGaussNewtonSolverT< T >::initializeSolver ( )
finalprotectedvirtual

Initializes solver state before optimization begins.

Implements momentum::SolverT< T >.

Definition at line 148 of file subset_gauss_newton_solver.cpp.

◆ setEnabledParameters()

template<typename T>
void momentum::SubsetGaussNewtonSolverT< T >::setEnabledParameters ( const ParameterSet & parameters)
finalvirtual

Specifies which parameters should be optimized.

Updates the internal mapping between full parameter space and optimization subset

Reimplemented from momentum::SolverT< T >.

Definition at line 66 of file subset_gauss_newton_solver.cpp.

References momentum::SolverT< T >::setEnabledParameters().

◆ setOptions()

template<typename T>
void momentum::SubsetGaussNewtonSolverT< T >::setOptions ( const SolverOptions & options)
finalvirtual

Updates solver configuration, handling both base and Subset Gauss-Newton specific options.

Reimplemented from momentum::SolverT< T >.

Definition at line 39 of file subset_gauss_newton_solver.cpp.

References momentum::SolverT< T >::setOptions().

Referenced by SubsetGaussNewtonSolverT().


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