12 template <
size_t STATE_DIM,
typename SCALAR>
16 : system_(system), observer_(eventHandlers)
22 template <
size_t STATE_DIM,
typename SCALAR>
32 template <
size_t STATE_DIM,
typename SCALAR>
35 initializeCTSteppers(intType);
36 initializeAdaptiveSteppers(intType);
37 initializeODEIntSteppers(intType);
38 if (!integratorStepper_)
39 throw std::runtime_error(
"Unknown integration type");
43 template <
size_t STATE_DIM,
typename SCALAR>
46 integratorStepper_->setAdaptiveErrorTolerances(absErrTol, relErrTol);
49 template <
size_t STATE_DIM,
typename SCALAR>
58 integratorStepper_->integrate_n_steps(
59 observer_.observeWrapWithLogging, systemFunction_, state, startTime, numSteps, dt);
60 retrieveTrajectoriesFromObserver(stateTrajectory, timeTrajectory);
63 template <
size_t STATE_DIM,
typename SCALAR>
70 integratorStepper_->integrate_n_steps(observer_.observeWrap, systemFunction_, state, startTime, numSteps, dt);
73 template <
size_t STATE_DIM,
typename SCALAR>
82 integratorStepper_->integrate_const(
83 observer_.observeWrapWithLogging, systemFunction_, state, startTime, finalTime, dt);
84 retrieveTrajectoriesFromObserver(stateTrajectory, timeTrajectory);
87 template <
size_t STATE_DIM,
typename SCALAR>
94 integratorStepper_->integrate_const(observer_.observeWrap, systemFunction_, state, startTime, finalTime, dt);
97 template <
size_t STATE_DIM,
typename SCALAR>
106 integratorStepper_->integrate_adaptive(
107 observer_.observeWrapWithLogging, systemFunction_, state, startTime, finalTime, dtInitial);
108 retrieveTrajectoriesFromObserver(stateTrajectory, timeTrajectory);
109 state = stateTrajectory.back();
112 template <
size_t STATE_DIM,
typename SCALAR>
119 integratorStepper_->integrate_adaptive(
120 observer_.observeWrap, systemFunction_, state, startTime, finalTime, dtInitial);
123 template <
size_t STATE_DIM,
typename SCALAR>
130 integratorStepper_->integrate_times(
131 observer_.observeWrapWithLogging, systemFunction_, state, timeTrajectory, dtInitial);
132 retrieveStateVectorArrayFromObserver(stateTrajectory);
136 template <
size_t STATE_DIM,
typename SCALAR>
143 integratorStepper_ = std::shared_ptr<internal::StepperEulerCT<Eigen::Matrix<SCALAR, STATE_DIM, 1>,
SCALAR>>(
150 integratorStepper_ = std::shared_ptr<internal::StepperRK4CT<Eigen::Matrix<SCALAR, STATE_DIM, 1>,
SCALAR>>(
160 template <
size_t STATE_DIM,
typename SCALAR>
166 template <
size_t STATE_DIM,
typename SCALAR>
171 stateTrajectory.
swap(observer_.states_);
172 timeTrajectory.
swap(observer_.times_);
175 template <
size_t STATE_DIM,
typename SCALAR>
179 stateTrajectory.
swap(observer_.states_);
183 template <
size_t STATE_DIM,
typename SCALAR>
186 systemFunction_ = [
this](
187 const Eigen::Matrix<SCALAR, STATE_DIM, 1>&
x, Eigen::Matrix<SCALAR, STATE_DIM, 1>& dxdt,
SCALAR t) {
190 system_->computeDynamics(xState,
t, dxdtState);
191 observer_.observeInternal(xState,
t);
An discrete array (vector) of a particular data type.
Definition: DiscreteArray.h:22
void integrate_n_steps(StateVector< STATE_DIM, SCALAR > &state, const SCALAR &startTime, size_t numSteps, SCALAR dt, StateVectorArray< STATE_DIM, SCALAR > &stateTrajectory, tpl::TimeArray< SCALAR > &timeTrajectory)
Equidistant integration based on number of time steps and step length.
Definition: Integrator-impl.h:50
std::vector< EventHandlerPtr, Eigen::aligned_allocator< EventHandlerPtr > > EventHandlerPtrVector
Definition: Integrator.h:67
void integrate_adaptive(StateVector< STATE_DIM, SCALAR > &state, const SCALAR &startTime, const SCALAR &finalTime, StateVectorArray< STATE_DIM, SCALAR > &stateTrajectory, tpl::TimeArray< SCALAR > &timeTrajectory, const SCALAR dtInitial=SCALAR(0.01))
integrate forward from an initial to a final time using an adaptive scheme
Definition: Integrator-impl.h:98
Custom implementation of the euler stepper.
Definition: SteppersCT.h:81
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef std::shared_ptr< EventHandler< STATE_DIM, SCALAR > > EventHandlerPtr
Definition: Integrator.h:66
clear all close all load ct GNMSLog0 mat reformat t
void changeIntegrationType(const IntegrationType &intType)
Changes the integration type.
Definition: Integrator-impl.h:33
CppAD::AD< CppAD::cg::CG< double > > SCALAR
void integrate_times(StateVector< STATE_DIM, SCALAR > &state, const tpl::TimeArray< SCALAR > &timeTrajectory, StateVectorArray< STATE_DIM, SCALAR > &stateTrajectory, SCALAR dtInitial=SCALAR(0.01))
Integrate system using a given time trajectory.
Definition: Integrator-impl.h:124
Definition: StateVector.h:12
Standard Integrator.
Definition: Integrator.h:62
Definition: Integrator.h:39
ct::core::StateVector< state_dim > x
An array in time.
Definition: TimeArray.h:22
void integrate_const(StateVector< STATE_DIM, SCALAR > &state, const SCALAR &startTime, const SCALAR &finalTime, SCALAR dt, StateVectorArray< STATE_DIM, SCALAR > &stateTrajectory, tpl::TimeArray< SCALAR > &timeTrajectory)
Equidistant integration based on initial and final time as well as step length.
Definition: Integrator-impl.h:74
Interface class for a general system described by an ordinary differential equation (ODE) ...
Definition: System.h:38
Custom implementation of the rk4 integration scheme.
Definition: SteppersCT.h:107
Definition: Integrator.h:40
void setApadativeErrorTolerances(const SCALAR absErrTol, const SCALAR &relErrTol)
Sets the adaptive error tolerances.
Definition: Integrator-impl.h:44
void swap(DiscreteArray &other)
swaps the content of two arrays
Definition: DiscreteArray.h:84
IntegrationType
The available integration types.
Definition: Integrator.h:30
Integrator(const std::shared_ptr< System< STATE_DIM, SCALAR >> &system, const IntegrationType &intType=IntegrationType::EULERCT, const EventHandlerPtrVector &eventHandlers=EventHandlerPtrVector(0))
constructor
Definition: Integrator-impl.h:13