9#ifndef CROCODDYL_CORE_SOLVERS_ODYN_SQP_HPP_ 10#define CROCODDYL_CORE_SOLVERS_ODYN_SQP_HPP_ 12#include <odyn/data.hpp> 13#include <odyn/model.hpp> 14#include <odyn/params.hpp> 15#include <odyn/solver.hpp> 17#include "crocoddyl/core/solver-base.hpp" 18#include "crocoddyl/core/utils/deprecate.hpp" 37template <
typename _Scalar>
40 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
43 typedef _Scalar Scalar;
46 typedef typename ShootingProblem::ActionModelAbstract ActionModelAbstract;
47 typedef typename ShootingProblem::ActionDataAbstract ActionDataAbstract;
50 typedef typename MathBase::VectorXs VectorXs;
51 typedef typename MathBase::Vector3s Vector3s;
52 typedef typename MathBase::MatrixXs MatrixXs;
53 typedef typename MathBase::MatrixXsRowMajor MatrixXsRowMajor;
54 using Solver =
typename odyn::SparseQPTpl<Scalar>;
55 using Model =
typename odyn::SparseModelTpl<Scalar>;
56 using Data =
typename odyn::SparseDataTpl<Scalar>;
57 using Params =
typename odyn::ParamsTpl<Scalar>;
187 template <
typename NewScalar>
395 void updateStateAndControlIndex();
434 odyn::VerboseLevel verbose_level_;
435 std::vector<std::
size_t> xs_idx_;
436 std::vector<std::
size_t> us_idx_;
437 std::vector<VectorXs>
440 std::vector<VectorXs>
443 std::vector<VectorXs>
447 using SolverAbstract::acceptstep_;
450 using SolverAbstract::
cost_;
452 using SolverAbstract::
dfeas_;
453 using SolverAbstract::
dImpr_;
454 using SolverAbstract::
dPhi_;
456 using SolverAbstract::
dreg_;
457 using SolverAbstract::
dus_;
458 using SolverAbstract::
DV_;
459 using SolverAbstract::
dV_;
460 using SolverAbstract::
dVexp_;
462 using SolverAbstract::
dxs_;
463 using SolverAbstract::
feas_;
464 using SolverAbstract::feasnorm_;
465 using SolverAbstract::
ffeas_;
467 using SolverAbstract::
fs_;
469 using SolverAbstract::
gfeas_;
471 using SolverAbstract::
hfeas_;
474 using SolverAbstract::
iter_;
475 using SolverAbstract::
merit_;
476 using SolverAbstract::
ng_T_;
477 using SolverAbstract::
nh_T_;
478 using SolverAbstract::
preg_;
483 using SolverAbstract::
stop_;
485 using SolverAbstract::th_gaptol_;
487 using SolverAbstract::
us_;
489 using SolverAbstract::
xs_;
498#include "crocoddyl/core/solvers/odyn-sqp.hxx" Abstract class for solver callbacks.
This class encapsulates a shooting problem.
virtual void resizeData()
Scalar computeDynamicFeasibility()
SolverAbstractTpl(std::shared_ptr< ShootingProblem > problem)
Initialize the solver.
Scalar computeEqualityFeasibility()
Scalar computeInequalityFeasibility()
Scalar computeFeasibility(const std::vector< VectorXs > &fs)
Odyn-based Sequential Quadratic Programming (SQP) solver.
Scalar get_reg_incfactor() const
Return the regularization factor used to increase the damping value.
Scalar dV_
Reduction in the cost function computed by tryStep().
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.
void set_th_stepdec(const Scalar th_step)
Modify the step-length threshold used to decrease regularization.
void extractQpDirection(const VectorXs &x)
Extract the QP direction into the solver data structures.
virtual void computeDirection(const bool recalc=true) override
Compute the search direction for the current guess .
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_
std::vector< VectorXs > dxs_
Linear state direction (size T + 1).
void set_th_stepinc(const Scalar th_step)
Modify the step-length threshold used to increase regularization.
void set_th_acceptminstep(const Scalar th_acceptminstep)
Modify the threshold used for accepting minimum steps.
std::vector< VectorXs > fs_
Dynamics gaps in each node.
odyn::VerboseLevel get_verbose_level() const noexcept
Return the verbose level used in the OdynSQP solver.
virtual void computeCandidate(const Scalar step_length=Scalar(1.)) override
Compute new candidate solution using step length.
void set_th_minfeas(const Scalar th_minfeas)
Modify the threshold for switching to feasibility.
Scalar ffeas_
Feasibility of the dynamic constraints for the current guess.
std::size_t get_n() const noexcept
Return the number of decision variables in the SQP.
Scalar get_th_stepdec() const
Return the step-length threshold used to decrease regularization.
std::vector< VectorXs > Lxx_dx_
Scalar get_th_acceptminstep() const
Return the threshold used for accepting minimum steps.
Scalar stop_
Value computed by stoppingCriteria().
std::vector< VectorXs > us_try_
Control trajectory computed by line-search procedure.
bool is_feasible_
Label that indicates is the iteration is feasible.
std::shared_ptr< ShootingProblem > problem_
optimal control problem
Vector3s DV_
LQ approximation of the expected improvement.
void allocateData()
Allocate all the internal data needed for the solver.
Scalar dreg_
Current dual-variable regularization value.
Scalar get_upsilon() const
Return the estimated penalty parameter that balances relative contribution of the cost function and e...
Scalar preg_
Current primal-variable regularization value.
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...
Scalar dPhi_
Reduction in the merit function computed by tryStep().
void set_reg_decfactor(const Scalar reg_factor)
Modify the regularization factor used to decrease the damping value.
std::size_t get_m() const noexcept
Return the number of equality constraints in the SQP.
std::size_t nh_T_
Dimension of terminal equality constraints.
Scalar th_stepinc_
Step-length threshold used to increase regularization.
std::vector< VectorXs > fs_try_
bool increaseRegularizationCriteria() override
Criteria used to increase regularization.
virtual void computeMeritFunctionImprovement() override
Compute the merit function improvement for the current step.
Scalar steplength_
Current applied step length.
void set_upsilon_decfactor(const Scalar th_step)
Modify the upsilon decresing factor used to estimate to balance optimality and feasibility.
void set_th_minimprove(const Scalar th_step)
Modify the minimum improvement threshold used to increase regularization.
Scalar th_stepdec_
Step-length threshold used to decrease regularization.
void set_rho(const Scalar rho)
Modify the rho parameter used in the merit function.
std::size_t get_p() const noexcept
Return the number of inequality constraints in the SQP.
std::vector< std::shared_ptr< CallbackAbstract > > callbacks_
Callback functions.
Params & qp_params() noexcept
Return the QP params used in the OdynSQP solver.
Scalar get_upsilon_decfactor() const
Return the upsilon decresing factor used to estimate to balance optimality and feasibility.
Scalar th_acceptstep_
Threshold used for accepting step.
void set_verbose_level(const odyn::VerboseLevel verbose_level)
Modify the verbose level used in the OdynSQP solver.
std::vector< VectorXs > xs_
State trajectory.
void computeQuadraticModel()
Build the local Quadratic Program (QP) for the current iterate.
std::vector< VectorXs > us_
Control trajectory.
void set_zero_upsilon(const bool zero_upsilon)
Modify the zero-upsilon label.
std::size_t iter_
Number of iteration performed by the solver.
std::vector< VectorXs > Lxu_du_
Scalar get_th_stepinc() const
Return the step-length threshold used to increase regularization.
SolverOdynSQPTpl< NewScalar > cast() const
Cast the OdynSQP solver to a different scalar type.
bool decreaseRegularizationCriteria() override
Criteria used to decrease regularization.
void set_th_acceptnegstep(const Scalar th_acceptnegstep)
Modify the threshold used for accepting step along ascent direction.
Scalar feas_
Total feasibility for the current guess.
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.
std::vector< Scalar > alphas_
Set of step lengths using by the line-search procedure.
Data & qp_data() noexcept
Return the QP data used in the OdynSQP solver.
Scalar reg_min_
< Current control regularization values
Scalar cost_
Cost for the current guess.
std::vector< VectorXs > dus_
Linear control direction (size T).
bool get_zero_upsilon() const
Return the zero-upsilon label.
Scalar merit_
Merit for the current guess.
void set_qp_params(const Params ¶ms)
Modify the QP params used in the OdynSQP solver.
Scalar dfeas_
Reduction in the feasibility.
std::size_t ng_T_
Dimension of termianl inequality constraints.
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.
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.
virtual bool checkAcceptance() override
Check if we should accept or not the step.
SolverOdynSQPTpl(std::shared_ptr< ShootingProblem > problem)
Initialize the OdynSQP solver.
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.
Scalar th_minfeas_
Threshold for switching to feasibility.
Model & qp_model() noexcept
Return the QP model used in the OdynSQP solver.
Scalar get_reg_decfactor() const
Return the regularization factor used to decrease the damping value.
std::vector< VectorXs > xs_try_
State trajectory computed by line-search procedure.
std::vector< VectorXs > Luu_du_
Scalar th_stop_
Tolerance for stopping the algorithm.
Scalar cost_try_
Total cost computed by line-search procedure.
Scalar reg_max_
Maximum allowed regularization value.