maliput
|
A general initial value problem (or IVP) representation class, that allows evaluating the ๐ฑ(t; ๐ค) solution function to the given ODE d๐ฑ/dt = f(t, ๐ฑ; ๐ค), where f : t โจฏ ๐ฑ โ โโฟ, t โ โ, ๐ฑ โ โโฟ, ๐ค โ โแต, provided an initial condition ๐ฑ(tโ; ๐ค) = ๐ฑโ.
The parameter vector ๐ค allows for generic IVP definitions, which can later be solved for any instance of said vector.
By default, an explicit 3rd order RungeKutta integration scheme is used.
The implementation of this class performs basic computation caching, optimizing away repeated integration whenever the IVP is solved for increasing values of time t while both initial conditions and parameters are kept constant, e.g. if solved for tโ > tโ first, solving for tโ > tโ will only require integrating from tโ onward.
Additionally, IntegratorBase's dense output support can be leveraged to efficiently approximate the IVP solution within closed intervals of t. This is convenient when there's a need for a more dense sampling of the IVP solution than what would be available through either fixed or error-controlled step integration (for a given accuracy), or when the IVP is to be solved repeatedly for arbitrarily many t values within a given interval. See documentation of the internally held IntegratorBase subclass instance (either the default or a user-defined one, set via reset_integrator()) for further reference on the specific dense output technique in use.
For further insight into its use, consider the following examples:
@tparam_nonsymbolic_scalar
#include <src/maliput/drake/systems/analysis/initial_value_problem.h>
Classes | |
struct | OdeContext |
A collection of values i.e. More... | |
Public Types | |
using | OdeFunction = std::function< VectorX< T >(const T &t, const VectorX< T > &x, const VectorX< T > &k)> |
General ODE system d๐ฑ/dt = f(t, ๐ฑ; ๐ค) function type. More... | |
Public Member Functions | |
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN (InitialValueProblem) | |
InitialValueProblem (const OdeFunction &ode_function, const OdeContext &default_values) | |
Constructs an IVP described by the given ode_function , using given default_values.t0 and default_values.x0 as initial conditions, and parameterized with default_values.k by default. More... | |
VectorX< T > | Solve (const T &tf, const OdeContext &values={}) const |
Solves the IVP for time tf , using the initial time tโ, initial state vector ๐ฑโ and parameter vector ๐ค present in values , falling back to the ones given on construction if not given. More... | |
std::unique_ptr< DenseOutput< T > > | DenseSolve (const T &tf, const OdeContext &values={}) const |
Solves and yields an approximation of the IVP solution x(t; ๐ค) for the closed time interval between the initial time tโ and the given final time tf , using initial state ๐ฑโ and parameter vector ๐ค present in values (falling back to the ones given on construction if not given). 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... | |
Static Public Attributes | |
static const double | kDefaultAccuracy = 1e-4 |
Default integration accuracy in the relative tolerance sense. More... | |
static const T | kInitialStepSize = static_cast<T>(1e-4) |
Default initial integration step size. More... | |
static const T | kMaxStepSize = static_cast<T>(1e-1) |
Default maximum integration step size. More... | |
using OdeFunction = std::function<VectorX<T>(const T& t, const VectorX<T>& x, const VectorX<T>& k)> |
General ODE system d๐ฑ/dt = f(t, ๐ฑ; ๐ค) function type.
t | The independent scalar variable t โ โ. |
x | The dependent vector variable ๐ฑ โ โโฟ. |
k | The vector of parameters ๐ค โ โแต. |
InitialValueProblem | ( | const OdeFunction & | ode_function, |
const OdeContext & | default_values | ||
) |
Constructs an IVP described by the given ode_function
, using given default_values.t0
and default_values.x0
as initial conditions, and parameterized with default_values.k
by default.
ode_function | The ODE function f(t, ๐ฑ; ๐ค) that describes the state evolution over time. |
default_values | The values specified by default for this IVP, i.e. default initial time tโ โ โ and state vector ๐ฑโ โ โโฟ, and default parameter vector ๐ค โ โแต. |
default_values.t0
is given. default_values.x0
is given. default_values.k
is given. std::exception | if preconditions are not met. |
std::unique_ptr< DenseOutput< T > > DenseSolve | ( | const T & | tf, |
const OdeContext & | values = {} |
||
) | const |
Solves and yields an approximation of the IVP solution x(t; ๐ค) for the closed time interval between the initial time tโ and the given final time tf
, using initial state ๐ฑโ and parameter vector ๐ค present in values
(falling back to the ones given on construction if not given).
To this end, the wrapped IntegratorBase instance solves this IVP, advancing time and state from tโ and ๐ฑโ = ๐ฑ(tโ) to tf
and ๐ฑ(tf
), creating a dense output over that [tโ, tf
] interval along the way.
tf | The IVP will be solved up to this time. Usually, tโ < tf as an empty dense output would result if tโ = tf . |
values | IVP initial conditions and parameters. |
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. tf
must be larger than or equal to the specified initial time tโ (either given or default). values.x0
must match that of the default initial state vector in the default specified values given on construction. values.k
must match that of the parameter vector in the default specified values given on construction. std::exception | if any of the preconditions is not met. |
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN | ( | InitialValueProblem< T > | ) |
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.
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. |
VectorX< T > Solve | ( | const T & | tf, |
const OdeContext & | values = {} |
||
) | const |
Solves the IVP for time tf
, using the initial time tโ, initial state vector ๐ฑโ and parameter vector ๐ค present in values
, falling back to the ones given on construction if not given.
tf | The IVP will be solved for this time. |
values | IVP initial conditions and parameters. |
tf
; ๐ค) for ๐ฑ(tโ; ๐ค) = ๐ฑโ. tf
must be larger than or equal to the specified initial time tโ (either given or default). values.x0
must match that of the default initial state vector in the default specified values given on construction. values.k
must match that of the parameter vector in the default specified values given on construction. std::exception | if preconditions are not met. |
|
static |
Default integration accuracy in the relative tolerance sense.
|
static |
Default initial integration step size.
|
static |
Default maximum integration step size.