11#ifndef CROCODDYL_CORE_SOLVERS_KKT_HPP_ 12#define CROCODDYL_CORE_SOLVERS_KKT_HPP_ 14#include "crocoddyl/core/solver-base.hpp" 18template <
typename _Scalar>
21 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
22 CROCODDYL_DERIVED_FLOATINGPOINT_CAST(
SolverBase, SolverKKTTpl)
24 typedef _Scalar Scalar;
27 typedef typename ShootingProblem::ActionModelAbstract ActionModelAbstract;
28 typedef typename ShootingProblem::ActionDataAbstract ActionDataAbstract;
31 typedef typename MathBase::VectorXs VectorXs;
32 typedef typename MathBase::MatrixXs MatrixXs;
33 typedef typename MathBase::Vector3s Vector3s;
36 explicit SolverKKTTpl(std::shared_ptr<ShootingProblem> problem);
37 virtual ~SolverKKTTpl() =
default;
40 const std::vector<VectorXs>& init_xs = DefaultVector<Scalar>::value,
41 const std::vector<VectorXs>& init_us = DefaultVector<Scalar>::value,
42 const std::size_t maxiter = 100,
const bool is_feasible =
false,
43 const Scalar regInit = 1e-9)
override;
45 virtual Scalar
tryStep(
const Scalar steplength = Scalar(1.))
override;
57 template <
typename NewScalar>
58 SolverKKTTpl<NewScalar>
cast()
const;
60 const MatrixXs& get_kkt()
const;
61 const VectorXs& get_kktref()
const;
62 const VectorXs& get_primaldual()
const;
63 const std::vector<VectorXs>&
get_dxs()
const;
64 const std::vector<VectorXs>&
get_dus()
const;
65 const std::vector<VectorXs>& get_lambdas()
const;
66 std::size_t get_nx()
const;
67 std::size_t get_ndx()
const;
68 std::size_t get_nu()
const;
123 Scalar reg_incfactor_;
124 Scalar reg_decfactor_;
127 std::vector<Scalar> alphas_;
133 void computePrimalDual();
138 std::vector<VectorXs> dxs_;
139 std::vector<VectorXs> dus_;
140 std::vector<VectorXs> lambdas_;
145 VectorXs primaldual_;
148 VectorXs kkt_primal_;
157#include "crocoddyl/core/solvers/kkt.hxx" Abstract class for solver callbacks.
This class encapsulates a shooting problem.
const std::vector< VectorXs > & get_dus() const
Return the feedforward gains .
std::vector< VectorXs > us_try_
std::shared_ptr< ShootingProblem > problem_
void allocateData()
Allocate all the basic data needed in solvers.
SolverAbstractTpl(std::shared_ptr< ShootingProblem > problem)
Initialize the solver.
std::vector< std::shared_ptr< CallbackAbstract > > callbacks_
std::vector< VectorXs > xs_
std::vector< VectorXs > us_
virtual void setCandidate(const std::vector< VectorXs > &xs_warm=DefaultVector< Scalar >::value, const std::vector< VectorXs > &us_warm=DefaultVector< Scalar >::value, const bool is_feasible=false)
const std::vector< VectorXs > & get_dxs() const
Return the linear update in .
std::vector< VectorXs > xs_try_
void set_reg_incfactor(const Scalar reg_factor)
Modify the regularization factor used to increase the damping value.
SolverKKTTpl< NewScalar > cast() const
Cast the KKT solver to a different scalar type.
virtual void computeDirection(const bool recalc=true) override
Compute the search direction for the current guess .
void set_reg_decfactor(const Scalar reg_factor)
Modify the regularization factor used to decrease the damping value.
void set_reg_min(const Scalar regmin)
Modify the minimum regularization value.
virtual bool solve(const std::vector< VectorXs > &init_xs=DefaultVector< Scalar >::value, const std::vector< VectorXs > &init_us=DefaultVector< Scalar >::value, const std::size_t maxiter=100, const bool is_feasible=false, const Scalar regInit=1e-9) override
Compute the optimal trajectory as lists of and terms.
virtual Scalar tryStep(const Scalar steplength=Scalar(1.)) override
Try a predefined step length and compute its cost improvement and merit improvement .
void set_reg_max(const Scalar regmax)
Modify the maximum regularization value.
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 set_th_grad(const Scalar th_grad)
Modify the tolerance of the expected gradient used for testing the step.
void set_alphas(const std::vector< Scalar > &alphas)
Modify the set of step lengths using by the line-search procedure.