Crocoddyl
Loading...
Searching...
No Matches
SolverAbstractTpl< _Scalar > Class Template Referenceabstract

Abstract class for optimal control solvers. More...

#include <solver-base.hpp>

Inheritance diagram for SolverAbstractTpl< _Scalar >:
SolverBaseSolverFDDPTpl< _Scalar >SolverKKTTpl< _Scalar >SolverOdynSQPTpl< _Scalar >SolverBoxFDDPTpl< _Scalar >SolverIntroTpl< _Scalar >

Public Types

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

 SolverAbstractTpl (std::shared_ptr< ShootingProblem > problem)
 Initialize the solver.
virtual void calcDir ()
 Refresh the linearization of the optimal control problem around the current candidate.
virtual bool checkAcceptance ()
 Check if we should accept or not the step.
virtual void computeCandidate (const Scalar steplength=Scalar(1.))
 Compute new candidate solution using step length.
Scalar computeControlFeasibility (const std::vector< VectorXs > &us)
 Compute the control box-constraint feasibility from a given control trajectory.
virtual void computeDirection (const bool recalc)=0
 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 ()
 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 ()
 Compute the merit function improvement for the current step.
Scalar computeStateFeasibility (const std::vector< VectorXs > &xs)
 Compute the state box-constraint feasibility from a given state trajectory.
virtual void decreaseRegularization ()
 Decrease the state and control regularization values by a regfactor_ factor.
virtual bool decreaseRegularizationCriteria ()
 Criteria used to decrease regularization.
 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"
virtual Vector3s expectedImprovement ()=0
 Return the expected improvement $dV_{exp}$ from a given current search direction $(\delta\mathbf{x}^k,\delta\mathbf{u}^k)$.
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.
virtual void increaseRegularization ()
 Increase the state and control regularization values by a regfactor_ factor.
virtual bool increaseRegularizationCriteria ()
 Criteria used to increase regularization.
virtual void resizeData ()
 Resizing the solver data.
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 stoppingCriteria ()=0
 Return a positive value that quantifies the algorithm termination.
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$.
virtual void updateCandidate ()
 Update the candidate solution: cost, feasibilities, and merit value.
virtual void updateMeritFunction ()
 Update the merit function value for the current guess.

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar

Protected Member Functions

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"
virtual void resizeRunningData ()
 Resize data associated with the running models of the shooting problem.
virtual void resizeTerminalData ()
 Resize data associated with the terminal model of the shooting problem.

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_
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::SolverAbstractTpl< _Scalar >

Abstract class for optimal control solvers.

A solver resolves an optimal control solver of the form

\begin{eqnarray*}\begin{Bmatrix}
    \mathbf{x}^*_0,\cdots,\mathbf{x}^*_{T} \\
    \mathbf{u}^*_0,\cdots,\mathbf{u}^*_{T-1}
\end{Bmatrix} =
\arg\min_{\mathbf{x}_s,\mathbf{u}_s} && l_T (\mathbf{x}_T) + \sum_{k=0}^{T-1}
l_k(\mathbf{x}_t,\mathbf{u}_t) \\
\operatorname{subject}\,\operatorname{to} && \mathbf{x}_0 =
\mathbf{\tilde{x}}_0\\
&&  \mathbf{x}_{k+1} = \mathbf{f}_k(\mathbf{x}_k,\mathbf{u}_k)\\
&&  \mathbf{x}_k\in\mathcal{X}, \mathbf{u}_k\in\mathcal{U}
\end{eqnarray*}

where $l_T(\mathbf{x}_T)$, $l_k(\mathbf{x}_t,\mathbf{u}_t)$ are the terminal and running cost functions, respectively, $\mathbf{f}_k(\mathbf{x}_k,\mathbf{u}_k)$ describes evolution of the system, and state and control admissible sets are defined by $\mathbf{x}_k\in\mathcal{X}$, $\mathbf{u}_k\in\mathcal{U}$. An action model, defined in the shooting problem, describes each node $k$. Inside the action model, we specialize the cost functions, the system evolution and the admissible sets.

The main routines are computeDirection() and tryStep(). The former finds a search direction and typically computes the derivatives of each action model. The latter rollout the dynamics and cost (i.e., the action) to try the search direction found by computeDirection. Both functions used the current guess defined by setCandidate(). Finally, solve() function is used to define when the search direction and length are computed in each iterate. It also describes the globalization strategy (i.e., regularization) of the numerical optimization.

See also
solve(), computeDirection(), tryStep(), stoppingCriteria()

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

Member Typedef Documentation

◆ ShootingProblem

template<typename _Scalar>
typedef ShootingProblemTpl<Scalar> ShootingProblem

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

◆ ActionModelAbstract

template<typename _Scalar>
typedef ShootingProblem::ActionModelAbstract ActionModelAbstract

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

◆ ActionDataAbstract

template<typename _Scalar>
typedef ShootingProblem::ActionDataAbstract ActionDataAbstract

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

◆ CallbackAbstract

template<typename _Scalar>
typedef CallbackAbstractTpl<Scalar> CallbackAbstract

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

◆ MathBase

template<typename _Scalar>
typedef MathBaseTpl<Scalar> MathBase

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

◆ VectorXs

template<typename _Scalar>
typedef MathBase::VectorXs VectorXs

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

◆ Vector3s

template<typename _Scalar>
typedef MathBase::Vector3s Vector3s

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

Constructor & Destructor Documentation

◆ SolverAbstractTpl()

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

Initialize the solver.

Parameters
[in]problemshooting problem

Member Function Documentation

◆ solve()

template<typename _Scalar>
virtual bool solve(const std::vector< VectorXs > &init_xs = DefaultVector< Scalar >::value,
const std::vector< VectorXs > &init_us = DefaultVector< Scalar >::value,
const std::size_tmaxiter = 100,
const boolis_feasible = false,
const Scalarreg_init = std::numeric_limits< Scalar >::quiet_NaN() )
virtual

Compute the optimal trajectory $\mathbf{x}^*_s,\mathbf{u}^*_s$ as lists of $T+1$ and $T$ terms.

From an initial guess init_xs, init_us (feasible or not), iterate over computeDirection() and tryStep() until stoppingCriteria() is below threshold. It also describes the globalization strategy used during the numerical optimization.

Parameters
[in]init_xsinitial guess for state trajectory with $T+1$ elements (default [])
[in]init_usinitial guess for control trajectory with $T$ elements (default [])
[in]maxitermaximum allowed number of iterations (default 100)
[in]is_feasibletrue if the init_xs are obtained from integrating the init_us (rollout) (default false)
[in]init_reginitial guess for the regularization value. Very low values are typical used with very good guess points (default 1e-9).
Returns
A boolean that describes if convergence was reached.

Reimplemented in SolverKKTTpl< _Scalar >, and SolverKKTTpl< double >.

◆ computeDirection()

template<typename _Scalar>
virtual void computeDirection(const boolrecalc)
pure virtual

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

You must call setCandidate() first in order to define the current guess. A current guess defines a state and control trajectory $(\mathbf{x}^k_s,\mathbf{u}^k_s)$ of $T+1$ and $T$ elements, respectively. When recalc is true (the default in the provided algorithms), the method refreshes the linearization by calling calcDir() before running the backward pass. Setting recalc to false reuses the most recent derivatives, which is useful when calcDir() has already been triggered explicitly. The resulting state and control variations, together with the dynamics multipliers, are stored in the solver data structures (e.g., dxs_, dus_, and lambdas_).

Parameters
[in]recalctrue to refresh the derivatives before computing the search direction

Implemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, SolverIntroTpl< _Scalar >, SolverIntroTpl< double >, SolverKKTTpl< _Scalar >, SolverKKTTpl< double >, and SolverOdynSQPTpl< _Scalar >.

◆ tryStep()

template<typename _Scalar>
virtual Scalar tryStep(const Scalarsteplength = Scalar(1.))
virtual

Try a predefined step length $\alpha$ and compute its cost improvement $dV$ and merit improvement $d\Phi$.

It uses the search direction found by computeDirection() to try a determined step length $\alpha$. Therefore, it assumes that we have run computeDirection() first. Additionally, it returns the cost improvement $dV$ along the predefined step length $\alpha$. Internally, it updates the cost improvement $dV$ and merit improvement $d\Phi$.

Parameters
[in]steplengthapplied step length ( $0\leq\alpha\leq1$, with 1 as default)
Returns
the cost improvement

Reimplemented in SolverKKTTpl< _Scalar >, and SolverKKTTpl< double >.

◆ computeCandidate()

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

Compute new candidate solution using step length.

This method updates the candidate primal and dual variables by taking a step from the current solution along the computed search direction, scaled by the step length alpha. It prepares a candidate point that is evaluated before being accepted by the solver.

Parameters
[in]steplengthapplied step length ( $0\leq\alpha\leq1$, with 1 as default)

Reimplemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, and SolverOdynSQPTpl< _Scalar >.

◆ stoppingCriteria()

template<typename _Scalar>
virtual Scalar stoppingCriteria()
pure virtual

Return a positive value that quantifies the algorithm termination.

These values typically represents the gradient norm which tell us that it's been reached the local minima. The stopping criteria strictly speaking depends on the search direction (calculated by computeDirection()) but it could also depend on the chosen step length, tested by tryStep().

Implemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, SolverKKTTpl< _Scalar >, SolverKKTTpl< double >, and SolverOdynSQPTpl< _Scalar >.

◆ expectedImprovement()

template<typename _Scalar>
virtual Vector3s expectedImprovement()
pure virtual

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

For computing the expected improvement, you need to compute the search direction first via computeDirection(). The quadratic improvement model is described as dV = DV_0 + DV_1 + 0.5 * DV_2, where DV_0, DV_1, and DV_2 are the constant, linear, and quadratic terms, respectively.

Implemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, SolverKKTTpl< _Scalar >, SolverKKTTpl< double >, and SolverOdynSQPTpl< _Scalar >.

◆ computeMeritFunctionImprovement()

template<typename _Scalar>
virtual void computeMeritFunctionImprovement()
virtual

Compute the merit function improvement for the current step.

This function computes the current merit function improvement given the current cost improvement and feasibility improvement. The feasibility improvement are stored in dfeas_.

Reimplemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, and SolverOdynSQPTpl< _Scalar >.

◆ computeExpectedMeritFunctionImprovement()

template<typename _Scalar>
virtual void computeExpectedMeritFunctionImprovement()
virtual

Compute the expected merit function improvement for the current step.

This function computes the expected merit function improvement given the expected cost improvement and feasibility improvement. The feasibility improvement are stored in dfeas_.

Reimplemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, and SolverOdynSQPTpl< _Scalar >.

◆ updateMeritFunction()

template<typename _Scalar>
virtual void updateMeritFunction()
virtual

Update the merit function value for the current guess.

Reimplemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, and SolverOdynSQPTpl< _Scalar >.

◆ checkAcceptance()

template<typename _Scalar>
virtual bool checkAcceptance()
virtual

Check if we should accept or not the step.

Returns
True if we should accept the step. False otherwise

Reimplemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, and SolverOdynSQPTpl< _Scalar >.

◆ calcDir()

template<typename _Scalar>
virtual void calcDir()
virtual

Refresh the linearization of the optimal control problem around the current candidate.

This routine evaluates the shooting problem along the candidate trajectories (xs_, us_) to update the cost, dynamics, and constraint derivatives together with the feasibility metrics used by the solver. The main solve() loop invokes calcDir() automatically whenever a new linearization is required, but the method remains available when driving the solver manually (e.g., before calling computeDirection(false)).

Reimplemented in SolverIntroTpl< _Scalar >, and SolverIntroTpl< double >.

◆ setCandidate()

template<typename _Scalar>
virtual void setCandidate(const std::vector< VectorXs > &xs_warm = DefaultVector< Scalar >::value,
const std::vector< VectorXs > &us_warm = DefaultVector< Scalar >::value,
const boolis_feasible = false )
virtual

Set the solver candidate trajectories $(\mathbf{x}_s,\mathbf{u}_s)$.

The solver candidates are defined as a state and control trajectories $(\mathbf{x}_s,\mathbf{u}_s)$ of $T+1$ and $T$ elements, respectively. Additionally, we need to define the dynamic feasibility of the $(\mathbf{x}_s,\mathbf{u}_s)$ pair. Note that the trajectories are feasible if $\mathbf{x}_s$ is the resulting trajectory from the system rollout with $\mathbf{u}_s$ inputs. Updating the candidate invalidates any previously computed linearization; the next call to computeDirection() will therefore refresh the derivatives on demand.

Parameters
[in]xsstate trajectory of $T+1$ elements (default [])
[in]uscontrol trajectory of $T$ elements (default [])
[in]isFeasibletrue if the xs are obtained from integrating the us (rollout)

Reimplemented in SolverKKTTpl< _Scalar >, and SolverKKTTpl< double >.

◆ updateCandidate()

template<typename _Scalar>
virtual void updateCandidate()
virtual

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

Reimplemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, and SolverOdynSQPTpl< _Scalar >.

◆ decreaseRegularizationCriteria()

template<typename _Scalar>
virtual bool decreaseRegularizationCriteria()
virtual

Criteria used to decrease regularization.

Reimplemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, and SolverOdynSQPTpl< _Scalar >.

◆ increaseRegularizationCriteria()

template<typename _Scalar>
virtual bool increaseRegularizationCriteria()
virtual

Criteria used to increase regularization.

Reimplemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, and SolverOdynSQPTpl< _Scalar >.

◆ increaseRegularization()

template<typename _Scalar>
virtual void increaseRegularization()
virtual

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

Reimplemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, and SolverOdynSQPTpl< _Scalar >.

◆ decreaseRegularization()

template<typename _Scalar>
virtual void decreaseRegularization()
virtual

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

Reimplemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, and SolverOdynSQPTpl< _Scalar >.

◆ 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 in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, SolverIpopt, and SolverOdynSQPTpl< _Scalar >.

◆ 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

◆ 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})$.

◆ computeStateFeasibility()

template<typename _Scalar>
Scalar computeStateFeasibility(const std::vector< VectorXs > &xs)

