8 #define SYMPLECTIC_ENABLED \ 9 template <size_t V, size_t P, size_t ST> \ 10 typename std::enable_if<(V > 0 && P > 0 && (V + P == ST)), void>::type 11 #define SYMPLECTIC_DISABLED \ 12 template <size_t V, size_t P, size_t ST> \ 13 typename std::enable_if<(V <= 0 || P <= 0 || (V + P != ST)), void>::type 18 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
24 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
37 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
52 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
57 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
64 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
72 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
79 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
86 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
95 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
103 integrator_ = std::shared_ptr<ct::core::Integrator<STATE_DIM, SCALAR>>(
106 initializeSymplecticIntegrator<V_DIM, P_DIM, STATE_DIM>();
110 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
114 cont_time_system_ = std::shared_ptr<ControlledSystem<STATE_DIM, CONTROL_DIM, SCALAR>>(dyn->clone());
120 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
143 integrateSymplectic<V_DIM, P_DIM, STATE_DIM>(stateNext, n *
dt_,
K_sim_,
dt_sim_);
152 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
160 std::shared_ptr<ct::core::IntegratorSymplecticEuler<P_DIM, V_DIM, CONTROL_DIM, SCALAR>>(
167 integratorRkSymplectic_ = std::shared_ptr<ct::core::IntegratorSymplecticRk<P_DIM, V_DIM, CONTROL_DIM, SCALAR>>(
174 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
180 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
185 const double& dt_sim)
const 188 throw std::runtime_error(
"Trying to integrate using symplectic integrator, but system is not symplectic.");
200 throw std::runtime_error(
"invalid symplectic integrator specified");
204 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
209 const double& dt_sim)
const 211 throw std::runtime_error(
"Symplectic integrator selected but invalid dimensions for it. Check V_DIM>1, P_DIM>1");
214 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
215 const std::shared_ptr<ct::core::StateVectorArray<STATE_DIM, SCALAR>>&
221 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR>
222 const std::shared_ptr<ct::core::ControlVectorArray<CONTROL_DIM, SCALAR>>&
232 #undef SYMPLECTIC_ENABLED 233 #undef SYMPLECTIC_DISABLED SCALAR dt_
the time discretization interval
Definition: SystemDiscretizer.h:157
#define SYMPLECTIC_DISABLED
Definition: SystemDiscretizer-impl.h:11
virtual ~SystemDiscretizer()
destructor
Definition: SystemDiscretizer-impl.h:53
SCALAR getSimulationTimestep()
compute the simulation timestep
Definition: SystemDiscretizer-impl.h:73
SYMPLECTIC_ENABLED integrateSymplectic(ct::core::StateVector< STATE_DIM, SCALAR > &x0, const double &t, const size_t &steps, const double &dt_sim) const
integrateSymplectic, gets instantiated if the system is symplectic
Definition: SystemDiscretizer-impl.h:181
void setIntegrationType(const ct::core::IntegrationType &integratorType)
update integration type
Definition: SystemDiscretizer-impl.h:80
A constant controller.
Definition: ConstantController.h:20
IntegratorSymplecticRkPtr integratorRkSymplectic_
an integrator for forward integrating a symplectic continuous-time system with symplectic RK methods ...
Definition: SystemDiscretizer.h:181
ct::core::IntegrationType integratorType_
the integration type for forward integration
Definition: SystemDiscretizer.h:166
IntegratorPtr integrator_
an integrator for forward integrating a general continuous-time system with standard RK methods ...
Definition: SystemDiscretizer.h:175
ContinuousSystemPtr cont_time_system_
the continuous-time system to be discretized
Definition: SystemDiscretizer.h:169
SCALAR dt_sim_
the integration sub-step size, which is a function of dt_ and K_sim_
Definition: SystemDiscretizer.h:163
virtual void propagateControlledDynamics(const StateVector< STATE_DIM, SCALAR > &state, const time_t n, const ControlVector< CONTROL_DIM, SCALAR > &control, StateVector< STATE_DIM, SCALAR > &stateNext) override
propagate discrete-time dynamics by performing a numerical forward integration of the continuous-time...
Definition: SystemDiscretizer-impl.h:121
clear all close all load ct GNMSLog0 mat reformat t
Event handler to record substeps.
Definition: SubstepRecorder.h:20
Discretize a general, continuous-time non-linear dynamic system using forward integration.
Definition: SystemDiscretizer.h:44
void initialize()
initialize class
Definition: SystemDiscretizer-impl.h:96
std::shared_ptr< ControlledSystem< STATE_DIM, CONTROL_DIM, SCALAR > > ContinuousSystemPtr
Definition: SystemDiscretizer.h:57
Definition: ControlVector.h:12
SubstepRecorderPtr substepRecorder_
substep recorder which logs all the substeps required for later computing exact sensitivities ...
Definition: SystemDiscretizer.h:184
void setParameters(const SCALAR &dt, const int &K_sim=1)
update parameters
Definition: SystemDiscretizer-impl.h:87
CppAD::AD< CppAD::cg::CG< double > > SCALAR
virtual SystemDiscretizer< STATE_DIM, CONTROL_DIM, P_DIM, V_DIM, SCALAR > * clone() const override
deep cloning
Definition: SystemDiscretizer-impl.h:66
void changeContinuousTimeSystem(ContinuousSystemPtr newSystem)
update the SystemDiscretizer with a new nonlinear, continuous-time system
Definition: SystemDiscretizer-impl.h:111
constexpr size_t n
Definition: MatrixInversionTest.cpp:14
#define SYMPLECTIC_ENABLED
Definition: SystemDiscretizer-impl.h:8
Definition: StateVector.h:12
Standard Integrator.
Definition: Integrator.h:62
int K_sim_
the forward simulation can be discretized finer than dt_. K_sim_ is an integer number representing th...
Definition: SystemDiscretizer.h:160
SystemDiscretizer()
default constructor
Definition: SystemDiscretizer-impl.h:19
ContinuousConstantControllerPtr cont_constant_controller_
the continuous-time constant controller to be applied to the continuous-time dynamics ...
Definition: SystemDiscretizer.h:172
Definition: Integrator.h:42
Definition: Integrator.h:41
This class wraps the symplectic integrators from boost to this toolbox.
Definition: IntegratorSymplectic.h:34
Base::time_t time_t
Definition: DiscreteControlledSystem.h:51
IntegratorSymplecticEulerPtr integratorEulerSymplectic_
an integrator for forward integrating a symplectic continuous-time system with symplectic Euler ...
Definition: SystemDiscretizer.h:178
StateVector< state_dim > x0
std::shared_ptr< ct::core::SubstepRecorder< STATE_DIM, CONTROL_DIM, SCALAR > > SubstepRecorderPtr
Definition: SystemDiscretizer.h:60
The base class for the implementation of a symplectic system. In a symplectic system, the position and the velocity update can be separated. During integration, the velocity gets update first and the position update uses the updated velocity.
Definition: SymplecticSystem.h:25
SYMPLECTIC_ENABLED initializeSymplecticIntegrator()
initialize the symplectic integrator, if the system is symplectic
Definition: SystemDiscretizer-impl.h:153
const StateVectorArrayPtr & getSubstates() const
return a pointer to the substates recorded during integration
Definition: SystemDiscretizer-impl.h:216
const ControlVectorArrayPtr & getSubcontrols() const
reuturn a pointer to the subcontrols recorded during integration
Definition: SystemDiscretizer-impl.h:223
IntegrationType
The available integration types.
Definition: Integrator.h:30