aligator  0.14.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
expose-gar.cpp
Go to the documentation of this file.
1
6
9
10#include <eigenpy/std-array.hpp>
11
12namespace aligator::python {
13using namespace gar;
14
15using context::Scalar;
19
20using context::MatrixXs;
21using RowMatrixXs = Eigen::Transpose<MatrixXs>::PlainMatrix;
22using context::VectorXs;
23
25
26static void exposeBlockMatrices() {
31 "BlockRowMatrix41");
33 "BlockRowMatrix21");
34 eigenpy::StdArrayPythonVisitor<std::array<long, 1>, true>::expose(
35 "StdArr1_long");
36 eigenpy::StdArrayPythonVisitor<std::array<long, 2>, true>::expose(
37 "StdArr2_long");
38 eigenpy::StdArrayPythonVisitor<std::array<long, 4>, true>::expose(
39 "StdArr4_long");
40}
41
42#ifdef ALIGATOR_WITH_CHOLMOD
43// fwd-declare exposeCholmodSolver()
44void exposeCholmodSolver();
45#endif
46// fwd-declare exposeParallelSolver()
48// fwd-declare exposeDenseSolver()
50// fwd-declare exposeProxRiccati()
52// fwd-declare exposeGarUtils()
53void exposeGarUtils();
54
55void exposeGAR() {
56
57 bp::scope ns = get_namespace("gar");
58
60
61 bp::class_<knot_t>("LqrKnot", bp::no_init)
62 .def(bp::init<uint, uint, uint>(("self"_a, "nx", "nu", "nc")))
63 .def(bp::init<uint, uint, uint, uint, uint>(
64 ("self"_a, "nx"_a, "nu", "nc", "nx2", "nth"_a = 0)))
65 .def_readonly("nx", &knot_t::nx)
66 .def_readonly("nu", &knot_t::nu)
67 .def_readonly("nc", &knot_t::nc)
68 .def_readonly("nx2", &knot_t::nx2)
69 .def_readonly("nth", &knot_t::nth)
70 //
71 .def_readwrite("Q", &knot_t::Q)
72 .def_readwrite("S", &knot_t::S)
73 .def_readwrite("R", &knot_t::R)
74 .def_readwrite("q", &knot_t::q)
75 .def_readwrite("r", &knot_t::r)
76 //
77 .def_readwrite("A", &knot_t::A)
78 .def_readwrite("B", &knot_t::B)
79 .def_readwrite("E", &knot_t::E)
80 .def_readwrite("f", &knot_t::f)
81 //
82 .def_readwrite("C", &knot_t::C)
83 .def_readwrite("D", &knot_t::D)
84 .def_readwrite("d", &knot_t::d)
85 //
86 .def_readwrite("Gth", &knot_t::Gth)
87 .def_readwrite("Gx", &knot_t::Gx)
88 .def_readwrite("Gu", &knot_t::Gu)
89 .def_readwrite("gamma", &knot_t::gamma)
90 //
91 .def("isApprox", &knot_t::isApprox,
92 ("self"_a, "prec"_a = std::numeric_limits<Scalar>::epsilon()))
93 //
96
97 StdVectorPythonVisitor<knot_vec_t, false>::expose("StdVec_LqrKnot");
98
99 bp::class_<lqr_t, boost::noncopyable>("LqrProblem", bp::no_init)
100 .def(bp::init<const knot_vec_t &, long>(("self"_a, "stages", "nc0")))
101 .def_readwrite("stages", &lqr_t::stages)
102 .add_property("horizon", &lqr_t::horizon)
103 .def_readwrite("G0", &lqr_t::G0)
104 .def_readwrite("g0", &lqr_t::g0)
105 .add_property("isInitialized", &lqr_t::isInitialized,
106 "Whether the problem is initialized.")
107 .add_property("isParameterized", &lqr_t::isParameterized,
108 "Whether the problem is parameterized.")
109 .def("addParameterization", &lqr_t::addParameterization,
110 ("self"_a, "nth"))
111 .add_property("ntheta", &lqr_t::ntheta)
112 .def("evaluate", &lqr_t::evaluate,
113 ("self"_a, "xs", "us", "theta"_a = std::nullopt),
114 "Evaluate the problem objective.");
115
116 bp::class_<riccati_base_t, boost::noncopyable>("RiccatiSolverBase",
117 bp::no_init)
118 .def("backward", &riccati_base_t::backward, ("self"_a, "mu", "mueq"))
119 .def("forward", &riccati_base_t::forward,
120 ("self"_a, "xs", "us", "vs", "lbdas", "theta"_a = std::nullopt));
121
123
124#ifdef ALIGATOR_WITH_CHOLMOD
125 exposeCholmodSolver();
126#endif
130}
131
132} // namespace aligator::python
virtual bool backward(const Scalar mudyn, const Scalar mueq)=0
virtual bool forward(std::vector< VectorXs > &xs, std::vector< VectorXs > &us, std::vector< VectorXs > &vs, std::vector< VectorXs > &lbdas, const std::optional< ConstVectorRef > &theta_=std::nullopt) const=0
The Python bindings.
Definition blk-matrix.hpp:5
Eigen::Transpose< MatrixXs >::PlainMatrix RowMatrixXs
LqrKnotTpl< context::Scalar > knot_t
void exposeGAR()
Expose GAR module.
RiccatiSolverBase< Scalar > riccati_base_t
bp::object get_namespace(const std::string &name)
Create or retrieve a Python scope (that is, a class or module namespace).
Definition utils.hpp:22
LqrProblemTpl< context::Scalar > lqr_t
lqr_t::KnotVector knot_vec_t
static void exposeBlockMatrices()
Struct describing a stage of a constrained LQ problem.
bool isApprox(const LqrKnotTpl &other, Scalar prec=std::numeric_limits< Scalar >::epsilon()) const
Scalar evaluate(const VectorOfVectors &xs, const VectorOfVectors &us, const std::optional< ConstVectorRef > &theta_) const