bindings/python/algorithm/proximal.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019-2022 INRIA
3 //
4 
5 #ifndef __pinocchio_python_algorithm_proximal_hpp__
6 #define __pinocchio_python_algorithm_proximal_hpp__
7 
9 
10 #include <sstream>
11 
12 namespace pinocchio
13 {
14  namespace python
15  {
16  namespace bp = boost::python;
17 
18  template<typename ProximalSettings>
20  : public boost::python::def_visitor<ProximalSettingsPythonVisitor<ProximalSettings>>
21  {
22  typedef typename ProximalSettings::Scalar Scalar;
23 
24  public:
25  template<class PyClass>
26  void visit(PyClass & cl) const
27  {
28  cl.def(bp::init<>("Default constructor.", bp::arg("self")))
29  .def(bp::init<const Scalar, const Scalar, int>(
30  (bp::arg("self"), bp::arg("accuracy"), bp::arg("mu"), bp::arg("max_iter")),
31  "Structure containing all the settings parameters for the proximal algorithms."))
32  .def(bp::init<const Scalar, const Scalar, const Scalar, int>(
33  (bp::arg("self"), bp::arg("absolute_accuracy"), bp::arg("relative_accuracy"),
34  bp::arg("mu"), bp::arg("max_iter")),
35  "Structure containing all the settings parameters for the proximal algorithms."))
36 
37  .add_property(
38  "absolute_accuracy", &ProximalSettings::absolute_accuracy,
39  "Absolute proximal accuracy.")
40  .add_property(
41  "relative_accuracy", &ProximalSettings::relative_accuracy,
42  "Relative proximal accuracy between two iterates.")
43  .add_property(
44  "mu", &ProximalSettings::mu, "Regularization parameter of the Proximal algorithms.")
45  .add_property("max_iter", &ProximalSettings::max_iter, "Maximal number of iterations.")
46 
47  .add_property(
48  "absolute_residual", &ProximalSettings::absolute_residual, "Absolute residual.")
49  .add_property(
50  "relative_residual", &ProximalSettings::relative_residual,
51  "Relatice residual between two iterates.")
52 
53  .add_property(
54  "iter", &ProximalSettings::iter,
55  "Final number of iteration of the algorithm when it has converged or "
56  "reached the maximal number of allowed iterations.")
57  .def("__repr__", &repr);
58  }
59 
60  static void expose()
61  {
62  bp::class_<ProximalSettings>(
63  "ProximalSettings",
64  "Structure containing all the settings parameters for proximal algorithms.", bp::no_init)
66  }
67 
68  private:
69  static std::string repr(const ProximalSettings & self)
70  {
71  std::stringstream ss_repr;
72 
73  ss_repr << "ProximalSettings(";
74  ss_repr << self.absolute_accuracy << ", ";
75  ss_repr << self.relative_accuracy << ", ";
76  ss_repr << self.mu << ", ";
77  ss_repr << self.max_iter;
78  ss_repr << ")";
79 
80  return ss_repr.str();
81  }
82  };
83 
84  } // namespace python
85 } // namespace pinocchio
86 
87 #endif // ifndef __pinocchio_python_algorithm_proximal_hpp__
boost::python
pinocchio::python::ProximalSettingsPythonVisitor::expose
static void expose()
Definition: bindings/python/algorithm/proximal.hpp:60
pinocchio::ProximalSettingsTpl::mu
Scalar mu
Regularization parameter of the proximal algorithm.
Definition: algorithm/proximal.hpp:95
pinocchio::ProximalSettingsTpl::absolute_accuracy
Scalar absolute_accuracy
Absolute proximal accuracy.
Definition: algorithm/proximal.hpp:89
pinocchio::ProximalSettingsTpl::Scalar
_Scalar Scalar
Definition: algorithm/proximal.hpp:26
proximal.hpp
pinocchio::ProximalSettingsTpl
Structure containing all the settings parameters for the proximal algorithms.
Definition: algorithm/fwd.hpp:13
pinocchio::python::ProximalSettingsPythonVisitor::repr
static std::string repr(const ProximalSettings &self)
Definition: bindings/python/algorithm/proximal.hpp:69
python
pinocchio::ProximalSettingsTpl::relative_accuracy
Scalar relative_accuracy
Relative proximal accuracy between two iterates.
Definition: algorithm/proximal.hpp:92
pinocchio::ProximalSettingsTpl::absolute_residual
Scalar absolute_residual
Absolute residual.
Definition: algorithm/proximal.hpp:103
pinocchio::ProximalSettingsTpl::iter
int iter
Total number of iterations of the algorithm when it has converged or reached the maximal number of al...
Definition: algorithm/proximal.hpp:110
pinocchio::python::ProximalSettingsPythonVisitor::visit
void visit(PyClass &cl) const
Definition: bindings/python/algorithm/proximal.hpp:26
pinocchio::ProximalSettingsTpl::relative_residual
Scalar relative_residual
Relatice residual between two iterates.
Definition: algorithm/proximal.hpp:106
cl
cl
pinocchio::ProximalSettingsTpl::max_iter
int max_iter
Maximal number of iterations.
Definition: algorithm/proximal.hpp:98
pinocchio::python::ProximalSettingsPythonVisitor::Scalar
ProximalSettings::Scalar Scalar
Definition: bindings/python/algorithm/proximal.hpp:22
pinocchio::python::ProximalSettingsPythonVisitor
Definition: bindings/python/algorithm/proximal.hpp:19
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:32