9 #ifndef CROCODDYL_CORE_SOLVER_BASE_HPP_ 10 #define CROCODDYL_CORE_SOLVER_BASE_HPP_ 14 #include "crocoddyl/core/optctrl/shooting.hpp" 18 class CallbackAbstract;
19 static std::vector<Eigen::VectorXd> DEFAULT_VECTOR;
52 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
59 explicit SolverAbstract(boost::shared_ptr<ShootingProblem> problem);
60 virtual ~SolverAbstract();
78 virtual bool solve(
const std::vector<Eigen::VectorXd>& init_xs = DEFAULT_VECTOR,
79 const std::vector<Eigen::VectorXd>& init_us = DEFAULT_VECTOR,
const std::size_t& maxiter = 100,
80 const bool& is_feasible =
false,
const double& reg_init = 1e-9) = 0;
105 virtual double tryStep(
const double& step_length = 1) = 0;
136 void setCandidate(
const std::vector<Eigen::VectorXd>& xs_warm = DEFAULT_VECTOR,
137 const std::vector<Eigen::VectorXd>& us_warm = DEFAULT_VECTOR,
const bool& is_feasible =
false);
147 void setCallbacks(
const std::vector<boost::shared_ptr<CallbackAbstract> >& callbacks);
152 const std::vector<boost::shared_ptr<CallbackAbstract> >&
getCallbacks()
const;
157 const boost::shared_ptr<ShootingProblem>&
get_problem()
const;
162 const std::vector<Eigen::VectorXd>&
get_xs()
const;
167 const std::vector<Eigen::VectorXd>&
get_us()
const;
187 const Eigen::Vector2d&
get_d()
const;
207 const double&
get_dV()
const;
227 const std::size_t&
get_iter()
const;
232 void set_xs(
const std::vector<Eigen::VectorXd>& xs);
237 void set_us(
const std::vector<Eigen::VectorXd>& us);
261 std::vector<Eigen::VectorXd>
xs_;
262 std::vector<Eigen::VectorXd>
us_;
263 std::vector<boost::shared_ptr<CallbackAbstract> >
callbacks_;
300 bool raiseIfNaN(
const double& value);
304 #endif // CROCODDYL_CORE_SOLVER_BASE_HPP_ const double & get_dV() const
Return the cost reduction.
bool is_feasible_
Label that indicates is the iteration is feasible.
void set_th_stop(const double &th_stop)
Modify the tolerance for stopping the algorithm.
const std::vector< Eigen::VectorXd > & get_us() const
Return the control trajectory .
const double & get_steplength() const
Return the step length.
const std::vector< Eigen::VectorXd > & get_xs() const
Return the state trajectory .
const boost::shared_ptr< ShootingProblem > & get_problem() const
Return the shooting problem.
double ureg_
Current control regularization values.
double steplength_
Current applied step-length.
void set_th_acceptstep(const double &th_acceptstep)
Modify the threshold used for accepting step.
void setCallbacks(const std::vector< boost::shared_ptr< CallbackAbstract > > &callbacks)
Set a list of callback functions using for diagnostic.
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 warm-point values .
double xreg_
Current state regularization value.
std::vector< boost::shared_ptr< CallbackAbstract > > callbacks_
Callback functions.
virtual void computeDirection(const bool &recalc)=0
Compute the search direction for the current guess .
double th_acceptstep_
Threshold used for accepting step.
const std::size_t & get_iter() const
Return the number of iterations performed by the solver.
std::vector< Eigen::VectorXd > us_
Control trajectory.
Abstract class for optimal control solvers.
double dV_
Cost reduction obtained by tryStep()
EIGEN_MAKE_ALIGNED_OPERATOR_NEW SolverAbstract(boost::shared_ptr< ShootingProblem > problem)
Initialize the solver.
Eigen::Vector2d d_
LQ approximation of the expected improvement.
virtual double stoppingCriteria()=0
Return a positive value that quantifies the algorithm termination.
boost::shared_ptr< ShootingProblem > problem_
optimal control problem
double dVexp_
Expected cost reduction.
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 ®_init=1e-9)=0
Compute the optimal trajectory as lists of and terms.
CallbackAbstract()
Initialize the callback function.
std::vector< Eigen::VectorXd > xs_
State trajectory.
void set_xreg(const double &xreg)
Modify the state regularization value.
const double & get_cost() const
Return the total cost.
virtual double tryStep(const double &step_length=1)=0
Try a predefined step length and compute its cost improvement.
const double & get_stop() const
Return the value computed by stoppingCriteria()
void set_ureg(const double &ureg)
Modify the control regularization value.
const std::vector< boost::shared_ptr< CallbackAbstract > > & getCallbacks() const
"Return the list of callback functions using for diagnostic
const double & get_th_stop() const
Return the tolerance for stopping the algorithm.
double th_stop_
Tolerance for stopping the algorithm.
void set_xs(const std::vector< Eigen::VectorXd > &xs)
Modify the state trajectory .
const double & get_dVexp() const
Return the expected cost reduction.
const double & get_ureg() const
Return the control regularization value.
void set_us(const std::vector< Eigen::VectorXd > &us)
Modify the control trajectory .
const Eigen::Vector2d & get_d() const
Return the LQ approximation of the expected improvement.
Abstract class for solver callbacks.
std::size_t iter_
Number of iteration performed by the solver.
const double & get_xreg() const
Return the state regularization value.
const double & get_th_acceptstep() const
Return the threshold used for accepting a step.
virtual const Eigen::Vector2d & expectedImprovement()=0
Return the expected improvement from a given current search direction.
double stop_
Value computed by stoppingCriteria()
const bool & get_is_feasible() const
Return the feasibility status of the trajectory.