aligator  0.9.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
module.cpp
Go to the documentation of this file.
1
4
7
8#include <eigenpy/optional.hpp>
9
10namespace aligator {
11namespace python {
12
14#ifdef ALIGATOR_WITH_CROCODDYL_COMPAT
15void exposeCrocoddylCompat();
16#endif
17
18static void exposeEnums() {
20
21 bp::enum_<MultiplierUpdateMode>(
22 "MultiplierUpdateMode", "Enum for the kind of multiplier update to use.")
23 .value("NEWTON", MultiplierUpdateMode::NEWTON)
24 .value("PRIMAL", MultiplierUpdateMode::PRIMAL)
25 .value("PRIMAL_DUAL", MultiplierUpdateMode::PRIMAL_DUAL);
26
27 bp::enum_<LinesearchMode>("LinesearchMode", "Linesearch mode.")
28 .value("PRIMAL", LinesearchMode::PRIMAL)
29 .value("PRIMAL_DUAL", LinesearchMode::PRIMAL_DUAL);
30
31 bp::enum_<RolloutType>("RolloutType", "Rollout type.")
32 .value("ROLLOUT_LINEAR", RolloutType::LINEAR)
33 .value("ROLLOUT_NONLINEAR", RolloutType::NONLINEAR)
34 .export_values();
35
36 bp::enum_<HessianApprox>("HessianApprox",
37 "Level of approximation for the Hessian.")
38 .value("HESSIAN_EXACT", HessianApprox::EXACT)
39 .value("HESSIAN_GAUSS_NEWTON", HessianApprox::GAUSS_NEWTON)
40 .value("HESSIAN_BFGS", HessianApprox::BFGS)
41 .export_values();
42
43 bp::enum_<StepAcceptanceStrategy>("StepAcceptanceStrategy",
44 "Step acceptance strategy.")
45 .value("SA_LINESEARCH", StepAcceptanceStrategy::LINESEARCH)
46 .value("SA_FILTER", StepAcceptanceStrategy::FILTER)
47 .export_values();
48}
49
50static void exposeContainers() {
51 StdVectorPythonVisitor<std::vector<long>, true>::expose("StdVec_long");
52 eigenpy::exposeStdVectorEigenSpecificType<context::Vector3s>(
53 "StdVec_Vector3s");
54 StdVectorPythonVisitor<std::vector<bool>, true>::expose("StdVec_bool");
55}
56
57} // namespace python
58} // namespace aligator
59
60BOOST_PYTHON_MODULE(MODULE_NAME) {
61 using namespace aligator::python;
62 using aligator::context::ConstVectorRef;
63
64 bp::docstring_options module_docstring_options(true, true, true);
65
66 bp::scope().attr("__version__") = ALIGATOR_VERSION;
67#ifdef ALIGATOR_MULTITHREADING
68 bp::def("get_available_threads", &aligator::omp::get_available_threads,
69 "Get the number of available threads.");
70 bp::def("get_current_threads", &aligator::omp::get_current_threads,
71 "Get the current number of threads.");
72 bp::def("set_omp_default_options", &aligator::omp::set_default_options,
73 ("num_threads"_a, "dynamic"_a = true));
74#endif
75 eigenpy::enableEigenPy();
76
77 eigenpy::OptionalConverter<ConstVectorRef, std::optional>::registration();
78 eigenpy::detail::NoneToPython<std::nullopt_t>::registration();
79
80 bp::import("warnings");
81 bp::import("proxsuite_nlp");
82
83 bp::def(
84 "has_pinocchio_features",
85 +[]() constexpr -> bool {
86 return
87#ifdef ALIGATOR_WITH_PINOCCHIO
88 true;
89#else
90 false;
91#endif
92 },
93 "Whether Aligator (and its Python bindings) were compiled with support "
94 "for Pinocchio.");
95
96 exposeContainers();
97 exposeGAR();
98 exposeEnums();
99 exposeContainers();
100 exposeFunctions();
101 exposeCosts();
102 exposeConstraint();
103 exposeStage();
104 exposeProblem();
105 exposeFilter();
106 {
107 bp::scope dynamics = get_namespace("dynamics");
108 exposeContinuousDynamics();
109 exposeDynamics();
110 exposeExplicitIntegrators();
111 exposeIntegrators();
112 }
113 exposeUtils();
114
115 exposeSolvers();
116 exposeCallbacks();
117 exposeAutodiff();
118
119#ifdef ALIGATOR_WITH_PINOCCHIO
120 exposePinocchioFeatures();
121#endif
122
123#ifdef ALIGATOR_WITH_CROCODDYL_COMPAT
124 {
125 bp::scope croc_ns = get_namespace("croc");
126 exposeCrocoddylCompat();
127 }
128#endif
129}
BOOST_PYTHON_MODULE(MODULE_NAME)
Definition module.cpp:60
std::size_t get_current_threads()
Get the current number of threads.
Definition threads.hpp:33
void set_default_options(std::size_t, bool=true)
Definition threads.hpp:38
std::size_t get_available_threads()
Definition threads.hpp:30
The Python bindings.
Definition blk-matrix.hpp:5
static void exposeEnums()
Definition module.cpp:18
static void exposeContainers()
Definition module.cpp:50
bool register_enum_symlink(bool export_values)
Definition utils.hpp:14
Main package namespace.
@ LINEAR
Linear rollout.
@ NONLINEAR
Nonlinear rollout, using the full dynamics.
@ GAUSS_NEWTON
Use the Gauss-Newton approximation.
@ BFGS
Use a BFGS-type approximation.
@ EXACT
Use exact Hessian.