Crocoddyl
Loading...
Searching...
No Matches
SolverOdynSQPTpl< _Scalar > Class Template Reference

Odyn-based Sequential Quadratic Programming (SQP) solver. More...

#include <odyn-sqp.hpp>

Inheritance diagram for SolverOdynSQPTpl< _Scalar >:
SolverAbstractTpl< _Scalar >SolverBase

Public Types

typedef ShootingProblem::ActionDataAbstract ActionDataAbstract
typedef ShootingProblem::ActionModelAbstract ActionModelAbstract
typedef CallbackAbstractTpl< Scalar > CallbackAbstract
using Data = typename odyn::SparseDataTpl<Scalar>
typedef MathBaseTpl< Scalar > MathBase
typedef MathBase::MatrixXs MatrixXs
typedef MathBase::MatrixXsRowMajor MatrixXsRowMajor
using Model = typename odyn::SparseModelTpl<Scalar>
using Params = typename odyn::ParamsTpl<Scalar>
typedef ShootingProblemTpl< Scalar > ShootingProblem
using Solver = typename odyn::SparseQPTpl<Scalar>
typedef SolverAbstractTpl< Scalar > SolverAbstract
typedef MathBase::Vector3s Vector3s
typedef MathBase::VectorXs VectorXs
Public Types inherited from SolverAbstractTpl< _Scalar >
typedef ShootingProblem::ActionDataAbstract ActionDataAbstract
typedef ShootingProblem::ActionModelAbstract ActionModelAbstract
typedef CallbackAbstractTpl< Scalar > CallbackAbstract
typedef MathBaseTpl< Scalar > MathBase
typedef ShootingProblemTpl< Scalar > ShootingProblem
typedef MathBase::Vector3s Vector3s
typedef MathBase::VectorXs VectorXs

Public Member Functions

 SolverOdynSQPTpl (std::shared_ptr< ShootingProblem > problem)
 Initialize the OdynSQP solver.
template<typename NewScalar>
SolverOdynSQPTpl< NewScalar > cast () const
 Cast the OdynSQP solver to a different scalar type.
virtual bool checkAcceptance () override
 Check if we should accept or not the step.
virtual void computeCandidate (const Scalar step_length=Scalar(1.)) override
 Compute new candidate solution using step length.
virtual void computeDirection (const bool recalc=true) override
 Compute the search direction $(\delta\mathbf{x}^k,\delta\mathbf{u}^k)$ for the current guess $(\mathbf{x}^k_s,\mathbf{u}^k_s)$.
Scalar computeDynamicFeasibility ()
 Compute the dynamic feasibility $\|\mathbf{f}_{\mathbf{s}}\|_{\infty,1}$ for the current guess $(\mathbf{x}^k,\mathbf{u}^k)$.
Scalar computeEqualityFeasibility ()
 Compute the feasibility of the equality constraints for the current guess.
virtual void computeExpectedMeritFunctionImprovement () override
 Compute the expected merit function improvement for the current step.
Scalar computeFeasibility (const std::vector< VectorXs > &fs)
 Compute the feasibility from a given residual vector.
Scalar computeInequalityFeasibility ()
 Compute the feasibility of the inequality constraints for the current guess.
virtual void computeMeritFunctionImprovement () override
 Compute the merit function improvement for the current step.
void computeQuadraticModel ()
 Build the local Quadratic Program (QP) for the current iterate.
void decreaseRegularization () override
 Decrease the state and control regularization values by a regfactor_ factor.
bool decreaseRegularizationCriteria () override
 Criteria used to decrease regularization.
virtual Vector3s expectedImprovement () override
 Return the expected improvement $dV_{exp}$ from a given current search direction $(\delta\mathbf{x}^k,\delta\mathbf{u}^k)$.
void extractQpDirection (const VectorXs &x)
 Extract the QP direction into the solver data structures.
std::size_t get_m () const noexcept
 Return the number of equality constraints in the SQP.
std::size_t get_n () const noexcept
 Return the number of decision variables in the SQP.
std::size_t get_p () const noexcept
 Return the number of inequality constraints in the SQP.
Scalar get_reg_decfactor () const
 Return the regularization factor used to decrease the damping value.
Scalar get_reg_incfactor () const
 Return the regularization factor used to increase the damping value.
Scalar get_rho () const
 Return the rho parameter used in the merit function.
Scalar get_th_acceptminstep () const
 Return the threshold used for accepting minimum steps.
Scalar get_th_acceptnegstep () const
 Return the threshold used for accepting step along ascent direction.
Scalar get_th_grad () const
 Return the tolerance of the expected gradient used for testing the step.
Scalar get_th_minfeas () const
 Return the threshold for switching to feasibility.
Scalar get_th_minimprove () const
 Return the minimum improvement threshold used to increase regularization.
Scalar get_th_stepdec () const
 Return the step-length threshold used to decrease regularization.
Scalar get_th_stepinc () const
 Return the step-length threshold used to increase regularization.
Scalar get_upsilon () const
 Return the estimated penalty parameter that balances relative contribution of the cost function and equality constraints.
Scalar get_upsilon_decfactor () const
 Return the upsilon decresing factor used to estimate to balance optimality and feasibility.
odyn::VerboseLevel get_verbose_level () const noexcept
 Return the verbose level used in the OdynSQP solver.
bool get_zero_upsilon () const
 Return the zero-upsilon label.
void increaseRegularization () override
 Increase the state and control regularization values by a regfactor_ factor.
bool increaseRegularizationCriteria () override
 Criteria used to increase regularization.
Data & qp_data () noexcept
 Return the QP data used in the OdynSQP solver.
Model & qp_model () noexcept
 Return the QP model used in the OdynSQP solver.
Params & qp_params () noexcept
 Return the QP params used in the OdynSQP solver.
