11#include <eigenpy/std-array.hpp>
18using knot_t = LQRKnotTpl<context::Scalar>;
19using lqr_t = LQRProblemTpl<context::Scalar>;
21using context::MatrixXs;
23using context::VectorXs;
30 auto &[xs, us, vs, lbdas] = ss;
39 BlkMatrixPythonVisitor<BlkMatrix<MatrixXs, 2, 2>>::expose(
"BlockMatrix22");
40 BlkMatrixPythonVisitor<BlkMatrix<VectorXs, 4, 1>>::expose(
"BlockVector4");
41 BlkMatrixPythonVisitor<BlkMatrix<VectorXs, 2, 1>>::expose(
"BlockVector2");
42 BlkMatrixPythonVisitor<BlkMatrix<RowMatrixXs, 4, 1>>::expose(
44 BlkMatrixPythonVisitor<BlkMatrix<RowMatrixXs, 2, 1>>::expose(
46 eigenpy::StdArrayPythonVisitor<std::array<long, 1>,
true>::expose(
48 eigenpy::StdArrayPythonVisitor<std::array<long, 2>,
true>::expose(
50 eigenpy::StdArrayPythonVisitor<std::array<long, 4>,
true>::expose(
54#ifdef ALIGATOR_WITH_CHOLMOD
67 bp::scope ns = get_namespace(
"gar");
71 bp::class_<knot_t>(
"LQRKnot", bp::no_init)
72 .def(bp::init<uint, uint, uint>((
"nx"_a,
"nu",
"nc")))
73 .def(bp::init<uint, uint, uint, uint>((
"nx"_a,
"nu",
"nc",
"nx2")))
74 .def_readonly(
"nx", &knot_t::nx)
75 .def_readonly(
"nu", &knot_t::nu)
76 .def_readonly(
"nc", &knot_t::nc)
77 .def_readonly(
"nx2", &knot_t::nx2)
78 .def_readonly(
"nth", &knot_t::nth)
80 .def_readwrite(
"Q", &knot_t::Q)
81 .def_readwrite(
"S", &knot_t::S)
82 .def_readwrite(
"R", &knot_t::R)
83 .def_readwrite(
"q", &knot_t::q)
84 .def_readwrite(
"r", &knot_t::r)
86 .def_readwrite(
"A", &knot_t::A)
87 .def_readwrite(
"B", &knot_t::B)
88 .def_readwrite(
"E", &knot_t::E)
89 .def_readwrite(
"f", &knot_t::f)
91 .def_readwrite(
"C", &knot_t::C)
92 .def_readwrite(
"D", &knot_t::D)
93 .def_readwrite(
"d", &knot_t::d)
95 .def_readwrite(
"Gth", &knot_t::Gth)
96 .def_readwrite(
"Gx", &knot_t::Gx)
97 .def_readwrite(
"Gu", &knot_t::Gu)
98 .def_readwrite(
"gamma", &knot_t::gamma)
100 .def(CopyableVisitor<knot_t>())
101 .def(PrintableVisitor<knot_t>());
103 StdVectorPythonVisitor<knot_vec_t, false>::expose(
"StdVec_LQRKnot");
105 bp::class_<lqr_t>(
"LQRProblem", bp::no_init)
106 .def(bp::init<const knot_vec_t &, long>((
"self"_a,
"stages",
"nc0")))
112 "Whether the problem is initialized.")
114 "Whether the problem is parameterized.")
119 (
"self"_a,
"xs",
"us",
"theta"_a = std::nullopt),
120 "Evaluate the problem objective.")
121 .def(CopyableVisitor<lqr_t>());
123 bp::class_<riccati_base_t, boost::noncopyable>(
"RiccatiSolverBase",
127 (
"self"_a,
"xs",
"us",
"vs",
"lbdas",
"theta"_a = std::nullopt));
131 +[](
const lqr_t &problem, Scalar mudyn, Scalar mueq) {
133 return bp::make_tuple(std::get<0>(mat_rhs), std::get<1>(mat_rhs));
135 (
"problem"_a,
"mudyn",
"mueq"));
139#ifdef ALIGATOR_WITH_CHOLMOD
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
auto lqrInitializeSolution(const LQRProblemTpl< Scalar > &problem)
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...
Eigen::Transpose< MatrixXs >::PlainMatrix RowMatrixXs
bp::dict lqr_sol_initialize_wrap(const lqr_t &problem)
void exposeGAR()
Expose GAR module.
RiccatiSolverBase< Scalar > riccati_base_t
LQRKnotTpl< context::Scalar > knot_t
void exposeCholmodSolver()
lqr_t::KnotVector knot_vec_t
void exposeParallelSolver()
static void exposeBlockMatrices()
bool isInitialized() const
std::vector< KnotType > KnotVector
bool isParameterized() const
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