Compute the state box-constraint feasibility from a given state trajectory.

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]xsVector state trajectory feasibility
Returns
the state trajectory's feasibility

◆ computeControlFeasibility()

template<typename _Scalar>
Scalar computeControlFeasibility(const std::vector< VectorXs > &us)

Compute the control box-constraint feasibility from a given control trajectory.

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]usVector control trajectory feasibility
Returns
the control trajectory's 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.

◆ 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.

◆ setCallbacks()

template<typename _Scalar>
void setCallbacks(const std::vector< std::shared_ptr< CallbackAbstract > > &callbacks)

Set a list of callback functions using for the solver diagnostic.

Each iteration, the solver calls these set of functions in order to allowed user the diagnostic of its performance.

Parameters
callbacksset of callback functions

◆ get_ureg()

template<typename _Scalar>
Scalar get_ureg()const
inline

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

◆ DEPRECATED() [1/3]

template<typename _Scalar>
DEPRECATED("Do not use this threshold. It is not needed by our solvers",
Scalar get_th_gaptol() const { return th_gaptol_;} ) const

Return the threshold for accepting a gap as non-zero.

Return the type of norm used to evaluate the dynamic and constraints feasibility

◆ set_ureg()

template<typename _Scalar>
void set_ureg(const Scalarureg)
inline

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

◆ DEPRECATED() [2/3]

template<typename _Scalar>
DEPRECATED("Do not use this threshold. It is not needed by our solvers",
void set_th_gaptol(const Scalar th_gaptol); ) const

Modify the threshold for accepting a gap as non-zero.

Modify the current norm used for computed the dynamic and constraint feasibility

◆ resizeRunningData()

template<typename _Scalar>
virtual void resizeRunningData()
protectedvirtual

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

This function is invoked by resizeData() whenever the horizon or the running action models change. Derived classes can override it to adjust their own storage before the solver resumes.

Reimplemented in SolverBoxFDDPTpl< _Scalar >, SolverBoxFDDPTpl< double >, SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, and SolverOdynSQPTpl< _Scalar >.

◆ resizeTerminalData()

template<typename _Scalar>
virtual void resizeTerminalData()
protectedvirtual

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

This function is invoked by resizeData() whenever the terminal model changes. Derived classes can override it to resize custom storage that depends on the terminal constraints or cost.

Reimplemented in SolverFDDPTpl< _Scalar >, SolverFDDPTpl< double >, SolverFDDPTpl< Scalar >, and SolverOdynSQPTpl< _Scalar >.

◆ DEPRECATED() [3/3]

template<typename _Scalar>
DEPRECATED("Do not use this threshold. It is not needed by our solvers",
Scalar th_gaptol_; )
protected

Type of norm used to evaluate the dynamics and constraints feasibility

Parameters
-Threshold limit to check non-zero gaps

Member Data Documentation

◆ Scalar

template<typename _Scalar>
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar

Definition at line 80 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.

◆ callbacks_

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

Callback functions.

Definition at line 700 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.

◆ 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.

◆ 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.

◆ xs_

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

State trajectory.

Definition at line 713 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.

◆ fs_

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

Dynamics gaps in each node.

Definition at line 715 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.

◆ 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.

◆ 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.

◆ dxs_

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

Linear state direction (size T + 1).

Definition at line 722 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.

◆ 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.

◆ was_feasible_

template<typename _Scalar>
bool was_feasible_
protected

Label that indicates in the previous iterate was feasible

Definition at line 725 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.

◆ merit_

template<typename _Scalar>
Scalar merit_
protected

Merit for the current guess.

Definition at line 729 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.

◆ 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.

◆ 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.

◆ dPhi_

template<typename _Scalar>
Scalar dPhi_
protected

Reduction in the merit function computed by tryStep().

Definition at line 734 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.

◆ 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.

◆ 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.

◆ dfeas_

template<typename _Scalar>
Scalar dfeas_
protected

Reduction in the feasibility.

Definition at line 741 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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_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.

◆ tmp_feas_

template<typename _Scalar>
Scalar tmp_feas_
protected

Temporal variables used for computed the feasibility.

Definition at line 755 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.

◆ dreg_

template<typename _Scalar>
Scalar dreg_
protected

Current dual-variable regularization value.

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

◆ ureg_

template<typename _Scalar>
Scalar ureg_
protected

Definition at line 761 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.

◆ reg_max_

template<typename _Scalar>
Scalar reg_max_
protected

Maximum allowed regularization value.

Definition at line 763 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.

◆ g_adj_

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

Adjusted inequality bound.

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

◆ x_adj_

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

Adjusted state bound.

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

◆ u_adj_

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

Adjusted control bound.

Definition at line 767 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.

◆ 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.

◆ acceptstep_

template<typename _Scalar>
bool acceptstep_
protected

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

◆ recalcdir_

template<typename _Scalar>
bool recalcdir_
protected

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


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