aligator  0.9.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;
16using riccati_base_t = RiccatiSolverBase<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>(("nx"_a, "nu", "nc")))
63 .def(bp::init<uint, uint, uint, uint>(("nx"_a, "nu", "nc", "nx2")))
64 .def_readonly("nx", &knot_t::nx)
65 .def_readonly("nu", &knot_t::nu)
66 .def_readonly("nc", &knot_t::nc)
67 .def_readonly("nx2", &knot_t::nx2)
68 .def_readonly("nth", &knot_t::nth)
69 //
70 .def_readwrite("Q", &knot_t::Q)
71 .def_readwrite("S", &knot_t::S)
72 .def_readwrite("R", &knot_t::R)
73 .def_readwrite("q", &knot_t::q)
74 .def_readwrite("r", &knot_t::r)
75 //
76 .def_readwrite("A", &knot_t::A)
77 .def_readwrite("B", &knot_t::B)
78 .def_readwrite("E", &knot_t::E)
79 .def_readwrite("f", &knot_t::f)
80 //
81 .def_readwrite("C", &knot_t::C)
82 .def_readwrite("D", &knot_t::D)
83 .def_readwrite("d", &knot_t::d)
84 //
85 .def_readwrite("Gth", &knot_t::Gth)
86 .def_readwrite("Gx", &knot_t::Gx)
87 .def_readwrite("Gu", &knot_t::Gu)
88 .def_readwrite("gamma", &knot_t::gamma)
89 //
90 .def("isApprox", &knot_t::isApprox,
91 ("self"_a, "prec"_a = std::numeric_limits<Scalar>::epsilon()))
92 //
95
96 StdVectorPythonVisitor<knot_vec_t, false>::expose("StdVec_LQRKnot");
97
98 bp::class_<lqr_t>("LQRProblem", bp::no_init)
99 .def(bp::init<const knot_vec_t &, long>(("self"_a, "stages", "nc0")))
100 .def_readwrite("stages", &lqr_t::stages)
101 .add_property("horizon", &lqr_t::horizon)
102 .def_readwrite("G0", &lqr_t::G0)
103 .def_readwrite("g0", &lqr_t::g0)
104 .add_property("isInitialized", &lqr_t::isInitialized,
105 "Whether the problem is initialized.")
106 .add_property("isParameterized", &lqr_t::isParameterized,
107 "Whether the problem is parameterized.")
108 .def("addParameterization", &lqr_t::addParameterization,
109 ("self"_a, "nth"))
110 .add_property("ntheta", &lqr_t::ntheta)
111 .def("evaluate", &lqr_t::evaluate,
112 ("self"_a, "xs", "us", "theta"_a = std::nullopt),
113 "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
void exposeGAR()
Expose GAR module.
RiccatiSolverBase< Scalar > riccati_base_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
std::vector< KnotType > KnotVector
void addParameterization(uint nth)
Scalar evaluate(const VectorOfVectors &xs, const VectorOfVectors &us, const std::optional< ConstVectorRef > &theta_) const
Evaluate the quadratic objective.
int horizon() const noexcept