aligator  0.9.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
expose-utils.cpp
Go to the documentation of this file.
3
4#include <eigenpy/std-array.hpp>
5
6namespace aligator::python {
7using namespace gar;
8
10using lqr_t = LQRProblemTpl<context::Scalar>;
11
12bp::dict lqr_sol_initialize_wrap(const lqr_t &problem) {
13 bp::dict out;
14 auto ss = lqrInitializeSolution(problem);
15 auto &[xs, us, vs, lbdas] = ss;
16 out["xs"] = xs;
17 out["us"] = us;
18 out["vs"] = vs;
19 out["lbdas"] = lbdas;
20 return out;
21}
22
24
25 bp::def(
26 "lqrDenseMatrix",
27 +[](const lqr_t &problem, Scalar mudyn, Scalar mueq) {
28 auto mat_rhs = lqrDenseMatrix(problem, mudyn, mueq);
29 return bp::make_tuple(std::get<0>(mat_rhs), std::get<1>(mat_rhs));
30 },
31 ("problem"_a, "mudyn", "mueq"));
32
33 bp::def("lqrCreateSparseMatrix", lqrCreateSparseMatrix<Scalar>,
34 ("problem"_a, "mudyn", "mueq", "mat", "rhs", "update"),
35 "Create or update a sparse matrix from an LQRProblem.");
36
37 bp::def("lqrInitializeSolution", lqr_sol_initialize_wrap, ("problem"_a));
38
39 bp::def("lqrComputeKktError", lqrComputeKktError<Scalar>,
40 ("problem"_a, "xs", "us", "vs", "lbdas", "mudyn", "mueq", "theta",
41 "verbose"_a = false),
42 "Compute the KKT residual of the LQR problem.");
43}
44} // namespace aligator::python
auto lqrInitializeSolution(const LQRProblemTpl< Scalar > &problem)
Definition utils.hpp:140
bool lqrDenseMatrix(const LQRProblemTpl< Scalar > &problem, Scalar mudyn, Scalar mueq, typename math_types< Scalar >::MatrixXs &mat, typename math_types< Scalar >::VectorXs &rhs)
Fill in a KKT constraint matrix and vector for the given LQ problem with the given dual-regularizatio...
void lqrCreateSparseMatrix(const LQRProblemTpl< Scalar > &problem, const Scalar mudyn, const Scalar mueq, Eigen::SparseMatrix< Scalar > &mat, Eigen::Matrix< Scalar, -1, 1 > &rhs, bool update)
std::array< Scalar, 3 > lqrComputeKktError(const LQRProblemTpl< Scalar > &problem, boost::span< const typename math_types< Scalar >::VectorXs > xs, boost::span< const typename math_types< Scalar >::VectorXs > us, boost::span< const typename math_types< Scalar >::VectorXs > vs, boost::span< const typename math_types< Scalar >::VectorXs > lbdas, const Scalar mudyn, const Scalar mueq, const std::optional< typename math_types< Scalar >::ConstVectorRef > &theta_, bool verbose=false)
The Python bindings.
Definition blk-matrix.hpp:5
bp::dict lqr_sol_initialize_wrap(const lqr_t &problem)
LQRProblemTpl< context::Scalar > lqr_t