A thin wrapper of the InitialValueProblem class to provide a simple interface when solving scalar initial value problems i.e.
when evaluating the x(t; π€) solution function to the given ODE dx/dt = f(t, x; π€), where f : t β¨― x β β , t β β, x β β, π€ β βα΅, along with an initial condition x(tβ; π€) = xβ. The parameter vector π€ allows for generic IVP definitions, which can later be solved for any instance of said vector.
Note the distinction from general initial value problems where f : t β¨― π± β ββΏ and π± β ββΏ, addressed by the class being wrapped. While every scalar initial value problem could be written in vector form, this wrapper keeps both problem definition and solution in their scalar form with almost zero overhead, leading to clearer code if applicable. Moreover, this scalar form facilitates single-dimensional quadrature using methods for solving initial value problems.
See InitialValueProblem class documentation for information on caching support and dense output usage for improved efficiency in scalar IVP solving.
For further insight into its use, consider the following examples of scalar IVPs:
T | The scalar type, which must be one of the default nonsymbolic scalars. |
#include <drake/systems/analysis/scalar_initial_value_problem.h>
Public Types | |
using | ScalarOdeFunction = std::function< T(const T &t, const T &x, const VectorX< T > &k)> |
Scalar ODE dx/dt = f(t, x; π€) function type. More... | |
Public Member Functions | |
ScalarInitialValueProblem (const ScalarOdeFunction &scalar_ode_function, const T &x0, const Eigen::Ref< const VectorX< T >> &k=Vector0< T >{}) | |
Constructs a scalar IVP described by the given scalar_ode_function , using given x0 as initial conditions, and parameterized with k . More... | |
T | Solve (const T &t0, const T &tf) const |
Solves the IVP from time t0 up to time tf , using the initial state π±β and parameter vector π€ provided in the constructor. More... | |
std::unique_ptr< ScalarDenseOutput< T > > | DenseSolve (const T &t0, const T &tf) const |
Solves and yields an approximation of the IVP solution x(t; π€) for the closed time interval between the initial time t0 and the final time tf , using initial state π±β and parameter vector π€ provided in the constructor. More... | |
template<typename Integrator , typename... Args> | |
Integrator * | reset_integrator (Args &&... args) |
Resets the internal integrator instance by in-place construction of the given integrator type. More... | |
const IntegratorBase< T > & | get_integrator () const |
Gets a reference to the internal integrator instance. More... | |
IntegratorBase< T > & | get_mutable_integrator () |
Gets a mutable reference to the internal integrator instance. More... | |
Does not allow copy, move, or assignment | |
ScalarInitialValueProblem (const ScalarInitialValueProblem &)=delete | |
ScalarInitialValueProblem & | operator= (const ScalarInitialValueProblem &)=delete |
ScalarInitialValueProblem (ScalarInitialValueProblem &&)=delete | |
ScalarInitialValueProblem & | operator= (ScalarInitialValueProblem &&)=delete |
using ScalarOdeFunction = std::function<T(const T& t, const T& x, const VectorX<T>& k)> |
Scalar ODE dx/dt = f(t, x; π€) function type.
t | The independent variable t β β . |
x | The dependent variable x β β . |
k | The parameter vector π€ β βα΅. |
|
delete |
|
delete |
ScalarInitialValueProblem | ( | const ScalarOdeFunction & | scalar_ode_function, |
const T & | x0, | ||
const Eigen::Ref< const VectorX< T >> & | k = Vector0< T >{} |
||
) |
Constructs a scalar IVP described by the given scalar_ode_function
, using given x0
as initial conditions, and parameterized with k
.
scalar_ode_function | The ODE function f(t, π±; π€) that describes the state evolution over time. |
x0 | The initial state π±β β β. |
k | The parameter vector π€ β βα΅. By default m=0 (no parameters). |
std::unique_ptr<ScalarDenseOutput<T> > DenseSolve | ( | const T & | t0, |
const T & | tf | ||
) | const |
Solves and yields an approximation of the IVP solution x(t; π€) for the closed time interval between the initial time t0
and the final time tf
, using initial state π±β and parameter vector π€ provided in the constructor.
To this end, the wrapped IntegratorBase instance solves this IVP, advancing time and state from tβ and π±β = π±(t0
) to tf
and π±(tf
), creating a dense output over that [t0
, tf
] interval along the way.
tf | The IVP will be solved up to this time, which must be β₯ t0 . Usually, t0 < tf as an empty dense output would result if t0 = tf . |
tf
value is, the larger the approximated interval will be. See documentation of the specific dense output technique in use for reference on performance impact as this interval grows. std::exception | if t0 > tf. |
const IntegratorBase<T>& get_integrator | ( | ) | const |
Gets a reference to the internal integrator instance.
IntegratorBase<T>& get_mutable_integrator | ( | ) |
Gets a mutable reference to the internal integrator instance.
|
delete |
|
delete |
Integrator* reset_integrator | ( | Args &&... | args | ) |
Resets the internal integrator instance by in-place construction of the given integrator type.
A usage example is shown below.
args | The integrator type-specific arguments. |
Integrator | The integrator type, which must be an IntegratorBase subclass. |
Args | The integrator specific argument types. |
T Solve | ( | const T & | t0, |
const T & | tf | ||
) | const |
Solves the IVP from time t0
up to time tf
, using the initial state π±β and parameter vector π€ provided in the constructor.
std::exception | if t0 > tf. |