virtual void resizeData ()
 Resizing the solver data.
void set_qp_params (const Params &params)
 Modify the QP params used in the OdynSQP solver.
void set_reg_decfactor (const Scalar reg_factor)
 Modify the regularization factor used to decrease the damping value.
void set_reg_incfactor (const Scalar reg_factor)
 Modify the regularization factor used to increase the damping value.
void set_rho (const Scalar rho)
 Modify the rho parameter used in the merit function.
void set_th_acceptminstep (const Scalar th_acceptminstep)
 Modify the threshold used for accepting minimum steps.
void set_th_acceptnegstep (const Scalar th_acceptnegstep)
 Modify the threshold used for accepting step along ascent direction.
void set_th_grad (const Scalar th_grad)
 Modify the tolerance of the expected gradient used for testing the step.
void set_th_minfeas (const Scalar th_minfeas)
 Modify the threshold for switching to feasibility.
void set_th_minimprove (const Scalar th_step)
 Modify the minimum improvement threshold used to increase regularization.
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 noimprovement object.
void set_th_stepdec (const Scalar th_step)
 Modify the step-length threshold used to decrease regularization.
void set_th_stepinc (const Scalar th_step)
 Modify the step-length threshold used to increase regularization.
void set_upsilon_decfactor (const Scalar th_step)
 Modify the upsilon decresing factor used to estimate to balance optimality and feasibility.
void set_verbose_level (const odyn::VerboseLevel verbose_level)
 Modify the verbose level used in the OdynSQP solver.
void set_zero_upsilon (const bool zero_upsilon)
 Modify the zero-upsilon label.
virtual Scalar stoppingCriteria () override
 Return a positive value that quantifies the algorithm termination.
void updateCandidate () override
 Update the candidate solution: cost, feasibilities, and merit value.
virtual void updateMeritFunction () override
 Update the merit function value for the current guess.
Public Member Functions inherited from SolverAbstractTpl< _Scalar >
 SolverAbstractTpl (std::shared_ptr< ShootingProblem > problem)
 Initialize the solver.
virtual void calcDir ()
 Refresh the linearization of the optimal control problem around the current candidate.
Scalar computeControlFeasibility (const std::vector< VectorXs > &us)
 Compute the control box-constraint feasibility from a given control trajectory.
Scalar computeDynamicFeasibility ()
 Compute the dynamic feasibility $\|\mathbf{f}_{\mathbf{s}}\|_{\infty,1}$ for the current guess $(\mathbf{x}^k,\mathbf{u}^k)$.
Scalar computeEqualityFeasibility ()
 Compute the feasibility of the equality constraints for the current guess.
Scalar computeFeasibility (const std::vector< VectorXs > &fs)
 Compute the feasibility from a given residual vector.
Scalar computeInequalityFeasibility ()
 Compute the feasibility of the inequality constraints for the current guess.
