pinocchio  3.2.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
proximal.hpp
1 //
2 // Copyright (c) 2019-2022 INRIA
3 //
4 
5 #ifndef __pinocchio_algorithm_proximal_hpp__
6 #define __pinocchio_algorithm_proximal_hpp__
7 
8 #include <Eigen/Core>
9 #include "pinocchio/multibody/model.hpp"
10 #include "pinocchio/multibody/data.hpp"
11 
12 namespace pinocchio
13 {
14 
23  template<typename _Scalar>
25  {
26  typedef _Scalar Scalar;
27 
30  : absolute_accuracy(Eigen::NumTraits<Scalar>::dummy_precision())
31  , relative_accuracy(Eigen::NumTraits<Scalar>::dummy_precision())
32  , mu(0)
33  , max_iter(1)
34  , absolute_residual(-1.)
35  , relative_residual(-1.)
36  , iter(0)
37  {
38  }
39 
43  ProximalSettingsTpl(const Scalar accuracy, const Scalar mu, const int max_iter)
44  : absolute_accuracy(accuracy)
45  , relative_accuracy(accuracy)
46  , mu(mu)
48  , absolute_residual(-1.)
49  , relative_residual(-1.)
50  , iter(0)
51  {
52  PINOCCHIO_CHECK_INPUT_ARGUMENT(
53  check_expression_if_real<Scalar>(accuracy >= 0.) && "Accuracy must be positive.");
54  PINOCCHIO_CHECK_INPUT_ARGUMENT(
55  check_expression_if_real<Scalar>(mu >= 0.) && "mu must be positive");
56  assert(max_iter >= 1 && "max_iter must be greater or equal to 1");
57  }
58 
63  const Scalar absolute_accuracy,
64  const Scalar relative_accuracy,
65  const Scalar mu,
66  const int max_iter)
69  , mu(mu)
71  , absolute_residual(-1.)
72  , relative_residual(-1.)
73  , iter(0)
74  {
75  PINOCCHIO_CHECK_INPUT_ARGUMENT(
76  check_expression_if_real<Scalar>(absolute_accuracy >= 0.)
77  && "Absolute accuracy must be positive.");
78  PINOCCHIO_CHECK_INPUT_ARGUMENT(
79  check_expression_if_real<Scalar>(relative_accuracy >= 0.)
80  && "Relative accuracy must be positive.");
81  PINOCCHIO_CHECK_INPUT_ARGUMENT(
82  check_expression_if_real<Scalar>(mu >= 0.) && "mu must be positive");
83  assert(max_iter >= 1 && "max_iter must be greater or equal to 1");
84  }
85 
86  // data
87 
90 
93 
95  Scalar mu;
96 
98  int max_iter;
99 
100  // data that can be modified by the algorithm
101 
104 
107 
110  int iter;
111  };
112 
113 } // namespace pinocchio
114 
115 #if PINOCCHIO_ENABLE_TEMPLATE_INSTANTIATION
116  #include "pinocchio/algorithm/proximal.txx"
117 #endif // PINOCCHIO_ENABLE_TEMPLATE_INSTANTIATION
118 
119 #endif // ifndef __pinocchio_algorithm_proximal_hpp__
Main pinocchio namespace.
Definition: treeview.dox:11
Structure containing all the settings parameters for the proximal algorithms.
Definition: proximal.hpp:25
ProximalSettingsTpl()
Default constructor.
Definition: proximal.hpp:29
ProximalSettingsTpl(const Scalar accuracy, const Scalar mu, const int max_iter)
Constructor with all the setting parameters.
Definition: proximal.hpp:43
int max_iter
Maximal number of iterations.
Definition: proximal.hpp:98
Scalar relative_accuracy
Relative proximal accuracy between two iterates.
Definition: proximal.hpp:92
Scalar absolute_accuracy
Absolute proximal accuracy.
Definition: proximal.hpp:89
Scalar mu
Regularization parameter of the proximal algorithm.
Definition: proximal.hpp:95
int iter
Total number of iterations of the algorithm when it has converged or reached the maximal number of al...
Definition: proximal.hpp:110
Scalar relative_residual
Relatice residual between two iterates.
Definition: proximal.hpp:106
Scalar absolute_residual
Absolute residual.
Definition: proximal.hpp:103
ProximalSettingsTpl(const Scalar absolute_accuracy, const Scalar relative_accuracy, const Scalar mu, const int max_iter)
Constructor with all the setting parameters.
Definition: proximal.hpp:62