Stan Math Library
4.9.0
Automatic Differentiation
|
std::vector< Eigen::VectorXd > stan::math::ode_adjoint_impl | ( | const char * | function_name, |
F && | f, | ||
const T_y0 & | y0, | ||
const T_t0 & | t0, | ||
const std::vector< T_ts > & | ts, | ||
double | relative_tolerance_forward, | ||
const T_abs_tol_fwd & | absolute_tolerance_forward, | ||
double | relative_tolerance_backward, | ||
const T_abs_tol_bwd & | absolute_tolerance_backward, | ||
double | relative_tolerance_quadrature, | ||
double | absolute_tolerance_quadrature, | ||
long int | max_num_steps, | ||
long int | num_steps_between_checkpoints, | ||
int | interpolation_polynomial, | ||
int | solver_forward, | ||
int | solver_backward, | ||
std::ostream * | msgs, | ||
const T_Args &... | args | ||
) |
Solve the ODE initial value problem y' = f(t, y), y(t0) = y0 at a set of times, { t1, t2, t3, ... } using the stiff backward differentiation formula BDF solver or the non-stiff Adams solver from CVODES.
The ODE system is integrated using the adjoint sensitivity approach of CVODES. This implementation handles the case of a double return type which ensures that no resources are left on the AD stack.
f
must define an operator() with the signature as: template<typename T_t, typename T_y, typename... T_Args> Eigen::Matrix<stan::return_type_t<T_t, T_y, T_Args...>, Eigen::Dynamic, 1> operator()(const T_t& t, const Eigen::Matrix<T_y, Eigen::Dynamic, 1>& y,
std::ostream* msgs, const T_Args&... args);
t is the time, y is the state, msgs is a stream for error messages, and args are optional arguments passed to the ODE solve function (which are passed through to f
without modification).
F | Type of ODE right hand side |
T_y0 | Type of initial state |
T_t0 | Type of initial time |
T_ts | Type of output times |
T_Args | Types of pass-through parameters |
function_name | Calling function name (for printing debugging messages) | |
f | Right hand side of the ODE | |
y0 | Initial state | |
t0 | Initial time | |
ts | Times at which to solve the ODE at. All values must be sorted and not less than t0. | |
relative_tolerance_forward | Relative tolerance for forward problem passed to CVODES | |
absolute_tolerance_forward | Absolute tolerance per ODE state for forward problem passed to CVODES | |
relative_tolerance_backward | Relative tolerance for backward problem passed to CVODES | |
absolute_tolerance_backward | Absolute tolerance per ODE state for backward problem passed to CVODES | |
relative_tolerance_quadrature | Relative tolerance for quadrature problem passed to CVODES | |
absolute_tolerance_quadrature | Absolute tolerance for quadrature problem passed to CVODES | |
max_num_steps | Upper limit on the number of integration steps to take between each output (error if exceeded) | |
num_steps_between_checkpoints | Number of integrator steps after which a checkpoint is stored for the backward pass | |
interpolation_polynomial | type of polynomial used for interpolation | |
solver_forward | solver used for forward pass | |
solver_backward | solver used for backward pass | |
[in,out] | msgs | the print stream for warning messages |
args | Extra arguments passed unmodified through to ODE right hand side |
std::vector
of Eigen column vectors with scalars equal to the least upper bound of T_y0
, T_t0
, T_ts
, and the lambda's arguments. This represents the solution to ODE at times ts
Definition at line 155 of file ode_adjoint.hpp.