Scalar computeStateFeasibility (const std::vector< VectorXs > &xs)
 Compute the state box-constraint feasibility from a given state trajectory.
 DEPRECATED ("Do not use this threshold. It is not needed by our solvers", Scalar get_th_gaptol() const { return th_gaptol_;}) FeasibilityNorm get_feasnorm() const
 Return the threshold for accepting a gap as non-zero.
 DEPRECATED ("Do not use this threshold. It is not needed by our solvers", void set_th_gaptol(const Scalar th_gaptol);) void set_feasnorm(const FeasibilityNorm feas_norm)
 Modify the threshold for accepting a gap as non-zero.
 DEPRECATED ("Use get_preg for primal-variable regularization", Scalar get_xreg() const { return preg_;}) DEPRECATED("Use get_preg for primal-variable regularization"
 DEPRECATED ("Use set_preg for primal-variable regularization", void set_xreg(const Scalar xreg) { if(xreg< Scalar(0.)) { throw_pretty("Invalid argument: "<< "xreg value has to be positive.");} xreg_=xreg;preg_=xreg;}) DEPRECATED("Use set_preg for primal-variable regularization"
const std::vector< Scalar > & get_alphas () const
 Return the set of step lengths using by the line-search procedure.
Scalar get_cost () const
 Return the cost for the current guess.
Scalar get_dfeas () const
 Return the reduction in the feasibility.
Scalar get_dPhi () const
 Return the reduction in the merit function $\Delta\Phi$.
Scalar get_dPhiexp () const
 Return the expected reduction in the merit function $\Delta\Phi_{exp}$.
Scalar get_dreg () const
 Return the dual-variable regularization.
const std::vector< VectorXs > & get_dus () const
 Return the feedforward gains $\delta\mathbf{u}_s$.
const Vector3s & get_DV () const
 Return the constant, linear, and quadratic terms of the expected improvement.
Scalar get_dV () const
 Return the reduction in the cost function $\Delta V$.
Scalar get_dVexp () const
 Return the expected reduction in the cost function $\Delta
V_{exp}$.
const std::vector< VectorXs > & get_dxs () const
 Return the linear update in $\delta\mathbf{x}_s$.
Scalar get_feas () const
 Return the total feasibility for the current guess.
Scalar get_ffeas () const
 Return the dynamic feasibility for the current guess.
Scalar get_ffeas_try () const
 Return the dynamic feasibility for the current step length.
const std::vector< VectorXs > & get_fs () const
 Return the dynamic infeasibility $\mathbf{f}_{s}$.
const std::vector< VectorXs > & get_fs_try () const
 Return the trail dynamic infeasibility $\mathbf{f}_{s}$.
Scalar get_gfeas () const
 Return the inequality feasibility for the current guess.
Scalar get_gfeas_try () const
 Return the inequality feasibility for the current step length.
Scalar get_hfeas () const
 Return the equality feasibility for the current guess.
Scalar get_hfeas_try () const
 Return the equality feasibility for the current step length.
bool get_is_feasible () const
 Return the feasibility status of the $(\mathbf{x}_s,\mathbf{u}_s)$ trajectory.
std::size_t get_iter () const
 Return the number of iterations performed by the solver.
Scalar get_merit () const
 Return the merit for the current guess.
Scalar get_preg () const
 Return the primal-variable regularization.
const std::shared_ptr< ShootingProblem > & get_problem () const
 Return the shooting problem.
Scalar get_reg_max () const
 Return the maximum regularization value.
Scalar get_reg_min () const
 Return the minimum regularization value.
Scalar get_steplength () const
 Return the step length $\alpha$.
Scalar get_stop () const
 Return the stopping-criteria value computed by stoppingCriteria().
Scalar get_th_acceptstep () const
 Return the threshold used for accepting a step.
Scalar get_th_stop () const
 Return the tolerance for stopping the algorithm.
Scalar get_ureg () const
const std::vector< VectorXs > & get_us () const
 Return the control trajectory $\mathbf{u}_s$.
const std::vector< VectorXs > & get_us_try () const
 Return the trial control trajectory $\mathbf{u}_s$.
const std::vector< VectorXs > & get_xs () const
 Return the state trajectory $\mathbf{x}_s$.
const std::vector< VectorXs > & get_xs_try () const
 Return the trial state trajectory $\mathbf{x}_s$.
const std::vector< std::shared_ptr< CallbackAbstract > > & getCallbacks () const
 Return the list of callback functions using for diagnostic.
void set_alphas (const std::vector< Scalar > &alphas)
 Modify the set of step lengths using by the line-search procedure.
void set_dreg (const Scalar dreg)
 Modify the dual-variable regularization value.
void set_preg (const Scalar preg)
 Modify the primal-variable regularization value.
void set_reg_max (const Scalar regmax)
 Modify the maximum regularization value.
void set_reg_min (const Scalar regmin)
 Modify the minimum regularization value.
void set_th_acceptstep (const Scalar th_acceptstep)
 Modify the threshold used for accepting step.
void set_th_stop (const Scalar th_stop)
 Modify the tolerance for stopping the algorithm.
void set_ureg (const Scalar ureg)
void set_us (const std::vector< VectorXs > &us)
 Modify the control trajectory $\mathbf{u}_s$.
void set_xs (const std::vector< VectorXs > &xs)
 Modify the state trajectory $\mathbf{x}_s$.
void setCallbacks (const std::vector< std::shared_ptr< CallbackAbstract > > &callbacks)
 Set a list of callback functions using for the solver diagnostic.
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)
 Set the solver candidate trajectories $(\mathbf{x}_s,\mathbf{u}_s)$.
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 reg_init=std::numeric_limits< Scalar >::quiet_NaN())
 Compute the optimal trajectory $\mathbf{x}^*_s,\mathbf{u}^*_s$ as lists of $T+1$ and $T$ terms.
virtual Scalar tryStep (const Scalar steplength=Scalar(1.))
 Try a predefined step length $\alpha$ and compute its cost improvement $dV$ and merit improvement $d\Phi$.

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar
Public Attributes inherited from SolverAbstractTpl< _Scalar >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar

Protected Member Functions

void allocateData ()
 Allocate all the internal data needed for the solver.
virtual void resizeRunningData () override
 Resize data associated with the running models of the shooting problem.
virtual void resizeTerminalData () override
 Resize data associated with the terminal model of the shooting problem.
