crocoddyl
1.9.0
Contact RObot COntrol by Differential DYnamic programming Library (Crocoddyl)
|
|
9 #ifndef CROCODDYL_CORE_SOLVER_BASE_HPP_
10 #define CROCODDYL_CORE_SOLVER_BASE_HPP_
14 #include "crocoddyl/core/optctrl/shooting.hpp"
15 #include "crocoddyl/core/utils/stop-watch.hpp"
19 class CallbackAbstract;
20 static std::vector<Eigen::VectorXd> DEFAULT_VECTOR;
53 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
60 explicit SolverAbstract(boost::shared_ptr<ShootingProblem> problem);
79 virtual bool solve(
const std::vector<Eigen::VectorXd>& init_xs = DEFAULT_VECTOR,
80 const std::vector<Eigen::VectorXd>& init_us = DEFAULT_VECTOR,
const std::size_t maxiter = 100,
81 const bool is_feasible =
false,
const double reg_init = 1e-9) = 0;
106 virtual double tryStep(
const double steplength = 1) = 0;
156 void setCandidate(
const std::vector<Eigen::VectorXd>& xs_warm = DEFAULT_VECTOR,
157 const std::vector<Eigen::VectorXd>& us_warm = DEFAULT_VECTOR,
const bool is_feasible =
false);
167 void setCallbacks(
const std::vector<boost::shared_ptr<CallbackAbstract> >& callbacks);
172 const std::vector<boost::shared_ptr<CallbackAbstract> >&
getCallbacks()
const;
177 const boost::shared_ptr<ShootingProblem>&
get_problem()
const;
182 const std::vector<Eigen::VectorXd>&
get_xs()
const;
187 const std::vector<Eigen::VectorXd>&
get_us()
const;
192 const std::vector<Eigen::VectorXd>&
get_fs()
const;
212 const Eigen::Vector2d&
get_d()
const;
273 void set_xs(
const std::vector<Eigen::VectorXd>& xs);
278 void set_us(
const std::vector<Eigen::VectorXd>& us);
312 std::vector<Eigen::VectorXd>
xs_;
313 std::vector<Eigen::VectorXd>
us_;
314 std::vector<Eigen::VectorXd>
fs_;
315 std::vector<boost::shared_ptr<CallbackAbstract> >
callbacks_;
355 virtual void operator()(SolverAbstract& solver) = 0;
358 bool raiseIfNaN(
const double value);
362 #endif // CROCODDYL_CORE_SOLVER_BASE_HPP_
double th_acceptstep_
Threshold used for accepting step.
const Eigen::Vector2d & get_d() const
Return the LQ approximation of the expected improvement.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW SolverAbstract(boost::shared_ptr< ShootingProblem > problem)
Initialize the solver.
Abstract class for solver callbacks.
double get_steplength() const
Return the step length .
Abstract class for optimal control solvers.
double computeDynamicFeasibility()
Compute the dynamic feasibility for the current guess .
void set_th_acceptstep(const double th_acceptstep)
Modify the threshold used for accepting step.
double th_gaptol_
Threshold limit to check non-zero gaps.
double get_th_gaptol() const
Return the threshold for accepting a gap as non-zero.
bool is_feasible_
Label that indicates is the iteration is feasible.
Eigen::Vector2d d_
LQ approximation of the expected improvement.
void set_th_gaptol(const double th_gaptol)
Modify the threshold for accepting a gap as non-zero.
double get_cost() const
Return the total cost.
virtual void operator()(SolverAbstract &solver)=0
Run the callback function given a solver.
CallbackAbstract()
Initialize the callback function.
virtual void resizeData()
Resizing the solver data.
std::size_t iter_
Number of iteration performed by the solver.
void set_xs(const std::vector< Eigen::VectorXd > &xs)
Modify the state trajectory .
double ureg_
Current control regularization values.
double stop_
Value computed by stoppingCriteria()
const std::vector< boost::shared_ptr< CallbackAbstract > > & getCallbacks() const
Return the list of callback functions using for diagnostic.
void set_th_stop(const double th_stop)
Modify the tolerance for stopping the algorithm.
bool get_is_feasible() const
Return the feasibility status of the trajectory.
virtual double stoppingCriteria()=0
Return a positive value that quantifies the algorithm termination.
double get_dV() const
Return the cost reduction .
double steplength_
Current applied step-length.
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 .
double th_stop_
Tolerance for stopping the algorithm.
virtual void computeDirection(const bool recalc)=0
Compute the search direction for the current guess .
double get_xreg() const
Return the state regularization value.
bool get_inffeas() const
Return the norm used for the computing the feasibility (true for , false for )
double tmp_feas_
Temporal variables used for computed the feasibility.
virtual double tryStep(const double steplength=1)=0
Try a predefined step length and compute its cost improvement .
double ffeas_
Feasibility of the dynamic constraints.
boost::shared_ptr< ShootingProblem > problem_
optimal control problem
double get_th_acceptstep() const
Return the threshold used for accepting a step.
std::vector< boost::shared_ptr< CallbackAbstract > > callbacks_
Callback functions.
void setCallbacks(const std::vector< boost::shared_ptr< CallbackAbstract > > &callbacks)
Set a list of callback functions using for the solver diagnostic.
const std::vector< Eigen::VectorXd > & get_xs() const
Return the state trajectory .
double xreg_
Current state regularization value.
double get_ureg() const
Return the control regularization value.
double dVexp_
Expected cost reduction.
const std::vector< Eigen::VectorXd > & get_fs() const
Return the gaps .
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 reg_init=1e-9)=0
Compute the optimal trajectory as lists of and terms.
std::vector< Eigen::VectorXd > us_
Control trajectory.
double get_dVexp() const
Return the expected cost reduction .
std::size_t get_iter() const
Return the number of iterations performed by the solver.
std::vector< Eigen::VectorXd > fs_
Gaps/defects between shooting nodes.
virtual const Eigen::Vector2d & expectedImprovement()=0
Return the expected improvement from a given current search direction .
std::vector< Eigen::VectorXd > xs_
State trajectory.
void set_xreg(const double xreg)
Modify the state regularization value.
double get_th_stop() const
Return the tolerance for stopping the algorithm.
double get_stop() const
Return the value computed by stoppingCriteria()
const boost::shared_ptr< ShootingProblem > & get_problem() const
Return the shooting problem.
void set_ureg(const double ureg)
Modify the control regularization value.
double dV_
Cost reduction obtained by tryStep()
void set_inffeas(const bool inffeas)
Modify the current norm used for computed the feasibility.
const std::vector< Eigen::VectorXd > & get_us() const
Return the control trajectory .
bool was_feasible_
Label that indicates in the previous iterate was feasible.
double get_ffeas() const
Return the feasibility of the dynamic constraints of the current guess.
void set_us(const std::vector< Eigen::VectorXd > &us)
Modify the control trajectory .