Drake
InitialValueProblem< T > Class Template Reference

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β‚€; 𝐀) = 𝐱₀. More...

#include <drake/systems/analysis/initial_value_problem.h>

Collaboration diagram for InitialValueProblem< T >:
[legend]

Classes

struct  SpecifiedValues
 A collection of values i.e. More...
 

Public Types

typedef std::function< VectorX< T > const T &t, const VectorX< T > &x, const VectorX< T > &k)> ODEFunction
 General ODE system d𝐱/dt = f(t, 𝐱; 𝐀) function type. More...
 

Public Member Functions

 InitialValueProblem (const ODEFunction &ode_function, const SpecifiedValues &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 SpecifiedValues &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...
 
template<typename Integrator , typename... Args>
Integratorreset_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 pointer to the internal integrator instance. More...
 
IntegratorBase< T > * get_mutable_integrator ()
 Gets a pointer to the internal mutable integrator instance. More...
 
Does not allow copy, move, or assignment
 InitialValueProblem (const InitialValueProblem &)=delete
 
InitialValueProblemoperator= (const InitialValueProblem &)=delete
 
 InitialValueProblem (InitialValueProblem &&)=delete
 
InitialValueProblemoperator= (InitialValueProblem &&)=delete
 

Static Public Attributes

static const T kDefaultAccuracy = static_cast<T>(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...
 

Detailed Description

template<typename T>
class drake::systems::InitialValueProblem< T >

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.

Additionally, this class' implementation 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.

For further insight into its use, consider the following examples:

  • The momentum 𝐩 of a particle of mass m that is traveling through a volume of a gas with dynamic viscosity ΞΌ can be described by d𝐩/dt = -ΞΌ * 𝐩/m. At time tβ‚€, the particle carries an initial momentum 𝐩₀. In this context, t is unused (the ODE is autonomous), 𝐱 β‰œ 𝐩, 𝐀 β‰œ [m, ΞΌ], tβ‚€ = 0, 𝐱₀ β‰œ 𝐩₀, d𝐱/dt = f(t, 𝐱; 𝐀) = -kβ‚‚ * 𝐱 / k₁.
  • The velocity 𝐯 of the same particle in the same exact conditions as before, but when a time varying force 𝐅(t) is applied to it, can be be described by d𝐯/dt = (𝐅(t) - ΞΌ * 𝐯) / m. In this context, 𝐱 β‰œ 𝐯, 𝐀 β‰œ [m, ΞΌ], 𝐱₀ β‰œ 𝐯₀, d𝐱/dt = f(t, 𝐱; 𝐀) = (𝐅(t) - kβ‚‚ * 𝐱) / k₁.
Template Parameters
TThe ℝ domain scalar type, which must be a valid Eigen scalar.
Note
Instantiated templates for the following scalar types T are provided:
  • double

Member Typedef Documentation

typedef std::function<VectorX<T> const T& t, const VectorX<T>& x, const VectorX<T>& k)> ODEFunction

General ODE system d𝐱/dt = f(t, 𝐱; 𝐀) function type.

Parameters
tThe independent scalar variable t ∈ ℝ.
xThe dependent vector variable 𝐱 ∈ ℝⁿ.
kThe vector of parameters 𝐀 ∈ ℝᡐ.
Returns
The derivative vector d𝐱/dt ∈ ℝⁿ.

Constructor & Destructor Documentation

InitialValueProblem ( const InitialValueProblem< T > &  )
delete

Here is the caller graph for this function:

InitialValueProblem ( const ODEFunction ode_function,
const SpecifiedValues 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.

Parameters
ode_functionThe ODE function f(t, 𝐱; 𝐀) that describes the state evolution over time.
default_valuesThe values specified by default for this IVP, i.e. default initial time tβ‚€ ∈ ℝ and state vector 𝐱₀ ∈ ℝⁿ, and default parameter vector 𝐀 ∈ ℝᡐ.
Precondition
An initial time default_values.t0 is given.
An initial state vector default_values.x0 is given.
A parameter vector default_values.k is given.
Exceptions
std::logic_errorif preconditions are not met.

Member Function Documentation

const IntegratorBase<T>* get_integrator ( ) const
inline

Gets a pointer to the internal integrator instance.

IntegratorBase<T>* get_mutable_integrator ( )
inline

Gets a pointer to the internal mutable integrator instance.

InitialValueProblem& operator= ( InitialValueProblem< T > &&  )
delete
InitialValueProblem& operator= ( const InitialValueProblem< T > &  )
delete
Integrator* reset_integrator ( Args &&...  args)
inline

Resets the internal integrator instance by in-place construction of the given integrator type.

A usage example is shown below.

ivp.reset_integrator<RungeKutta2Integrator<T>>(max_step);
Parameters
argsThe integrator type-specific arguments.
Returns
The new integrator instance.
Template Parameters
IntegratorThe integrator type, which must be an IntegratorBase subclass.
ArgsThe integrator specific argument types.
Warning
This operation invalidates pointers returned by InitialValueProblem::get_integrator() and InitialValueProblem::get_mutable_integrator().
VectorX< T > Solve ( const T &  tf,
const SpecifiedValues 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.

Parameters
tfThe time to solve the IVP for.
valuesThe specified values for the IVP.
Returns
The IVP solution 𝐱(tf; 𝐀) for 𝐱(tβ‚€; 𝐀) = 𝐱₀.
Precondition
Given tf must be larger than or equal to the specified initial time tβ‚€ (either given or default).
If given, the dimension of the initial state vector values.x0 must match that of the default initial state vector in the default specified values given on construction.
If given, the dimension of the parameter vector values.k must match that of the parameter vector in the default specified values given on construction.
Exceptions
std::logic_errorif preconditions are not met.

Here is the call graph for this function:

Member Data Documentation

const T kDefaultAccuracy = static_cast<T>(1e-4)
static

Default integration accuracy in the relative tolerance sense.

const T kInitialStepSize = static_cast<T>(1e-4)
static

Default initial integration step size.

const T kMaxStepSize = static_cast<T>(1e-1)
static

Default maximum integration step size.


The documentation for this class was generated from the following files: