Crocoddyl
Loading...
Searching...
No Matches
intro.hpp
1
2// BSD 3-Clause License
3//
4// Copyright (C) 2021-2026, Heriot-Watt University, University of Edinburgh
5// Copyright note valid unless otherwise stated in individual files.
6// All rights reserved.
8
9#ifndef CROCODDYL_CORE_SOLVERS_INTRO_HPP_
10#define CROCODDYL_CORE_SOLVERS_INTRO_HPP_
11
12#include "crocoddyl/core/solvers/fddp.hpp"
13
14namespace crocoddyl {
15
16template <typename _Scalar>
17class SolverIntroTpl : public SolverFDDPTpl<_Scalar> {
18 public:
19 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
20 CROCODDYL_DERIVED_FLOATINGPOINT_CAST(SolverBase, SolverIntroTpl)
21
22 typedef _Scalar Scalar;
23 typedef SolverAbstractTpl<Scalar> SolverAbstract;
24 typedef SolverFDDPTpl<Scalar> SolverFDDP;
25 typedef ShootingProblemTpl<Scalar> ShootingProblem;
26 typedef typename ShootingProblem::ActionModelAbstract ActionModelAbstract;
27 typedef typename ShootingProblem::ActionDataAbstract ActionDataAbstract;
28 typedef MathBaseTpl<Scalar> MathBase;
29 typedef typename MathBase::VectorXs VectorXs;
30 typedef typename MathBase::MatrixXs MatrixXs;
31 typedef typename MathBase::MatrixXsRowMajor MatrixXsRowMajor;
32
40 explicit SolverIntroTpl(std::shared_ptr<ShootingProblem> problem,
41 const DynamicsSolverType dyn_solver = FeasShoot,
42 const EqualitySolverType eq_solver = LuNull,
43 const EqualitySolverType term_solver = LuNull);
44 virtual ~SolverIntroTpl() = default;
45
55 virtual void calcDir() override;
56
60 virtual void computeDirection(const bool recalc = true) override;
61
65 virtual void computePolicy(const std::size_t t) override;
66
70 virtual void computeBatchPolicy(const std::size_t t) override;
71
75 virtual void computeValueFunction(
76 const std::size_t t,
77 const std::shared_ptr<ActionModelAbstract>& model) override;
78
82 virtual void computeBatchValueFunction(const std::size_t t) override;
83
92 template <typename NewScalar>
94
98 EqualitySolverType get_equality_solver() const;
99
103 const std::vector<std::size_t>& get_Hu_rank() const;
104
109 const std::vector<MatrixXs>& get_YZ() const;
110
114 const std::vector<MatrixXs>& get_Qzz() const;
115
119 const std::vector<MatrixXs>& get_Qxz() const;
120
124 const std::vector<MatrixXs>& get_Quz() const;
125
129 const std::vector<VectorXs>& get_Qz() const;
130
135 const std::vector<MatrixXs>& get_Hy() const;
136
141 const std::vector<VectorXs>& get_kz() const;
142
146 const std::vector<MatrixXs>& get_Kz() const;
147
151 const std::vector<VectorXs>& get_ks() const;
152
156 const std::vector<MatrixXs>& get_Ks() const;
157
161 const std::vector<MatrixXs>& get_Qzc() const;
162
170 void set_equality_solver(const EqualitySolverType type);
171
172 protected:
173 void allocateData();
174
178 virtual void resizeRunningData() override;
179
183 virtual void resizeTerminalData() override;
184
185 using SolverAbstract::feasnorm_;
187 using SolverAbstract::th_gaptol_;
193 using SolverFDDP::fs_;
194 using SolverFDDP::K_;
195 using SolverFDDP::k_;
196 using SolverFDDP::Kc_;
198 using SolverFDDP::Qu_;
199 using SolverFDDP::Quc_;
200 using SolverFDDP::Quu_;
202 using SolverFDDP::Quuk_;
203 using SolverFDDP::Qx_;
204 using SolverFDDP::Qxu_;
205 using SolverFDDP::Qxx_;
210 using SolverFDDP::rho_;
222 using SolverFDDP::Ts_;
224 using SolverFDDP::Vx_;
225 using SolverFDDP::Vxc_;
226 using SolverFDDP::Vxx_;
230
231 void calcLuNullDir();
232 void calcQrNullDir();
233 void computeNullPolicy(const std::size_t t);
234 void computeNullBatchPolicy(const std::size_t t);
235 void computeSchurPolicy(const std::size_t t);
236 void computeSchurBatchPolicy(const std::size_t t);
237
238 enum EqualitySolverType
239 eq_solver_;
240
241 std::vector<std::size_t>
242 Hu_rank_;
243 std::vector<MatrixXsRowMajor> KQuu_2Qxu_;
244 std::vector<MatrixXs>
245 YZ_;
248 std::vector<MatrixXs>
249 Hy_;
251 std::vector<VectorXs>
252 Qz_;
253 std::vector<MatrixXs>
254 Qzz_;
255 std::vector<MatrixXs>
256 Qxz_;
257 std::vector<MatrixXs>
258 Quz_;
259 std::vector<VectorXs>
260 kz_;
261 std::vector<MatrixXs>
262 Kz_;
263 std::vector<VectorXs>
264 ks_;
265 std::vector<MatrixXs>
266 Ks_;
267 std::vector<MatrixXs> QuuinvHuT_;
268 std::vector<Eigen::LLT<MatrixXs> > Qzz_llt_;
269 std::vector<Eigen::FullPivLU<MatrixXs> >
270 Hu_lu_;
272 std::vector<Eigen::ColPivHouseholderQR<MatrixXs> >
273 Hu_qr_;
275 std::vector<Eigen::PartialPivLU<MatrixXs> >
276 Hy_lu_;
278
279 std::vector<MatrixXs> Kcs_;
280 std::vector<MatrixXs> QuuKc_Quc_;
281 std::vector<MatrixXs>
282 Qzc_;
283};
284
285} // namespace crocoddyl
286
287/* --- Details -------------------------------------------------------------- */
288/* --- Details -------------------------------------------------------------- */
289/* --- Details -------------------------------------------------------------- */
290#include "crocoddyl/core/solvers/intro.hxx"
291
292CROCODDYL_DECLARE_EXTERN_TEMPLATE_CLASS(crocoddyl::SolverIntroTpl)
293
294#endif // CROCODDYL_CORE_SOLVERS_INTRO_HPP_
This class encapsulates a shooting problem.
Definition shooting.hpp:32
Abstract class for optimal control solvers.
std::shared_ptr< ShootingProblem > problem_
std::vector< std::shared_ptr< CallbackAbstract > > callbacks_
virtual void resizeRunningData() override
Resize data associated with the running models of the shooting problem.
std::vector< MatrixXs > Vxx_
Definition fddp.hpp:720
DynamicsSolverType dyn_solver_
Definition fddp.hpp:685
std::vector< VectorXs > Qx_
Definition fddp.hpp:742
void allocateData()
Allocate all the internal data needed for the solver.
std::vector< MatrixXs > Qxx_
Definition fddp.hpp:736
SolverFDDPTpl(std::shared_ptr< ShootingProblem > problem, const DynamicsSolverType dyn_solver=FeasShoot, const EqualitySolverType term_solver=LuNull)
Initialize the FDDP solver.
std::vector< MatrixXs > Qxu_
Definition fddp.hpp:738
std::vector< MatrixXs > Quu_
Definition fddp.hpp:740
std::vector< std::size_t > Ts_
Definition fddp.hpp:715
std::vector< VectorXs > Vx_
Definition fddp.hpp:725
std::vector< VectorXs > Qu_
Definition fddp.hpp:744
virtual void resizeTerminalData() override
Resize data associated with the terminal model of the shooting problem.
std::vector< MatrixXsRowMajor > K_
Definition fddp.hpp:745
EqualitySolverType term_solver_
Definition fddp.hpp:686
std::vector< Eigen::LLT< MatrixXs > > Quu_llt_
Definition fddp.hpp:758
std::vector< VectorXs > Vxx_f_
Definition fddp.hpp:722
std::vector< VectorXs > k_
Definition fddp.hpp:746
virtual void calcDir() override
Refresh the Intro linearization and constraint factorizations.
virtual void computeDirection(const bool recalc=true) override
Compute the search direction for the current guess .
SolverIntroTpl(std::shared_ptr< ShootingProblem > problem, const DynamicsSolverType dyn_solver=FeasShoot, const EqualitySolverType eq_solver=LuNull, const EqualitySolverType term_solver=LuNull)
Initialize the INTRO solver.
EqualitySolverType get_equality_solver() const
Return the type of solver used for handling the equality constraints.
virtual void computeBatchValueFunction(const std::size_t t) override
Compute the linear-quadratic approximation of the value function associated to the batch's constraint...
virtual void computePolicy(const std::size_t t) override
Compute the feedforward and feedback terms (control policy) computed via a Cholesky decomposition.
virtual void computeValueFunction(const std::size_t t, const std::shared_ptr< ActionModelAbstract > &model) override
Compute the linear-quadratic approximation of the value function.
SolverIntroTpl< NewScalar > cast() const
Cast the Intro solver to a different scalar type.
virtual void computeBatchPolicy(const std::size_t t) override
Compute the feedforward and feedback terms (control policy) associated to the batch's constraints.