Crocoddyl
Loading...
Searching...
No Matches
SolverIpopt Class Reference

Ipopt solver. More...

#include <ipopt.hpp>

Inheritance diagram for SolverIpopt:
SolverAbstractTpl< Ipopt::Number >SolverBase

Public Types

typedef IpoptInterfaceTpl< Scalar > IpoptInterface
typedef MathBaseTpl< Scalar > MathBase
typedef ShootingProblemTpl< Scalar > ShootingProblem
typedef SolverAbstractTpl< Scalar > SolverAbstract
typedef MathBase::Vector3s Vector3s
typedef MathBase::VectorXs VectorXs
Public Types inherited from SolverAbstractTpl< Ipopt::Number >
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

 SolverIpopt (std::shared_ptr< ShootingProblem > problem)
 Initialize the Ipopt solver.
virtual void resizeData () override
 Resizing the solver data.
void set_th_stop (const Scalar th_stop)
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)$.
void setNumericIpoptOption (const std::string &tag, Ipopt::Number value)
 Set a string ipopt option.
void setStringIpoptOption (const std::string &tag, const std::string &value)
 Set a string ipopt option.
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=Scalar(1e-9)) override
Public Member Functions inherited from SolverAbstractTpl< Ipopt::Number >
 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.
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 ("Use get_preg for primal-variable regularization", Scalar get_xreg() const { return preg_;}) DEPRECATED("Use get_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.
virtual void increaseRegularization ()
 Increase the state and control regularization values by a regfactor_ factor.
virtual bool increaseRegularizationCriteria ()
 Criteria used to increase regularization.
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 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 Ipopt::Number Scalar
Public Attributes inherited from SolverAbstractTpl< Ipopt::Number >
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Ipopt::Number Scalar

Additional Inherited Members

Protected Member Functions inherited from SolverAbstractTpl< Ipopt::Number >
void allocateData ()
 Allocate all the basic data needed in solvers.
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 inherited from SolverAbstractTpl< Ipopt::Number >
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

Ipopt solver.

This solver solves the optimal control problem by transcribing with the multiple shooting approach.

See also
solve()

Definition at line 30 of file ipopt.hpp.

Member Typedef Documentation

◆ SolverAbstract

typedef SolverAbstractTpl<Scalar> SolverAbstract

Definition at line 36 of file ipopt.hpp.

◆ ShootingProblem

typedef ShootingProblemTpl<Scalar> ShootingProblem

Definition at line 37 of file ipopt.hpp.

◆ IpoptInterface

typedef IpoptInterfaceTpl<Scalar> IpoptInterface

Definition at line 38 of file ipopt.hpp.

◆ MathBase

typedef MathBaseTpl<Scalar> MathBase

Definition at line 39 of file ipopt.hpp.

◆ VectorXs

typedef MathBase::VectorXs VectorXs

Definition at line 40 of file ipopt.hpp.

◆ Vector3s

typedef MathBase::Vector3s Vector3s

Definition at line 41 of file ipopt.hpp.

Constructor & Destructor Documentation

◆ SolverIpopt()

SolverIpopt(std::shared_ptr< ShootingProblem >problem)

Initialize the Ipopt solver.

Parameters
[in]problemsolver to be diagnostic

Member Function Documentation

◆ resizeData()

virtual void resizeData()
overridevirtual

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< Ipopt::Number >.

◆ setStringIpoptOption()

void setStringIpoptOption(const std::string &tag,
const std::string &value )

Set a string ipopt option.

Parameters
[in]tagname of the parameter
[in]valuestring value for the parameter

◆ setNumericIpoptOption()

void setNumericIpoptOption(const std::string &tag,
Ipopt::Numbervalue )

Set a string ipopt option.

Parameters
[in]tagname of the parameter
[in]valuenumeric value for the parameter

◆ setCandidate()

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 )

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)

Member Data Documentation

◆ Scalar

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Ipopt::Number Scalar

Definition at line 35 of file ipopt.hpp.


The documentation for this class was generated from the following file:
  • /build/source/include/crocoddyl/core/solvers/ipopt.hpp