void updateStateAndControlIndex ()
Protected Member Functions inherited from SolverAbstractTpl< _Scalar >
void allocateData ()
 Allocate all the basic data needed in solvers.
 DEPRECATED ("Do not use this threshold. It is not needed by our solvers", Scalar th_gaptol_;) enum FeasibilityNorm feasnorm_
 DEPRECATED ("Use preg_ for primal-variable regularization", Scalar xreg_;) DEPRECATED("Use dreg_ for primal-variable regularization"

Protected Attributes

bool acceptstep_
std::vector< Scalar > alphas_
 Set of step lengths using by the line-search procedure.
std::vector< std::shared_ptr< CallbackAbstract > > callbacks_
 Callback functions.
Scalar cost_
 Cost for the current guess.
Scalar cost_try_
 Total cost computed by line-search procedure.
Scalar dfeas_
 Reduction in the feasibility.
Scalar dImpr_
Scalar dPhi_
 Reduction in the merit function computed by tryStep().
Scalar dPhiexp_
Scalar dreg_
 Current dual-variable regularization value.
std::vector< VectorXs > dus_
 Linear control direction (size T).
Vector3s DV_
 LQ approximation of the expected improvement.
Scalar dV_
 Reduction in the cost function computed by tryStep().
Scalar dVexp_
Scalar dVexp_full_
std::vector< VectorXs > dxs_
 Linear state direction (size T + 1).
Scalar feas_
 Total feasibility for the current guess.
Scalar ffeas_
 Feasibility of the dynamic constraints for the current guess.
Scalar ffeas_try_
std::vector< VectorXs > fs_
 Dynamics gaps in each node.
std::vector< VectorXs > fs_try_
Scalar gfeas_
Scalar gfeas_try_
Scalar hfeas_
Scalar hfeas_try_
bool is_feasible_
 Label that indicates is the iteration is feasible.
std::size_t iter_
 Number of iteration performed by the solver.
std::vector< VectorXs > Luu_du_
std::vector< VectorXs > Lxu_du_
std::vector< VectorXs > Lxx_dx_
std::size_t m_
Scalar merit_
 Merit for the current guess.
std::size_t n_
std::size_t ng_T_
 Dimension of termianl inequality constraints.
std::size_t nh_T_
 Dimension of terminal equality constraints.
std::size_t p_
Scalar preg_
 Current primal-variable regularization value.
std::shared_ptr< ShootingProblem > problem_
 optimal control problem
Data qp_data_
Model qp_model_
Params qp_params_
Solver qp_solver_
Scalar reg_decfactor_
Scalar reg_incfactor_
Scalar reg_max_
 Maximum allowed regularization value.
Scalar reg_min_
 < Current control regularization values
Scalar rho_
Scalar steplength_
 Current applied step length.
Scalar stop_
 Value computed by stoppingCriteria().
Scalar th_acceptminstep_
Scalar th_acceptnegstep_
Scalar th_acceptstep_
 Threshold used for accepting step.
Scalar th_grad_
Scalar th_minfeas_
 Threshold for switching to feasibility.
Scalar th_minimprove_
Scalar th_noimprovement_
Scalar th_stepdec_
 Step-length threshold used to decrease regularization.
Scalar th_stepinc_
 Step-length threshold used to increase regularization.
Scalar th_stop_
 Tolerance for stopping the algorithm.
Scalar upsilon_
Scalar upsilon_decfactor_
std::vector< VectorXs > us_
 Control trajectory.
std::vector< std::size_t > us_idx_
std::vector< VectorXs > us_try_
 Control trajectory computed by line-search procedure.
odyn::VerboseLevel verbose_level_
VectorXs x_
std::vector< VectorXs > xs_
 State trajectory.
std::vector< std::size_t > xs_idx_
std::vector< VectorXs > xs_try_
 State trajectory computed by line-search procedure.
bool zero_upsilon_
Protected Attributes inherited from SolverAbstractTpl< _Scalar >
bool acceptstep_
std::vector< Scalar > alphas_
 Set of step lengths using by the line-search procedure.
std::vector< std::shared_ptr< CallbackAbstract > > callbacks_
 Callback functions.
Scalar cost_
 Cost for the current guess.
Scalar cost_try_
 Total cost computed by line-search procedure.
Scalar dfeas_
 Reduction in the feasibility.
Scalar dImpr_
Scalar dPhi_
 Reduction in the merit function computed by tryStep().
Scalar dPhiexp_
Scalar dreg_
 Current dual-variable regularization value.
std::vector< VectorXs > dus_
 Linear control direction (size T).
Vector3s DV_
 LQ approximation of the expected improvement.
Scalar dV_
 Reduction in the cost function computed by tryStep().
Scalar dVexp_
Scalar dVexp_full_
std::vector< VectorXs > dxs_
 Linear state direction (size T + 1).
Scalar feas_
 Total feasibility for the current guess.
Scalar ffeas_
 Feasibility of the dynamic constraints for the current guess.
Scalar ffeas_try_
std::vector< VectorXs > fs_
 Dynamics gaps in each node.
std::vector< VectorXs > fs_try_
std::vector< VectorXs > g_adj_
 Adjusted inequality bound.
Scalar gfeas_
Scalar gfeas_try_
Scalar hfeas_
Scalar hfeas_try_
bool is_feasible_
 Label that indicates is the iteration is feasible.
std::size_t iter_
 Number of iteration performed by the solver.
Scalar merit_
 Merit for the current guess.
std::size_t ng_T_
 Dimension of termianl inequality constraints.
std::size_t nh_T_
 Dimension of terminal equality constraints.
Scalar preg_
 Current primal-variable regularization value.
std::shared_ptr< ShootingProblem > problem_
 optimal control problem
bool recalcdir_
Scalar reg_max_
 Maximum allowed regularization value.
Scalar reg_min_
 < Current control regularization values
Scalar steplength_
 Current applied step length.
Scalar stop_
 Value computed by stoppingCriteria().
Scalar th_acceptstep_
 Threshold used for accepting step.
Scalar th_stop_
 Tolerance for stopping the algorithm.
Scalar tmp_feas_
 Temporal variables used for computed the feasibility.
std::vector< VectorXs > u_adj_
 Adjusted control bound.
Scalar ureg_
std::vector< VectorXs > us_
 Control trajectory.
std::vector< VectorXs > us_try_
 Control trajectory computed by line-search procedure.
bool was_feasible_
std::vector< VectorXs > x_adj_
 Adjusted state bound.
std::vector< VectorXs > xs_
 State trajectory.
std::vector< VectorXs > xs_try_
 State trajectory computed by line-search procedure.

Detailed Description

template<typename _Scalar>
class crocoddyl::SolverOdynSQPTpl< _Scalar >

Odyn-based Sequential Quadratic Programming (SQP) solver.

This solver wraps Odyn’s sparse QP engine to solve Crocoddyl shooting problems with equality and inequality constraints. At each iteration it builds a sparse QP in computeQuadraticModel(), solves it with Odyn, and then maps the QP step back to state/control updates in computeSearchDirection() / tryStep(). The try step supports infeasible iterates (open dynamics gaps) and line-searches them, which improves globalization on hard-constrained problems. The expected improvement calculation also accounts for the dynamics gaps.

See SolverAbstract(), computeSearchDirection(), tryStep(), and expectedImprovement() for the main iteration steps.

Definition at line 38 of file odyn-sqp.hpp.

Member Typedef Documentation

◆ SolverAbstract

template<typename _Scalar>
typedef SolverAbstractTpl<Scalar> SolverAbstract

Definition at line 44 of file odyn-sqp.hpp.

◆ ShootingProblem

template<typename _Scalar>
typedef ShootingProblemTpl<Scalar> ShootingProblem

Definition at line 45 of file odyn-sqp.hpp.

◆ ActionModelAbstract

template<typename _Scalar>
typedef ShootingProblem::ActionModelAbstract ActionModelAbstract

Definition at line 46 of file odyn-sqp.hpp.

◆ ActionDataAbstract

template<typename _Scalar>
typedef ShootingProblem::ActionDataAbstract ActionDataAbstract

Definition at line 47 of file odyn-sqp.hpp.

◆ CallbackAbstract

template<typename _Scalar>
typedef CallbackAbstractTpl<Scalar> CallbackAbstract

Definition at line 48 of file odyn-sqp.hpp.

◆ MathBase

template<typename _Scalar>
typedef MathBaseTpl<Scalar> MathBase

Definition at line 49 of file odyn-sqp.hpp.

◆ VectorXs

template<typename _Scalar>
typedef MathBase::VectorXs VectorXs

Definition at line 50 of file odyn-sqp.hpp.

◆ Vector3s

template<typename _Scalar>
typedef MathBase::Vector3s Vector3s

Definition at line 51 of file odyn-sqp.hpp.

◆ MatrixXs

template<typename _Scalar>
typedef MathBase::MatrixXs MatrixXs

Definition at line 52 of file odyn-sqp.hpp.

◆ MatrixXsRowMajor

template<typename _Scalar>
typedef MathBase::MatrixXsRowMajor MatrixXsRowMajor

Definition at line 53 of file odyn-sqp.hpp.

◆ Solver

template<typename _Scalar>
using Solver = typename odyn::SparseQPTpl<Scalar>

Definition at line 54 of file odyn-sqp.hpp.

◆ Model

template<typename _Scalar>
using Model = typename odyn::SparseModelTpl<Scalar>

Definition at line 55 of file odyn-sqp.hpp.

◆ Data

template<typename _Scalar>
using Data = typename odyn::SparseDataTpl<Scalar>

Definition at line 56 of file odyn-sqp.hpp.

◆ Params

template<typename _Scalar>
using Params = typename odyn::ParamsTpl<Scalar>

Definition at line 57 of file odyn-sqp.hpp.

Constructor & Destructor Documentation

◆ SolverOdynSQPTpl()

template<typename _Scalar>
SolverOdynSQPTpl(std::shared_ptr< ShootingProblem >problem)
explicit

Initialize the OdynSQP solver.

Parameters
[in]problemShooting problem
[in]dyn_solverType of dynamic solver
[in]term_solverType of terminal solver

Member Function Documentation

◆ computeDirection()

template<typename _Scalar>
virtual void computeDirection(const boolrecalc = true)
overridevirtual

Compute the search direction $(\delta\mathbf{x}^k,\delta\mathbf{u}^k)$ for the current guess $(\mathbf{x}^k_s,\mathbf{u}^k_s)$.

Implements SolverAbstractTpl< _Scalar >.

◆ stoppingCriteria()

template<typename _Scalar>
virtual Scalar stoppingCriteria()
overridevirtual

Return a positive value that quantifies the algorithm termination.

Implements SolverAbstractTpl< _Scalar >.

◆ expectedImprovement()

template<typename _Scalar>
virtual Vector3s expectedImprovement()
overridevirtual

Return the expected improvement $dV_{exp}$ from a given current search direction $(\delta\mathbf{x}^k,\delta\mathbf{u}^k)$.

Implements SolverAbstractTpl< _Scalar >.

◆ computeMeritFunctionImprovement()

template<typename _Scalar>
virtual void computeMeritFunctionImprovement()
overridevirtual

Compute the merit function improvement for the current step.

Reimplemented from SolverAbstractTpl< _Scalar >.

◆ computeExpectedMeritFunctionImprovement()

template<typename _Scalar>
virtual void computeExpectedMeritFunctionImprovement()
overridevirtual

Compute the expected merit function improvement for the current step.

Reimplemented from SolverAbstractTpl< _Scalar >.

◆ updateMeritFunction()

template<typename _Scalar>
virtual void updateMeritFunction()
overridevirtual

Update the merit function value for the current guess.

Reimplemented from SolverAbstractTpl< _Scalar >.

◆ checkAcceptance()

template<typename _Scalar>
virtual bool checkAcceptance()
overridevirtual

Check if we should accept or not the step.

Returns
True if we should accept the step. False otherwise

Reimplemented from SolverAbstractTpl< _Scalar >.

◆ computeCandidate()

template<typename _Scalar>
virtual void computeCandidate(const Scalarstep_length = Scalar(1.))
overridevirtual

Compute new candidate solution using step length.

Reimplemented from SolverAbstractTpl< _Scalar >.

◆ computeQuadraticModel()

template<typename _Scalar>
void computeQuadraticModel()

Build the local Quadratic Program (QP) for the current iterate.

The QP has the form

\‍[  \min_{x}\ \tfrac{1}{2}\, x^\top Q\, x \;+\; c^\top x
  \quad\text{s.t.}\quad
  A\,x = b,\;\; G\,x \le h .
\‍]

Here, x is the full decision vector over the trajectory and controls, and Q, c, A, b, G, h are the corresponding (sparse, structured) cost and constraint matrices/vectors induced by the problem’s temporal layout.

Decision vector ordering:

\‍[  x = [\, \Delta x_0,\ \Delta u_0,\ \Delta x_1,\ \Delta
u_1,\ \ldots,\ \Delta x_T \,].
\‍]

The sparsity pattern reflects time-coupling (dynamics and local costs/constraints).

Template Parameters
ScalarScalar type (e.g., float, double).

◆ updateCandidate()

template<typename _Scalar>
void updateCandidate()
overridevirtual

Update the candidate solution: cost, feasibilities, and merit value.

Reimplemented from SolverAbstractTpl< _Scalar >.

◆ decreaseRegularizationCriteria()

template<typename _Scalar>
bool decreaseRegularizationCriteria()
overridevirtual

Criteria used to decrease regularization.

Reimplemented from SolverAbstractTpl< _Scalar >.

◆ increaseRegularizationCriteria()

template<typename _Scalar>
bool increaseRegularizationCriteria()
overridevirtual

Criteria used to increase regularization.

Reimplemented from SolverAbstractTpl< _Scalar >.

◆ increaseRegularization()

template<typename _Scalar>
void increaseRegularization()
overridevirtual

Increase the state and control regularization values by a regfactor_ factor.

Reimplemented from SolverAbstractTpl< _Scalar >.

◆ decreaseRegularization()

template<typename _Scalar>
void decreaseRegularization()
overridevirtual

Decrease the state and control regularization values by a regfactor_ factor.

Reimplemented from SolverAbstractTpl< _Scalar >.

◆ extractQpDirection()

template<typename _Scalar>
void extractQpDirection(const VectorXs &x)

Extract the QP direction into the solver data structures.

Parameters
[in]xdecision vector from the QP solver

◆ cast()

template<typename _Scalar>
template<typename NewScalar>
SolverOdynSQPTpl< NewScalar > cast()const

Cast the OdynSQP solver to a different scalar type.

It is useful for operations requiring different precision or scalar types.

Template Parameters
NewScalarThe new scalar type to cast to.
Returns
SolverOdynSQPTpl<NewScalar> A OdynSQP solver with the new scalar type.

◆ get_zero_upsilon()

template<typename _Scalar>
bool get_zero_upsilon()const

Return the zero-upsilon label.

True if we set the estimated penalty parameter (upsilon) to zero when solve is called.

◆ set_zero_upsilon()

template<typename _Scalar>
void set_zero_upsilon(const boolzero_upsilon)

Modify the zero-upsilon label.

Parameters
zero_upsilonTrue if we set estimated penalty parameter (upsilon) to zero when solve is called.

◆ resizeRunningData()

template<typename _Scalar>
virtual void resizeRunningData()
overrideprotectedvirtual

Resize data associated with the running models of the shooting problem.

Reimplemented from SolverAbstractTpl< _Scalar >.

◆ resizeTerminalData()

template<typename _Scalar>
virtual void resizeTerminalData()
overrideprotectedvirtual

Resize data associated with the terminal model of the shooting problem.

Reimplemented from SolverAbstractTpl< _Scalar >.

◆ computeDynamicFeasibility()

template<typename _Scalar>
Scalar computeDynamicFeasibility()

Compute the dynamic feasibility $\|\mathbf{f}_{\mathbf{s}}\|_{\infty,1}$ for the current guess $(\mathbf{x}^k,\mathbf{u}^k)$.

The feasibility can be computed using different norms (e.g, $\ell_\infty$ or $\ell_1$ norms). By default we use the $\ell_\infty$ norm, however, we can change the type of norm using set_feasnorm. Note that $\mathbf{f}_{\mathbf{s}}$ are the gaps on the dynamics, which are computed at each node as $\mathbf{x}^{'}-\mathbf{f}(\mathbf{x},\mathbf{u})$.

◆ computeEqualityFeasibility()

template<typename _Scalar>
Scalar computeEqualityFeasibility()

Compute the feasibility of the equality constraints for the current guess.

The feasibility can be computed using different norms (e.g, $\ell_\infty$ or $\ell_1$ norms). By default we use the $\ell_\infty$ norm, however, we can change the type of norm using set_feasnorm.

◆ computeFeasibility()

template<typename _Scalar>
Scalar computeFeasibility(const std::vector< VectorXs > &fs)

Compute the feasibility from a given residual vector.

As in the computeDynamicFeasibility, computeInequalityFeasibility or computeEqualityFeasibility, we can compute the feasibility using different norms (e.g, $\ell_\infty$ or $\ell_1$ norms). By default we use the $\ell_\infty$ norm, however, we can change the type of norm using set_feasnorm.

Parameters
[in]fsVector of residual vectors which we wish to compute the feasibility
Returns
the residuals' feasibility

◆ computeInequalityFeasibility()

template<typename _Scalar>
Scalar computeInequalityFeasibility()

Compute the feasibility of the inequality constraints for the current guess.

The feasibility can be computed using different norms (e.g, $\ell_\infty$ or $\ell_1$ norms). By default we use the $\ell_\infty$ norm, however, we can change the type of norm using set_feasnorm.

◆ resizeData()

template<typename _Scalar>
virtual void resizeData()
virtual

Resizing the solver data.

If the shooting problem has changed after construction, then this function resizes all the data before starting resolve the problem.

Reimplemented from SolverAbstractTpl< _Scalar >.

Member Data Documentation

◆ Scalar

template<typename _Scalar>
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar

Definition at line 43 of file odyn-sqp.hpp.

◆ reg_incfactor_

template<typename _Scalar>
Scalar reg_incfactor_
protected

Regularization factor used to increase the damping value

Definition at line 397 of file odyn-sqp.hpp.

◆ reg_decfactor_

template<typename _Scalar>
Scalar reg_decfactor_
protected

Regularization factor used to decrease the damping value

Definition at line 399 of file odyn-sqp.hpp.

◆ th_grad_

template<typename _Scalar>
Scalar th_grad_
protected

Tolerance of the expected gradient used for testing the step

Definition at line 401 of file odyn-sqp.hpp.

◆ th_noimprovement_

template<typename _Scalar>
Scalar th_noimprovement_
protected

Threshold used to accept steps that cannot be be improved due to numerical errors

Definition at line 403 of file odyn-sqp.hpp.

◆ th_stepdec_

template<typename _Scalar>
Scalar th_stepdec_
protected

Step-length threshold used to decrease regularization.

Definition at line 406 of file odyn-sqp.hpp.

◆ th_stepinc_

template<typename _Scalar>
Scalar th_stepinc_
protected

Step-length threshold used to increase regularization.

Definition at line 408 of file odyn-sqp.hpp.

◆ th_minimprove_

template<typename _Scalar>
Scalar th_minimprove_
protected

Minimum improvement threshold used in the regularization scheme

Definition at line 409 of file odyn-sqp.hpp.

◆ th_acceptnegstep_

template<typename _Scalar>
Scalar th_acceptnegstep_
protected

Threshold used for accepting step along ascent direction

Definition at line 411 of file odyn-sqp.hpp.

◆ th_acceptminstep_

template<typename _Scalar>
Scalar th_acceptminstep_
protected

Threshold used for accepting step along with a minimum length

Definition at line 413 of file odyn-sqp.hpp.

◆ rho_

template<typename _Scalar>
Scalar rho_
protected

Parameter used in the merit function to predict the expected reduction

Definition at line 415 of file odyn-sqp.hpp.

◆ th_minfeas_

template<typename _Scalar>
Scalar th_minfeas_
protected

Threshold for switching to feasibility.

Definition at line 417 of file odyn-sqp.hpp.

◆ upsilon_

template<typename _Scalar>
Scalar upsilon_
protected

Estimated penalty parameter that balances relative contribution of the cost function and equality constraints

Definition at line 419 of file odyn-sqp.hpp.

◆ upsilon_decfactor_

template<typename _Scalar>
Scalar upsilon_decfactor_
protected

Estimated penalty parameter factor used to decrease its value

Definition at line 421 of file odyn-sqp.hpp.

◆ zero_upsilon_

template<typename _Scalar>
bool zero_upsilon_
protected

True if we wish to set estimated penalty parameter (upsilon) to zero when solve is called.

Definition at line 423 of file odyn-sqp.hpp.

◆ n_

template<typename _Scalar>
std::size_t n_
protected

Definition at line 426 of file odyn-sqp.hpp.

◆ m_

template<typename _Scalar>
std::size_t m_
protected

Definition at line 427 of file odyn-sqp.hpp.

◆ p_

template<typename _Scalar>
std::size_t p_
protected

Definition at line 428 of file odyn-sqp.hpp.

◆ x_

template<typename _Scalar>
VectorXs x_
protected

Definition at line 429 of file odyn-sqp.hpp.

◆ qp_solver_

template<typename _Scalar>
Solver qp_solver_
protected

Definition at line 430 of file odyn-sqp.hpp.

◆ qp_model_

template<typename _Scalar>
Model qp_model_
protected

Definition at line 431 of file odyn-sqp.hpp.

◆ qp_data_

template<typename _Scalar>
Data qp_data_
protected

Definition at line 432 of file odyn-sqp.hpp.

◆ qp_params_

template<typename _Scalar>
Params qp_params_
protected

Definition at line 433 of file odyn-sqp.hpp.

◆ verbose_level_

template<typename _Scalar>
odyn::VerboseLevel verbose_level_
protected

Definition at line 434 of file odyn-sqp.hpp.

◆ xs_idx_

template<typename _Scalar>
std::vector<std::size_t> xs_idx_
protected

Definition at line 435 of file odyn-sqp.hpp.

◆ us_idx_

template<typename _Scalar>
std::vector<std::size_t> us_idx_
protected

Definition at line 436 of file odyn-sqp.hpp.

◆ Lxx_dx_

template<typename _Scalar>
std::vector<VectorXs> Lxx_dx_
protected

Second-order change of the cost function $\boldsymbol{\ell}_{\mathbf{{xx}}}\delta\mathbf{x}$

Definition at line 438 of file odyn-sqp.hpp.

◆ Luu_du_

template<typename _Scalar>
std::vector<VectorXs> Luu_du_
protected

Second-order change of the cost function $\boldsymbol{\ell}_{\mathbf{{uu}}}\delta\mathbf{u}$

Definition at line 441 of file odyn-sqp.hpp.

◆ Lxu_du_

template<typename _Scalar>
std::vector<VectorXs> Lxu_du_
protected

Second-order change of the cost function $\boldsymbol{\ell}_{\mathbf{{xu}}}\delta\mathbf{u}$

Definition at line 444 of file odyn-sqp.hpp.

◆ acceptstep_

template<typename _Scalar>
bool acceptstep_
protected

Definition at line 771 of file solver-base.hpp.

◆ alphas_

template<typename _Scalar>
std::vector<Scalar> alphas_
protected

Set of step lengths using by the line-search procedure.

Definition at line 702 of file solver-base.hpp.

◆ callbacks_

template<typename _Scalar>
std::vector<std::shared_ptr<CallbackAbstract> > callbacks_
protected

Callback functions.

Definition at line 700 of file solver-base.hpp.

◆ cost_

template<typename _Scalar>
Scalar cost_
protected

Cost for the current guess.

Definition at line 727 of file solver-base.hpp.

◆ cost_try_

template<typename _Scalar>
Scalar cost_try_
protected

Total cost computed by line-search procedure.

Definition at line 728 of file solver-base.hpp.

◆ dfeas_

template<typename _Scalar>
Scalar dfeas_
protected

Reduction in the feasibility.

Definition at line 741 of file solver-base.hpp.

◆ dImpr_

template<typename _Scalar>
Scalar dImpr_
protected

Reduction in the iteration improvement (i.e., maximum between cost and merit values)

Definition at line 711 of file solver-base.hpp.

◆ dPhi_

template<typename _Scalar>
Scalar dPhi_
protected

Reduction in the merit function computed by tryStep().

Definition at line 734 of file solver-base.hpp.

◆ dPhiexp_

template<typename _Scalar>
Scalar dPhiexp_
protected

Expected reduction in the merit function for the selected step length

Definition at line 739 of file solver-base.hpp.

◆ dreg_

template<typename _Scalar>
Scalar dreg_
protected

Current dual-variable regularization value.

Definition at line 757 of file solver-base.hpp.

◆ dus_

template<typename _Scalar>
std::vector<VectorXs> dus_
protected

Linear control direction (size T).

Definition at line 723 of file solver-base.hpp.

◆ DV_

template<typename _Scalar>
Vector3s DV_
protected

LQ approximation of the expected improvement.

Definition at line 732 of file solver-base.hpp.

◆ dV_

template<typename _Scalar>
Scalar dV_
protected

Reduction in the cost function computed by tryStep().

Definition at line 733 of file solver-base.hpp.

◆ dVexp_

template<typename _Scalar>
Scalar dVexp_
protected

Expected reduction in the cost function for the selected step length

Definition at line 737 of file solver-base.hpp.

◆ dVexp_full_

template<typename _Scalar>
Scalar dVexp_full_
protected

Expected reduction in the cost function for a full step length

Definition at line 735 of file solver-base.hpp.

◆ dxs_

template<typename _Scalar>
std::vector<VectorXs> dxs_
protected

Linear state direction (size T + 1).

Definition at line 722 of file solver-base.hpp.

◆ feas_

template<typename _Scalar>
Scalar feas_
protected

Total feasibility for the current guess.

Definition at line 742 of file solver-base.hpp.

◆ ffeas_

template<typename _Scalar>
Scalar ffeas_
protected

Feasibility of the dynamic constraints for the current guess.

Definition at line 744 of file solver-base.hpp.

◆ ffeas_try_

template<typename _Scalar>
Scalar ffeas_try_
protected

Feasibility of the dynamic constraints evaluated for the current step length

Definition at line 749 of file solver-base.hpp.

◆ fs_

template<typename _Scalar>
std::vector<VectorXs> fs_
protected

Dynamics gaps in each node.

Definition at line 715 of file solver-base.hpp.

◆ fs_try_

template<typename _Scalar>
std::vector<VectorXs> fs_try_
protected

Dynamics gaps in each node computed by the line-search procedure

Definition at line 720 of file solver-base.hpp.

◆ gfeas_

template<typename _Scalar>
Scalar gfeas_
protected

Feasibility of the inequality constraints for the current guess

Definition at line 745 of file solver-base.hpp.

◆ gfeas_try_

template<typename _Scalar>
Scalar gfeas_try_
protected

Feasibility of the inequality constraints evaluated for the current step length

Definition at line 751 of file solver-base.hpp.

◆ hfeas_

template<typename _Scalar>
Scalar hfeas_
protected

Feasibility of the equality constraints for the current guess

Definition at line 747 of file solver-base.hpp.

◆ hfeas_try_

template<typename _Scalar>
Scalar hfeas_try_
protected

Feasibility of the equality constraints evaluated for the current step length

Definition at line 753 of file solver-base.hpp.

◆ is_feasible_

template<typename _Scalar>
bool is_feasible_
protected

Label that indicates is the iteration is feasible.

Definition at line 724 of file solver-base.hpp.

◆ iter_

template<typename _Scalar>
std::size_t iter_
protected

Number of iteration performed by the solver.

Definition at line 731 of file solver-base.hpp.

◆ merit_

template<typename _Scalar>
Scalar merit_
protected

Merit for the current guess.

Definition at line 729 of file solver-base.hpp.

◆ ng_T_

template<typename _Scalar>
std::size_t ng_T_
protected

Dimension of termianl inequality constraints.

Definition at line 769 of file solver-base.hpp.

◆ nh_T_

template<typename _Scalar>
std::size_t nh_T_
protected

Dimension of terminal equality constraints.

Definition at line 768 of file solver-base.hpp.

◆ preg_

template<typename _Scalar>
Scalar preg_
protected

Current primal-variable regularization value.

Definition at line 756 of file solver-base.hpp.

◆ problem_

template<typename _Scalar>
std::shared_ptr<ShootingProblem> problem_
protected

optimal control problem

Definition at line 698 of file solver-base.hpp.

◆ reg_max_

template<typename _Scalar>
Scalar reg_max_
protected

Maximum allowed regularization value.

Definition at line 763 of file solver-base.hpp.

◆ reg_min_

template<typename _Scalar>
Scalar reg_min_
protected

< Current control regularization values

Minimum allowed regularization value

Definition at line 762 of file solver-base.hpp.

◆ steplength_

template<typename _Scalar>
Scalar steplength_
protected

Current applied step length.

Definition at line 764 of file solver-base.hpp.

◆ stop_

template<typename _Scalar>
Scalar stop_
protected

Value computed by stoppingCriteria().

Definition at line 730 of file solver-base.hpp.

◆ th_acceptstep_

template<typename _Scalar>
Scalar th_acceptstep_
protected

Threshold used for accepting step.

Definition at line 703 of file solver-base.hpp.

◆ th_stop_

template<typename _Scalar>
Scalar th_stop_
protected

Tolerance for stopping the algorithm.

Definition at line 704 of file solver-base.hpp.

◆ us_

template<typename _Scalar>
std::vector<VectorXs> us_
protected

Control trajectory.

Definition at line 714 of file solver-base.hpp.

◆ us_try_

template<typename _Scalar>
std::vector<VectorXs> us_try_
protected

Control trajectory computed by line-search procedure.

Definition at line 719 of file solver-base.hpp.

◆ xs_

template<typename _Scalar>
std::vector<VectorXs> xs_
protected

State trajectory.

Definition at line 713 of file solver-base.hpp.

◆ xs_try_

template<typename _Scalar>
std::vector<VectorXs> xs_try_
protected

State trajectory computed by line-search procedure.

Definition at line 717 of file solver-base.hpp.


The documentation for this class was generated from the following file: