Public Member Functions | |
EIGEN_MAKE_ALIGNED_OPERATOR_NEW | SolverKKT (boost::shared_ptr< ShootingProblem > problem) |
virtual void | computeDirection (const bool recalc=true) |
Compute the search direction \((\delta\mathbf{x}^k,\delta\mathbf{u}^k)\) for the current guess \((\mathbf{x}^k_s,\mathbf{u}^k_s)\). More... | |
virtual const Eigen::Vector2d & | expectedImprovement () |
Return the expected improvement \(dV_{exp}\) from a given current search direction \((\delta\mathbf{x}^k,\delta\mathbf{u}^k)\). More... | |
const std::vector< Eigen::VectorXd > & | get_dus () const |
const std::vector< Eigen::VectorXd > & | get_dxs () const |
const Eigen::MatrixXd & | get_kkt () const |
const Eigen::VectorXd & | get_kktref () const |
const std::vector< Eigen::VectorXd > & | get_lambdas () const |
std::size_t | get_ndx () const |
std::size_t | get_nu () const |
std::size_t | get_nx () const |
const Eigen::VectorXd & | get_primaldual () const |
virtual bool | solve (const std::vector< Eigen::VectorXd > &init_xs=DEFAULT_VECTOR, const std::vector< Eigen::VectorXd > &init_us=DEFAULT_VECTOR, const std::size_t maxiter=100, const bool is_feasible=false, const double regInit=1e-9) |
Compute the optimal trajectory \(\mathbf{x}^*_s,\mathbf{u}^*_s\) as lists of \(T+1\) and \(T\) terms. More... | |
virtual double | stoppingCriteria () |
Return a positive value that quantifies the algorithm termination. More... | |
virtual double | tryStep (const double steplength=1) |
Try a predefined step length \(\alpha\) and compute its cost improvement \(dV\). More... | |
![]() | |
EIGEN_MAKE_ALIGNED_OPERATOR_NEW | SolverAbstract (boost::shared_ptr< ShootingProblem > problem) |
Initialize the solver. More... | |
double | computeDynamicFeasibility () |
Compute the dynamic feasibility \(\|\mathbf{f}_{\mathbf{s}}\|_{\infty,1}\) for the current guess \((\mathbf{x}^k,\mathbf{u}^k)\). More... | |
double | get_cost () const |
Return the total cost. | |
const Eigen::Vector2d & | get_d () const |
Return the LQ approximation of the expected improvement. | |
double | get_dV () const |
Return the cost reduction \(dV\). | |
double | get_dVexp () const |
Return the expected cost reduction \(dV_{exp}\). | |
double | get_ffeas () const |
Return the feasibility of the dynamic constraints \(\|\mathbf{f}_{\mathbf{s}}\|_{\infty,1}\) of the current guess. | |
const std::vector< Eigen::VectorXd > & | get_fs () const |
Return the gaps \(\mathbf{f}_{s}\). | |
bool | get_inffeas () const |
Return the norm used for the computing the feasibility (true for \(\ell_\infty\), false for \(\ell_1\)) | |
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. | |
const boost::shared_ptr< ShootingProblem > & | get_problem () const |
Return the shooting problem. | |
double | get_steplength () const |
Return the step length \(\alpha\). | |
double | get_stop () const |
Return the value computed by stoppingCriteria() | |
double | get_th_acceptstep () const |
Return the threshold used for accepting a step. | |
double | get_th_gaptol () const |
Return the threshold for accepting a gap as non-zero. | |
double | get_th_stop () const |
Return the tolerance for stopping the algorithm. | |
double | get_ureg () const |
Return the control regularization value. | |
const std::vector< Eigen::VectorXd > & | get_us () const |
Return the control trajectory \(\mathbf{u}_s\). | |
double | get_xreg () const |
Return the state regularization value. | |
const std::vector< Eigen::VectorXd > & | get_xs () const |
Return the state trajectory \(\mathbf{x}_s\). | |
const std::vector< boost::shared_ptr< CallbackAbstract > > & | getCallbacks () const |
Return the list of callback functions using for diagnostic. | |
virtual void | resizeData () |
Resizing the solver data. More... | |
void | set_inffeas (const bool inffeas) |
Modify the current norm used for computed the feasibility. | |
void | set_th_acceptstep (const double th_acceptstep) |
Modify the threshold used for accepting step. | |
void | set_th_gaptol (const double th_gaptol) |
Modify the threshold for accepting a gap as non-zero. | |
void | set_th_stop (const double th_stop) |
Modify the tolerance for stopping the algorithm. | |
void | set_ureg (const double ureg) |
Modify the control regularization value. | |
void | set_us (const std::vector< Eigen::VectorXd > &us) |
Modify the control trajectory \(\mathbf{u}_s\). | |
void | set_xreg (const double xreg) |
Modify the state regularization value. | |
void | set_xs (const std::vector< Eigen::VectorXd > &xs) |
Modify the state trajectory \(\mathbf{x}_s\). | |
void | setCallbacks (const std::vector< boost::shared_ptr< CallbackAbstract > > &callbacks) |
Set a list of callback functions using for the solver diagnostic. More... | |
void | setCandidate (const std::vector< Eigen::VectorXd > &xs_warm=DEFAULT_VECTOR, const std::vector< Eigen::VectorXd > &us_warm=DEFAULT_VECTOR, const bool is_feasible=false) |
Set the solver candidate trajectories \((\mathbf{x}_s,\mathbf{u}_s)\). More... | |
Protected Attributes | |
double | cost_try_ |
double | reg_decfactor_ |
double | reg_incfactor_ |
double | reg_max_ |
double | reg_min_ |
std::vector< Eigen::VectorXd > | us_try_ |
std::vector< Eigen::VectorXd > | xs_try_ |
![]() | |
std::vector< boost::shared_ptr< CallbackAbstract > > | callbacks_ |
Callback functions. | |
double | cost_ |
Total cost. | |
Eigen::Vector2d | d_ |
LQ approximation of the expected improvement. | |
double | dV_ |
Cost reduction obtained by tryStep() | |
double | dVexp_ |
Expected cost reduction. | |
double | ffeas_ |
Feasibility of the dynamic constraints. | |
std::vector< Eigen::VectorXd > | fs_ |
Gaps/defects between shooting nodes. | |
bool | inffeas_ |
bool | is_feasible_ |
Label that indicates is the iteration is feasible. | |
std::size_t | iter_ |
Number of iteration performed by the solver. | |
boost::shared_ptr< ShootingProblem > | problem_ |
optimal control problem | |
double | steplength_ |
Current applied step-length. | |
double | stop_ |
Value computed by stoppingCriteria() | |
double | th_acceptstep_ |
Threshold used for accepting step. | |
double | th_gaptol_ |
Threshold limit to check non-zero gaps. | |
double | th_stop_ |
Tolerance for stopping the algorithm. | |
double | tmp_feas_ |
Temporal variables used for computed the feasibility. | |
double | ureg_ |
Current control regularization values. | |
std::vector< Eigen::VectorXd > | us_ |
Control trajectory. | |
bool | was_feasible_ |
Label that indicates in the previous iterate was feasible. | |
double | xreg_ |
Current state regularization value. | |
std::vector< Eigen::VectorXd > | xs_ |
State trajectory. | |
|
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.
[in] | init_xs | initial guess for state trajectory with \(T+1\) elements (default []) |
[in] | init_us | initial guess for control trajectory with \(T\) elements (default []) |
[in] | maxiter | maximum allowed number of iterations (default 100) |
[in] | isFeasible | true if the init_xs are obtained from integrating the init_us (rollout) (default false) |
[in] | regInit | initial guess for the regularization value. Very low values are typical used with very good guess points (init_xs, init_us) |
Implements SolverAbstract.
|
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.
[in] | recalc | true for recalculating the derivatives at current state and control |
Implements SolverAbstract.
|
virtual |
Try a predefined step length \(\alpha\) and compute its cost improvement \(dV\).
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\).
[in] | steplength | applied step length ( \(0\leq\alpha\leq1\)) |
Implements SolverAbstract.
|
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()
.
Implements SolverAbstract.
|
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()
.
Implements SolverAbstract.