10 #ifndef CROCODDYL_CORE_SOLVERS_DDP_HPP_
11 #define CROCODDYL_CORE_SOLVERS_DDP_HPP_
13 #include <Eigen/Cholesky>
16 #include "crocoddyl/core/mathbase.hpp"
17 #include "crocoddyl/core/solver-base.hpp"
18 #include "crocoddyl/core/utils/deprecate.hpp"
56 class SolverDDP :
public SolverAbstract {
58 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
60 typedef typename MathBaseTpl<double>::MatrixXsRowMajor MatrixXdRowMajor;
67 explicit SolverDDP(boost::shared_ptr<ShootingProblem> problem);
71 const std::vector<Eigen::VectorXd>& init_xs = DEFAULT_VECTOR,
72 const std::vector<Eigen::VectorXd>& init_us = DEFAULT_VECTOR,
73 const std::size_t maxiter = 100,
const bool is_feasible =
false,
74 const double init_reg = NAN);
75 virtual void computeDirection(
const bool recalc =
true);
76 virtual double tryStep(
const double steplength = 1);
77 virtual double stoppingCriteria();
78 virtual const Eigen::Vector2d& expectedImprovement();
79 virtual void resizeData();
90 virtual double calcDiff();
124 virtual void backwardPass();
139 virtual void forwardPass(
const double stepLength);
149 virtual void computeActionValueFunction(
150 const std::size_t t,
const boost::shared_ptr<ActionModelAbstract>& model,
151 const boost::shared_ptr<ActionDataAbstract>& data);
162 virtual void computeValueFunction(
163 const std::size_t t,
const boost::shared_ptr<ActionModelAbstract>& model);
179 virtual void computeGains(
const std::size_t t);
185 void increaseRegularization();
191 void decreaseRegularization();
196 virtual void allocateData();
201 double get_reg_incfactor()
const;
206 double get_reg_decfactor()
const;
211 DEPRECATED(
"Use get_reg_incfactor() or get_reg_decfactor()",
212 double get_regfactor()
const;)
217 double get_reg_min()
const;
218 DEPRECATED(
"Use get_reg_min()",
double get_regmin()
const);
223 double get_reg_max()
const;
224 DEPRECATED(
"Use get_reg_max()",
double get_regmax()
const);
229 const std::vector<double>& get_alphas()
const;
234 double get_th_stepdec()
const;
239 double get_th_stepinc()
const;
245 double get_th_grad()
const;
250 const std::vector<Eigen::MatrixXd>& get_Vxx()
const;
255 const std::vector<Eigen::VectorXd>& get_Vx()
const;
261 const std::vector<Eigen::MatrixXd>& get_Qxx()
const;
267 const std::vector<Eigen::MatrixXd>& get_Qxu()
const;
273 const std::vector<Eigen::MatrixXd>& get_Quu()
const;
279 const std::vector<Eigen::VectorXd>& get_Qx()
const;
285 const std::vector<Eigen::VectorXd>& get_Qu()
const;
290 const std::vector<MatrixXdRowMajor>& get_K()
const;
295 const std::vector<Eigen::VectorXd>& get_k()
const;
300 void set_reg_incfactor(
const double reg_factor);
305 void set_reg_decfactor(
const double reg_factor);
310 DEPRECATED(
"Use set_reg_incfactor() or set_reg_decfactor()",
311 void set_regfactor(
const double reg_factor);)
316 void set_reg_min(
const double regmin);
317 DEPRECATED(
"Use set_reg_min()",
void set_regmin(
const double regmin));
322 void set_reg_max(
const double regmax);
323 DEPRECATED(
"Use set_reg_max()",
void set_regmax(
const double regmax));
328 void set_alphas(
const std::vector<double>& alphas);
333 void set_th_stepdec(
const double th_step);
338 void set_th_stepinc(
const double th_step);
344 void set_th_grad(
const double th_grad);
347 double reg_incfactor_;
349 double reg_decfactor_;
355 std::vector<Eigen::VectorXd>
357 std::vector<Eigen::VectorXd>
359 std::vector<Eigen::VectorXd>
363 std::vector<Eigen::MatrixXd>
367 std::vector<Eigen::VectorXd>
369 std::vector<Eigen::MatrixXd>
371 std::vector<Eigen::MatrixXd>
373 std::vector<Eigen::MatrixXd>
375 std::vector<Eigen::VectorXd>
377 std::vector<Eigen::VectorXd>
379 std::vector<MatrixXdRowMajor> K_;
380 std::vector<Eigen::VectorXd> k_;
382 Eigen::VectorXd xnext_;
383 MatrixXdRowMajor FxTVxx_p_;
385 std::vector<MatrixXdRowMajor>
389 Eigen::VectorXd fTVxx_p_;
391 std::vector<Eigen::LLT<Eigen::MatrixXd> > Quu_llt_;
392 std::vector<Eigen::VectorXd>