1#ifndef CGMRES__HORIZON_HPP_
2#define CGMRES__HORIZON_HPP_
28 : Tf_(Tf), alpha_(alpha), t0_(t0) {
30 throw std::invalid_argument(
"[Horizon]: 'Tf' must be positive!");
32 time_varying_length_ = (alpha > 0.0);
51 if (time_varying_length_) {
53 throw std::invalid_argument(
"[Horizon]: 't' must be greater than or equal to 't0' (" + std::to_string(t0_) +
") !");
55 return Tf_ * (1.0-std::exp(-alpha_*(t-t0_)));
70 void disp(std::ostream& os)
const {
72 if (time_varying_length_) {
73 os <<
"time-varying length" << std::endl;
76 os <<
"fixed length" << std::endl;
78 os <<
" Tf: " << Tf_ << std::endl;
79 os <<
" alpha: " << alpha_ << std::endl;
80 os <<
" t0: " << t0_ << std::endl;
90 bool time_varying_length_;
Horizon of MPC.
Definition: horizon.hpp:18
~Horizon()=default
Default destructor.
Horizon(const Scalar Tf, const Scalar alpha=0.0, const Scalar t0=0.0)
Constructs the horizon. If alpha <= 0.0, then the fixed-length Tf is used. If alpha > 0....
Definition: horizon.hpp:27
Scalar T(const Scalar t) const
Gets the length of the horizon.
Definition: horizon.hpp:50
Horizon()=default
Default constructor.
friend std::ostream & operator<<(std::ostream &os, const Horizon &horizon)
Definition: horizon.hpp:83
void disp(std::ostream &os) const
Definition: horizon.hpp:70
void reset(const Scalar t0)
Resets the length of the horizon (for time-varying horizon).
Definition: horizon.hpp:66
Definition: continuation_gmres.hpp:11
double Scalar
Alias of double.
Definition: types.hpp:11