GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/crocoddyl/core/solvers/intro.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) 2021-2023, Heriot-Watt University, University of Edinburgh
5
// Copyright note valid unless otherwise stated in individual files.
6
// All rights reserved.
7
///////////////////////////////////////////////////////////////////////////////
8
9
#ifndef CROCODDYL_CORE_SOLVERS_INTRO_HPP_
10
#define CROCODDYL_CORE_SOLVERS_INTRO_HPP_
11
12
#include "crocoddyl/core/solvers/fddp.hpp"
13
14
namespace crocoddyl {
15
16
enum EqualitySolverType { LuNull = 0, QrNull, Schur };
17
18
class SolverIntro : public SolverFDDP {
19
 public:
20
  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
21
22
  /**
23
   * @brief Initialize the INTRO solver
24
   *
25
   * @param[in] problem  Shooting problem
26
   * @param[in] reduced  Use the reduced Schur-complement approach (default
27
   * true)
28
   */
29
  explicit SolverIntro(boost::shared_ptr<ShootingProblem> problem);
30
  virtual ~SolverIntro();
31
32
  virtual bool solve(
33
      const std::vector<Eigen::VectorXd>& init_xs = DEFAULT_VECTOR,
34
      const std::vector<Eigen::VectorXd>& init_us = DEFAULT_VECTOR,
35
      const std::size_t maxiter = 100, const bool is_feasible = false,
36
      const double init_reg = NAN);
37
  virtual double tryStep(const double step_length = 1);
38
  virtual double stoppingCriteria();
39
  virtual void resizeData();
40
  virtual double calcDiff();
41
  virtual void computeValueFunction(
42
      const std::size_t t, const boost::shared_ptr<ActionModelAbstract>& model);
43
  virtual void computeGains(const std::size_t t);
44
45
  /**
46
   * @brief Return the type of solver used for handling the equality constraints
47
   */
48
  EqualitySolverType get_equality_solver() const;
49
50
  /**
51
   * @brief Return the threshold for switching to feasibility
52
   */
53
  double get_th_feas() const;
54
55
  /**
56
   * @brief Return the rho parameter used in the merit function
57
   */
58
  double get_rho() const;
59
60
  /**
61
   * @brief Return the estimated penalty parameter that balances relative
62
   * contribution of the cost function and equality constraints
63
   */
64
  double get_upsilon() const;
65
66
  /**
67
   * @brief Return the rank of control-equality constraints \f$\mathbf{H_u}\f
68
   */
69
  const std::vector<std::size_t>& get_Hu_rank() const;
70
71
  /**
72
   * @brief Return the span and kernel of control-equality constraints
73
   * \f$\mathbf{H_u}\f
74
   */
75
  const std::vector<Eigen::MatrixXd>& get_YZ() const;
76
77
  /**
78
   * @brief Return Hessian of the reduced Hamiltonian \f$\mathbf{Q_{zz}}\f$
79
   */
80
  const std::vector<Eigen::MatrixXd>& get_Qzz() const;
81
82
  /**
83
   * @brief Return Hessian of the reduced Hamiltonian \f$\mathbf{Q_{xz}}\f$
84
   */
85
  const std::vector<Eigen::MatrixXd>& get_Qxz() const;
86
87
  /**
88
   * @brief Return Hessian of the reduced Hamiltonian \f$\mathbf{Q_{uz}}\f$
89
   */
90
  const std::vector<Eigen::MatrixXd>& get_Quz() const;
91
92
  /**
93
   * @brief Return Jacobian of the reduced Hamiltonian \f$\mathbf{Q_{z}}\f$
94
   */
95
  const std::vector<Eigen::VectorXd>& get_Qz() const;
96
97
  /**
98
   * @brief Return span-projected Jacobian of the equality-constraint with
99
   * respect to the control
100
   */
101
  const std::vector<Eigen::MatrixXd>& get_Hy() const;
102
103
  /**
104
   * @brief Return feedforward term related to the nullspace of
105
   * \f$\mathbf{H_u}\f$
106
   */
107
  const std::vector<Eigen::VectorXd>& get_kz() const;
108
109
  /**
110
   * @brief Return feedback gain related to the nullspace of \f$\mathbf{H_u}\f$
111
   */
112
  const std::vector<Eigen::MatrixXd>& get_Kz() const;
113
114
  /**
115
   * @brief Return feedforward term related to the equality constraints
116
   */
117
  const std::vector<Eigen::VectorXd>& get_ks() const;
118
119
  /**
120
   * @brief Return feedback gain related to the equality constraints
121
   */
122
  const std::vector<Eigen::MatrixXd>& get_Ks() const;
123
124
  /**
125
   * @brief Return the zero-upsilon label
126
   *
127
   * True if we set the estimated penalty parameter (upsilon) to zero when solve
128
   * is called.
129
   */
130
  bool get_zero_upsilon() const;
131
132
  /**
133
   * @brief Modify the type of solver used for handling the equality constraints
134
   *
135
   * Note that the default solver is nullspace LU. When we enable
136
   * parallelization, this strategy is generally faster than others for medium
137
   * to large systems.
138
   */
139
  void set_equality_solver(const EqualitySolverType type);
140
141
  /**
142
   * @brief Modify the threshold for switching to feasibility
143
   */
144
  void set_th_feas(const double th_feas);
145
146
  /**
147
   * @brief Modify the rho parameter used in the merit function
148
   */
149
  void set_rho(const double rho);
150
151
  /**
152
   * @brief Modify the zero-upsilon label
153
   *
154
   * @param zero_upsilon  True if we set estimated penalty parameter (upsilon)
155
   * to zero when solve is called.
156
   */
157
  void set_zero_upsilon(const bool zero_upsilon);
158
159
 protected:
160
  enum EqualitySolverType
161
      eq_solver_;   //!< Strategy used for handling the equality constraints
162
  double th_feas_;  //!< Threshold for switching to feasibility
163
  double rho_;      //!< Parameter used in the merit function to predict the
164
                    //!< expected reduction
165
  double
166
      upsilon_;  //!< Estimated penalty parameter that balances relative
167
                 //!< contribution of the cost function and equality constraints
168
  bool zero_upsilon_;  //!< True if we wish to set estimated penalty parameter
169
                       //!< (upsilon) to zero when solve is called.
170
171
  std::vector<std::size_t>
172
      Hu_rank_;  //!< Rank of the control Jacobian of the equality constraints
173
  std::vector<Eigen::MatrixXd> KQuu_tmp_;
174
  std::vector<Eigen::MatrixXd>
175
      YZ_;  //!< Span \f$\mathbf{Y}\in\mathbb{R}^{rank}\f$ and kernel
176
            //!< \f$\mathbf{Z}\in\mathbb{R}^{nullity}\f$ of the control-equality
177
            //!< constraints \f$\mathbf{H_u}\f$
178
  std::vector<Eigen::MatrixXd>
179
      Hy_;  //!< Span-projected Jacobian of the equality-constraint with respect
180
            //!< to the control
181
  std::vector<Eigen::VectorXd>
182
      Qz_;  //!< Jacobian of the reduced Hamiltonian \f$\mathbf{Q_{z}}\f$
183
  std::vector<Eigen::MatrixXd>
184
      Qzz_;  //!< Hessian of the reduced Hamiltonian \f$\mathbf{Q_{zz}}\f$
185
  std::vector<Eigen::MatrixXd>
186
      Qxz_;  //!< Hessian of the reduced Hamiltonian \f$\mathbf{Q_{xz}}\f$
187
  std::vector<Eigen::MatrixXd>
188
      Quz_;  //!< Hessian of the reduced Hamiltonian \f$\mathbf{Q_{uz}}\f$
189
  std::vector<Eigen::VectorXd>
190
      kz_;  //!< Feedforward term in the nullspace of \f$\mathbf{H_u}\f$
191
  std::vector<Eigen::MatrixXd>
192
      Kz_;  //!< Feedback gain in the nullspace of \f$\mathbf{H_u}\f$
193
  std::vector<Eigen::VectorXd>
194
      ks_;  //!< Feedforward term related to the equality constraints
195
  std::vector<Eigen::MatrixXd>
196
      Ks_;  //!< Feedback gain related to the equality constraints
197
  std::vector<Eigen::MatrixXd> QuuinvHuT_;
198
  std::vector<Eigen::LLT<Eigen::MatrixXd> > Qzz_llt_;  //!< Cholesky LLT solver
199
  std::vector<Eigen::FullPivLU<Eigen::MatrixXd> >
200
      Hu_lu_;  //!< Full-pivot LU solvers used for computing the span and
201
               //!< nullspace matrices
202
  std::vector<Eigen::ColPivHouseholderQR<Eigen::MatrixXd> >
203
      Hu_qr_;  //!< Column-pivot QR solvers used for computing the span and
204
               //!< nullspace matrices
205
  std::vector<Eigen::PartialPivLU<Eigen::MatrixXd> >
206
      Hy_lu_;  //!< Partial-pivot LU solvers used for computing the feedforward
207
               //!< and feedback gain related to the equality constraint
208
};
209
210
}  // namespace crocoddyl
211
212
#endif  // CROCODDYL_CORE_SOLVERS_INTRO_HPP_