1#ifndef CGMRES__CONTINUATION_GMRES_HPP_
2#define CGMRES__CONTINUATION_GMRES_HPP_
17 static constexpr int nx = NLP::nx;
18 static constexpr int nu = NLP::nu;
19 static constexpr int nc = NLP::nc;
20 static constexpr int dim = NLP::dim;
25 finite_difference_epsilon_(finite_difference_epsilon),
33 if (finite_difference_epsilon <= 0.0) {
34 throw std::invalid_argument(
"[ContinuationGMRES]: 'finite_difference_epsilon' must be positive!");
37 throw std::invalid_argument(
"[ContinuationGMRES]: 'zeta' must be positive!");
46 return fonc_.template lpNorm<2>();
49 template <
typename VectorType>
51 nlp_.eval_fonc_hu(t,
x, solution, fonc_);
54 template <
typename VectorType1,
typename VectorType2,
typename VectorType3,
typename VectorType4>
59 assert(solution.size() ==
dim);
60 assert(solution_update.size() ==
dim);
61 assert(b_vec.size() ==
dim);
63 const Scalar t1 = t + finite_difference_epsilon_;
64 nlp_.ocp().eval_f(t,
x.derived().data(), solution.derived().data(), dx_.data());
65 x_1_ =
x + finite_difference_epsilon_ * dx_;
66 updated_solution_ = solution + finite_difference_epsilon_ * solution_update;
68 nlp_.eval_fonc_hu(t,
x, solution, fonc_);
69 nlp_.eval_fonc_hu(t1, x_1_, solution, fonc_1_);
70 nlp_.eval_fonc_hu(t1, x_1_, updated_solution_, fonc_2_);
73 - fonc_2_ / finite_difference_epsilon_;
76 template <
typename VectorType1,
typename VectorType2,
typename VectorType3,
typename VectorType4>
81 assert(solution.size() ==
dim);
82 assert(solution_update.size() ==
dim);
83 assert(ax_vec.size() ==
dim);
84 const Scalar t1 = t + finite_difference_epsilon_;
85 updated_solution_ = solution + finite_difference_epsilon_ * solution_update;
86 nlp_.eval_fonc_hu(t1, x_1_, updated_solution_, fonc_2_);
92 nlp_.retrive_dummy(solution, fonc_1_, min_dummy);
97 nlp_.retrive_mu(solution, fonc_1_);
100 decltype(
auto)
x()
const {
return nlp_.x(); }
102 decltype(
auto)
lmd()
const {
return nlp_.lmd(); }
108 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
112 Scalar finite_difference_epsilon_, zeta_;
113 Vector<dim> updated_solution_, fonc_, fonc_1_, fonc_2_;
Definition: continuation_gmres.hpp:15
void retrive_mu(Vector< dim > &solution)
Definition: continuation_gmres.hpp:95
ContinuationGMRES(const NLP &nlp, const Scalar finite_difference_epsilon, const Scalar zeta)
Definition: continuation_gmres.hpp:22
void eval_Ax(const Scalar t, const MatrixBase< VectorType1 > &x, const MatrixBase< VectorType2 > &solution, const MatrixBase< VectorType3 > &solution_update, const MatrixBase< VectorType4 > &ax_vec)
Definition: continuation_gmres.hpp:77
static constexpr int nc
Definition: continuation_gmres.hpp:19
decltype(auto) x() const
Definition: continuation_gmres.hpp:100
void eval_fonc(const Scalar t, const MatrixBase< VectorType > &x, const Vector< dim > &solution)
Definition: continuation_gmres.hpp:50
static constexpr int nu
Definition: continuation_gmres.hpp:18
ContinuationGMRES()=default
void eval_b(const Scalar t, const MatrixBase< VectorType1 > &x, const MatrixBase< VectorType2 > &solution, const MatrixBase< VectorType3 > &solution_update, const MatrixBase< VectorType4 > &b_vec)
Definition: continuation_gmres.hpp:55
void synchronize_ocp()
Definition: continuation_gmres.hpp:106
static constexpr int dim
Definition: continuation_gmres.hpp:20
Scalar optError() const
Definition: continuation_gmres.hpp:45
~ContinuationGMRES()=default
const NLP & get_nlp() const
Definition: continuation_gmres.hpp:104
void retrive_dummy(Vector< dim > &solution, const Scalar min_dummy)
Definition: continuation_gmres.hpp:90
static constexpr int nx
Definition: continuation_gmres.hpp:17
decltype(auto) lmd() const
Definition: continuation_gmres.hpp:102
#define CGMRES_EIGEN_CONST_CAST(TYPE, OBJ)
Definition: macros.hpp:7
Definition: continuation_gmres.hpp:11
Eigen::Matrix< Scalar, size, 1 > Vector
Alias of Eigen::Vector.
Definition: types.hpp:23
double Scalar
Alias of double.
Definition: types.hpp:11
Eigen::MatrixBase< MatrixType > MatrixBase
Alias of Eigen::MatrixBase.
Definition: types.hpp:29