GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/crocoddyl/core/solvers/ipopt.hpp Lines: 0 1 0.0 %
Date: 2024-02-13 11:12:33 Branches: 0 0 - %

Line Branch Exec Source
1
///////////////////////////////////////////////////////////////////////////////
2
// 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.
7
///////////////////////////////////////////////////////////////////////////////
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
22
/**
23
 * @brief Ipopt solver
24
 *
25
 * This solver solves the optimal control problem by transcribing with the
26
 * multiple shooting approach.
27
 *
28
 * \sa `solve()`
29
 */
30
class SolverIpopt : public SolverAbstract {
31
 public:
32
  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
33
34
  /**
35
   * @brief Initialize the Ipopt solver
36
   *
37
   * @param[in]  problem solver to be diagnostic
38
   */
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
48
  /**
49
   * @brief Set a string ipopt option
50
   *
51
   * @param[in]  tag name of the parameter
52
   * @param[in]  value string value for the parameter
53
   */
54
  void setStringIpoptOption(const std::string& tag, const std::string& value);
55
56
  /**
57
   * @brief Set a string ipopt option
58
   *
59
   * @param[in]  tag name of the parameter
60
   * @param[in]  value numeric value for the parameter
61
   */
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