Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
trust_region_qr.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
16
17#include <Eigen/Core>
18
19namespace momentum {
20
24 float trustRegionRadius_ = 1.0f;
25
27
28 /* implicit */ TrustRegionQROptions(const SolverOptions& baseOptions)
29 : SolverOptions(baseOptions) {
30 // Empty
31 }
32};
33
34template <typename T>
35class TrustRegionQRT : public SolverT<T> {
36 public:
38
39 [[nodiscard]] std::string_view getName() const override;
40
41 void setOptions(const SolverOptions& options) final;
42
43 void iter() {
45 this->iteration_++;
46 }
47
48 void init() {
49 this->iteration_ = 0;
51 }
52
53 Eigen::VectorX<T> getP() {
54 return this->parameters_;
55 }
56
57 protected:
58 void doIteration() final;
59 void initializeSolver() final;
60
61 private:
62 ResizeableMatrix<T> jacobian_;
63 ResizeableMatrix<T> residual_;
64
65 Eigen::VectorX<T> gradientSub_;
66 Eigen::MatrixX<T> lambdaDiag_;
67 Eigen::VectorX<T> lambdaZero_;
68
69 OnlineHouseholderQR<T> qrSolver_;
70
71 SkeletonStateT<T> skeletonState_;
72 MeshStateT<T> meshState_;
73
74 T trustRegionRadius_;
75 T maxTrustRegionRadius_ = 10.0;
76 T curTrustRegionRadius_ = 1.0;
77 Eigen::MatrixX<T> Rmatrix_;
78};
79
80} // namespace momentum
Online (incremental) Householder QR solver for tall, column-sparse least-squares problems.
A dense column-major matrix whose underlying storage capacity grows monotonically and is reused acros...
Eigen::VectorX< float > parameters_
Definition solver.h:109
SolverT(const SolverOptions &options, SolverFunctionT< T > *solver)
Constructor with solver options and function to optimize.
Definition solver.cpp:20
void setOptions(const SolverOptions &options) final
Updates solver configuration with new options.
std::string_view getName() const override
Returns the name of the solver implementation.
Eigen::VectorX< T > getP()
TrustRegionQRT(const SolverOptions &options, SkeletonSolverFunctionT< T > *solverFun)
void doIteration() final
Performs a single iteration of the optimization algorithm.
void initializeSolver() final
Initializes solver state before optimization begins.
Definition types.h:28
Eigen::Matrix< T, Dynamic, Dynamic > MatrixX
Dynamic-size, column-major dense matrix.
Definition types.h:80
Vector< T, Dynamic > VectorX
Dynamic-size column vector. Common return type for solver residuals and parameter vectors.
Definition types.h:207
Represents the complete state of a model's mesh.
Definition mesh_state.h:24
Represents the complete state of a skeleton.
Common options for numerical optimization solvers.
Definition solver.h:19
TrustRegionQROptions(const SolverOptions &baseOptions)
float trustRegionRadius_
Trust region radius parameter for the Trust Region solver with QR decomposition.