10#ifndef CROCODDYL_CORE_SOLVERS_FDDP_HPP_ 11#define CROCODDYL_CORE_SOLVERS_FDDP_HPP_ 13#include "crocoddyl/core/solver-base.hpp" 14#include "crocoddyl/core/utils/deprecate.hpp" 18enum DynamicsSolverType {
25enum EqualitySolverType {
69template <
typename _Scalar>
72 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
75 typedef _Scalar Scalar;
78 typedef typename ShootingProblem::ActionModelAbstract ActionModelAbstract;
79 typedef typename ShootingProblem::ActionDataAbstract ActionDataAbstract;
82 typedef typename MathBase::VectorXs VectorXs;
83 typedef typename MathBase::Vector3s Vector3s;
84 typedef typename MathBase::MatrixXs MatrixXs;
85 typedef typename MathBase::MatrixXsRowMajor MatrixXsRowMajor;
100 const DynamicsSolverType dyn_solver = FeasShoot,
101 const EqualitySolverType term_solver = LuNull);
236 const std::size_t t,
const std::shared_ptr<ActionModelAbstract>& model,
237 const std::shared_ptr<ActionDataAbstract>& data);
247 const std::size_t t,
const std::shared_ptr<ActionDataAbstract>& data);
284 const std::size_t t,
const std::shared_ptr<ActionModelAbstract>& model);
382 template <
typename NewScalar>
470 const std::vector<std::size_t>&
get_Ts()
const;
480 const std::vector<VectorXs>&
get_Vx()
const;
504 const std::vector<VectorXs>&
get_Qx()
const;
510 const std::vector<VectorXs>&
get_Qu()
const;
515 const std::vector<MatrixXsRowMajor>&
get_K()
const;
520 const std::vector<VectorXs>&
get_k()
const;
552 const std::vector<MatrixXs>&
get_Kc()
const;
583 const std::size_t Tshoot = 0);
715 std::vector<std::size_t>
Ts_;
719 std::vector<MatrixXs>
721 std::vector<VectorXs>
724 std::vector<VectorXs>
726 std::vector<VectorXs>
729 std::vector<VectorXs>
732 std::vector<VectorXs>
735 std::vector<MatrixXs>
737 std::vector<MatrixXs>
739 std::vector<MatrixXs>
741 std::vector<VectorXs>
743 std::vector<VectorXs>
745 std::vector<MatrixXsRowMajor>
K_;
746 std::vector<VectorXs>
k_;
747 std::vector<VectorXs>
749 std::vector<MatrixXsRowMajor>
752 std::vector<MatrixXsRowMajor>
759 std::vector<VectorXs>
763 std::size_t dHc_rank_;
764 std::vector<MatrixXs>
767 std::vector<MatrixXs>
770 std::vector<MatrixXs>
773 std::vector<MatrixXs> dXc_;
775 std::vector<MatrixXs> dUc_;
777 std::vector<MatrixXs> Kc_;
788 Eigen::FullPivLU<MatrixXs>
791 Eigen::ColPivHouseholderQR<MatrixXs>
796 "Do not use this member",
799 "Do not use this member",
802 "Do not use this member",
805 using SolverAbstract::acceptstep_;
822 using SolverAbstract::feasnorm_;
842 using SolverAbstract::th_gaptol_;
855#include "crocoddyl/core/solvers/fddp.hxx" 857CROCODDYL_DISABLE_WARNING_DEPRECATED
861CROCODDYL_ENABLE_WARNING_DEPRECATED
Abstract class for solver callbacks.
This class encapsulates a shooting problem.
virtual void resizeData()
std::vector< VectorXs > dxs_
std::vector< VectorXs > fs_
Scalar computeDynamicFeasibility()
std::vector< VectorXs > us_try_
std::shared_ptr< ShootingProblem > problem_
SolverAbstractTpl(std::shared_ptr< ShootingProblem > problem)
Initialize the solver.
std::vector< VectorXs > fs_try_
std::vector< std::shared_ptr< CallbackAbstract > > callbacks_
Scalar computeEqualityFeasibility()
std::vector< VectorXs > xs_
std::vector< VectorXs > us_
Scalar computeInequalityFeasibility()
std::vector< Scalar > alphas_
std::vector< VectorXs > dus_
Scalar computeFeasibility(const std::vector< VectorXs > &fs)
std::vector< VectorXs > xs_try_
Feasibility-driven Differential Dynamic Programming (FDDP) solver.
Scalar get_reg_incfactor() const
Return the regularization factor used to increase the damping value.
std::vector< VectorXs > dx_
DynamicsSolverType get_dynamics_solver() const
Return the type of solver used for handling the dynamics constraints.
const std::vector< MatrixXs > & get_Vxx() const
Return the Hessian of the Value function .
Scalar get_th_minimprove() const
Return the minimum improvement threshold used to increase regularization.
void set_reg_incfactor(const Scalar reg_factor)
Modify the regularization factor used to increase the damping value.
virtual void resizeRunningData() override
Resize data associated with the running models of the shooting problem.
std::vector< MatrixXs > Vxx_
const std::vector< MatrixXs > & get_Kc() const
Return the feedforward gains .
void set_th_stepdec(const Scalar th_step)
Modify the step-length threshold used to decrease regularization.
virtual void computeDirection(const bool recalc=true) override
Compute the search direction for the current guess .
const std::vector< MatrixXs > & get_Quu() const
Return the Hessian of the Hamiltonian function .
std::vector< MatrixXsRowMajor > FuTVxx_p_
virtual void computeExpectedMeritFunctionImprovement() override
Compute the expected merit function improvement for the current step.
Scalar get_rho() const
Return the rho parameter used in the merit function.
Scalar upsilon_decfactor_
const std::vector< MatrixXs > & get_dXc() const
Return the linear update in .
void updateDir()
Update search direction associated with the batch's constraints.
void set_th_stepinc(const Scalar th_step)
Modify the step-length threshold used to increase regularization.
virtual void backwardPass()
Run the backward pass (Riccati sweep).
void set_th_acceptminstep(const Scalar th_acceptminstep)
Modify the threshold used for accepting minimum steps.
EqualitySolverType get_terminal_solver() const
Return the type of solver used for handling the terminal constraints.
virtual void hybridShootForwardPass(const Scalar steplength)
Run the multiple-shooting rollout with intervals of feasibility-driven search.
const std::vector< VectorXs > & get_Vx() const
Return the Hessian of the Value function .
virtual void computeCandidate(const Scalar step_length=Scalar(1.)) override
Compute new candidate solution using step length.
virtual void computeValueFunction(const std::size_t t, const std::shared_ptr< ActionModelAbstract > &model)
Compute the linear-quadratic approximation of the value function.
void set_th_minfeas(const Scalar th_minfeas)
Modify the threshold for switching to feasibility.
Scalar get_th_stepdec() const
Return the step-length threshold used to decrease regularization.
virtual void computeActionValueFunction(const std::size_t t, const std::shared_ptr< ActionModelAbstract > &model, const std::shared_ptr< ActionDataAbstract > &data)
Compute the linear-quadratic approximation of the control action-value function.
DynamicsSolverType dyn_solver_
std::vector< VectorXs > Lxx_dx_
Scalar get_th_acceptminstep() const
Return the threshold used for accepting minimum steps.
virtual void updateDualsAndSlacks(const Scalar stepLength=Scalar(1.))
Update the dual and slack variables with a predefined step length.
std::vector< VectorXs > Qx_
void forwardPass(const Scalar steplength=Scalar(1.))
Perform a forward pass with a predefined step length.
void batchPass()
Run the batch pass to account for its constraints.
virtual void computeBatchPolicy(const std::size_t t)
Compute the feedforward and feedback terms (control policy) associated to the batch's constraints.
const std::vector< std::size_t > & get_Ts() const
Return the hybrid shooting intervals.
void allocateData()
Allocate all the internal data needed for the solver.
Scalar get_upsilon() const
Return the estimated penalty parameter that balances relative contribution of the cost function and e...
std::vector< MatrixXs > Qxx_
const std::vector< VectorXs > & get_Qx() const
Return the Jacobian of the Hamiltonian function .
void set_th_noimprovement(const Scalar th_noimprovement)
Modify the threshold used to accept steps that cannot be be improved due to numerical errors the th n...
const std::vector< VectorXs > & get_Qu() const
Return the Jacobian of the Hamiltonian function .
const std::vector< MatrixXs > & get_Qxc() const
Return the Hessian of the Hamiltonian function .
void set_reg_decfactor(const Scalar reg_factor)
Modify the regularization factor used to decrease the damping value.
SolverFDDPTpl(std::shared_ptr< ShootingProblem > problem, const DynamicsSolverType dyn_solver=FeasShoot, const EqualitySolverType term_solver=LuNull)
Initialize the FDDP solver.
bool increaseRegularizationCriteria() override
Criteria used to increase regularization.
const std::vector< MatrixXs > & get_dUc() const
Return the linear update in .
const std::vector< MatrixXsRowMajor > & get_K() const
Return the feedback gains .
std::vector< MatrixXs > Qxu_
virtual void computeMeritFunctionImprovement() override
Compute the merit function improvement for the current step.
void set_upsilon_decfactor(const Scalar th_step)
Modify the upsilon decresing factor used to estimate to balance optimality and feasibility.
virtual void computeBatchValueFunction(const std::size_t t)
Compute the linear-quadratic approximation of the value function associated to the batch's constraint...
void set_th_minimprove(const Scalar th_step)
Modify the minimum improvement threshold used to increase regularization.
void set_rho(const Scalar rho)
Modify the rho parameter used in the merit function.
void set_terminal_solver(const EqualitySolverType type)
Set the type of solver used for handling the terminal constraints.
Scalar get_upsilon_decfactor() const
Return the upsilon decresing factor used to estimate to balance optimality and feasibility.
const std::vector< VectorXs > & get_k() const
Return the feedforward gains .
SolverFDDPTpl< NewScalar > cast() const
Cast the FDDP solver to a different scalar type.
void set_zero_upsilon(const bool zero_upsilon)
Modify the zero-upsilon label.
virtual void feasShootForwardPass(const Scalar steplength)
Run the feasibility-driven nonlinear rollout.
std::vector< MatrixXs > Quu_
std::vector< VectorXs > Lxu_du_
std::vector< std::size_t > Ts_
Scalar get_th_stepinc() const
Return the step-length threshold used to increase regularization.
std::vector< MatrixXsRowMajor > FxTVxx_p_
const VectorXs & get_beta_plus() const
Return the next terminal-constraint multiplier .
const std::vector< MatrixXs > & get_Vxc() const
Return the Hessian of the Value function .
bool decreaseRegularizationCriteria() override
Criteria used to decrease regularization.
virtual void computeBatchActionValueFunction(const std::size_t t, const std::shared_ptr< ActionDataAbstract > &data)
Compute the linear-quadratic approximation of the control action-value function associated to the bat...
std::vector< VectorXs > Vx_
void set_th_acceptnegstep(const Scalar th_acceptnegstep)
Modify the threshold used for accepting step along ascent direction.
std::vector< VectorXs > Qu_
const VectorXs & get_hc() const
Return the bias term of the terminal constraint gains .
Scalar get_th_minfeas() const
Return the threshold for switching to feasibility.
virtual void resizeTerminalData() override
Resize data associated with the terminal model of the shooting problem.
const std::vector< MatrixXs > & get_Qxu() const
Return the Hessian of the Hamiltonian function .
void set_dynamics_solver(const DynamicsSolverType type, const std::size_t Tshoot=0)
Set the dynamic solver used for handling the dynamics constraints.
std::vector< MatrixXsRowMajor > K_
bool get_zero_upsilon() const
Return the zero-upsilon label.
const std::vector< MatrixXs > & get_Qxx() const
Return the Hessian of the Hamiltonian function .
virtual void computePolicy(const std::size_t t)
Compute the feedforward and feedback terms (control policy) computed via a Cholesky decomposition.
EqualitySolverType term_solver_
Scalar get_th_grad() const
Return the tolerance of the expected gradient used for testing the step.
void decreaseRegularization() override
Decrease the state and control regularization values by a regfactor_ factor.
std::vector< Eigen::LLT< MatrixXs > > Quu_llt_
void increaseRegularization() override
Increase the state and control regularization values by a regfactor_ factor.
virtual Vector3s expectedImprovement() override
Return the expected improvement from a given current search direction .
virtual Scalar stoppingCriteria() override
Return a positive value that quantifies the algorithm termination.
void computeNullTerminalMultiplier()
compute the multiplier associated to the terminal constraint
virtual bool checkAcceptance() override
Check if we should accept or not the step.
virtual void updateMeritFunction() override
Update the merit function value for the current guess.
Scalar get_th_acceptnegstep() const
Return the threshold used for accepting step along ascent direction.
void updateCandidate() override
Update the candidate solution: cost, feasibilities, and merit value.
void set_th_grad(const Scalar th_grad)
Modify the tolerance of the expected gradient used for testing the step.
std::vector< VectorXs > Vxx_f_
std::vector< VectorXs > k_
void linearRollout()
Perform a linear rollout give the current control policy.
Scalar get_reg_decfactor() const
Return the regularization factor used to decrease the damping value.
virtual void multiShootForwardPass(const Scalar steplength)
Run the multiple-shooting rollout.
const MatrixXs & get_dHc() const
Return the Jacobian of the terminal constraint gains .
const std::vector< MatrixXs > & get_Quc() const
Return the Hessian of the Hamiltonian function .
std::vector< VectorXs > Luu_du_
virtual void singleShootForwardPass(const Scalar steplength)
Run the classical nonlinear rollout.