Crocoddyl
ipopt.hpp
1 // BSD 3-Clause License
3 //
4 // Copyright (C) 2022-2023, IRI: CSIC-UPC, Heriot-Watt University
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
8 
9 #ifndef CROCODDYL_CORE_SOLVERS_IPOPT_HPP_
10 #define CROCODDYL_CORE_SOLVERS_IPOPT_HPP_
11 
12 #define HAVE_CSTDDEF
13 #include <IpIpoptApplication.hpp>
14 #include <IpSolveStatistics.hpp>
15 #undef HAVE_CSTDDEF
16 
17 #include "crocoddyl/core/solver-base.hpp"
18 #include "crocoddyl/core/solvers/ipopt/ipopt-iface.hpp"
19 
20 namespace crocoddyl {
21 
30 class SolverIpopt : public SolverAbstract {
31  public:
32  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
33 
39  SolverIpopt(boost::shared_ptr<crocoddyl::ShootingProblem> problem);
40  ~SolverIpopt();
41 
42  bool solve(const std::vector<Eigen::VectorXd>& init_xs = DEFAULT_VECTOR,
43  const std::vector<Eigen::VectorXd>& init_us = DEFAULT_VECTOR,
44  const std::size_t maxiter = 100, const bool is_feasible = false,
45  const double reg_init = 1e-9);
46  virtual void resizeData();
47 
54  void setStringIpoptOption(const std::string& tag, const std::string& value);
55 
62  void setNumericIpoptOption(const std::string& tag, Ipopt::Number value);
63 
64  void set_th_stop(const double th_stop);
65 
66  private:
67  Ipopt::SmartPtr<IpoptInterface> ipopt_iface_;
68  Ipopt::SmartPtr<Ipopt::IpoptApplication> ipopt_app_;
69  Ipopt::ApplicationReturnStatus ipopt_status_;
70 
71  virtual void computeDirection(const bool recalc);
72  virtual double tryStep(const double steplength = 1);
73  virtual double stoppingCriteria();
74  virtual const Eigen::Vector2d& expectedImprovement();
75 };
76 } // namespace crocoddyl
77 
78 #endif
Abstract class for optimal control solvers.
Definition: solver-base.hpp:61
Ipopt solver.
Definition: ipopt.hpp:30
EIGEN_MAKE_ALIGNED_OPERATOR_NEW SolverIpopt(boost::shared_ptr< crocoddyl::ShootingProblem > problem)
Initialize the Ipopt solver.
Definition: ipopt.cpp:13
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)
Compute the optimal trajectory as lists of and terms.
Definition: ipopt.cpp:27
void setStringIpoptOption(const std::string &tag, const std::string &value)
Set a string ipopt option.
Definition: ipopt.cpp:65
virtual void resizeData()
Resizing the solver data.
Definition: ipopt.cpp:50
void setNumericIpoptOption(const std::string &tag, Ipopt::Number value)
Set a string ipopt option.
Definition: ipopt.cpp:70