SimulationBase< FP, M, Integrands > Class Template Reference
|
CPP API
|
Base class to define a Simulation. More...
#include <simulation_base.h>
Public Types | |
| using | Core = IntegratorCore< FP, Integrands... > |
| using | Model = M |
Public Member Functions | |
| SimulationBase & | operator= (const SimulationBase &other) |
| void | set_integrator_core (std::unique_ptr< Core > &&integrator_core) |
| Set the IntegratorCore used in the simulation. More... | |
| SimulationBase (const SimulationBase &other) | |
| SimulationBase (Model const &model, std::unique_ptr< Core > &&integrator_core, FP t0, FP dt) | |
| Create a SimulationBase. More... | |
| Core & | get_integrator_core () |
| Access the IntegratorCore used in the simulation. More... | |
| const Core & | get_integrator_core () const |
| Access the IntegratorCore used in the simulation. More... | |
| TimeSeries< FP > & | get_result () |
| Returns the simulation result describing the model population in each time step. More... | |
| const TimeSeries< FP > & | get_result () const |
| Returns the simulation result describing the model population in each time step. More... | |
| const Model & | get_model () const |
| Get a reference to the model owned and used by the simulation. More... | |
| Model & | get_model () |
| Get a reference to the model owned and used by the simulation. More... | |
| FP & | get_dt () |
| Returns the step size used by the integrator. More... | |
| const FP & | get_dt () const |
| Returns the step size used by the integrator. More... | |
Protected Member Functions | |
| Eigen::Ref< Eigen::VectorX< FP > > | advance (const Integrands &... fs, FP tmax, TimeSeries< FP > &results) |
| Run the simulation up to a given time. More... | |
Private Attributes | |
| FP | m_dt |
| The time step used (and possibly set) by m_integrator::m_core::step. More... | |
| SystemIntegrator< FP, Integrands... > | m_integrator |
| Integrates the DerivFunction (see advance) and stores resutls in m_result. More... | |
| std::unique_ptr< Model > | m_model |
| The model defining the ODE system and initial conditions. More... | |
| TimeSeries< FP > | m_result |
| The simulation results. More... | |
Detailed Description
template<typename FP, IsCompartmentalModel< FP > M, class... Integrands>
class mio::details::SimulationBase< FP, M, Integrands >
Base class to define a Simulation.
Provides a protected advance method that accepts the specified integrands, that must be exposed by the Derived class. Also defines all relevant members and accessors for a Simulation.
- Template Parameters
-
FP A floating point type, e.g. double. M An implementation of CompartmentalModel. Integrands One or more function types used for defining the right hand side of a system of equations.
Member Typedef Documentation
◆ Core
| using mio::details::SimulationBase< FP, M, Integrands >::Core = IntegratorCore<FP, Integrands...> |
◆ Model
| using mio::details::SimulationBase< FP, M, Integrands >::Model = M |
Constructor & Destructor Documentation
◆ SimulationBase() [1/2]
|
inline |
Create a SimulationBase.
- Parameters
-
[in] model An instance of a compartmental model [in] integrator_core A unique pointer to an object derived from IntegratorCore. [in] t0 Start time. [in] dt Initial step size of integration
◆ SimulationBase() [2/2]
|
inline |
Member Function Documentation
◆ advance()
|
inlineprotected |
Run the simulation up to a given time.
- Parameters
-
[in] fs Integrands passed to the integrator, e.g. a wrapper for get_derivatives.[in] tmax Next stopping point of the simulation. [in,out] results The TimeSeries to use as initial value and for storing integration results.
- Returns
- The simulation result at tmax.
◆ get_dt() [1/2]
|
inline |
Returns the step size used by the integrator.
When using a integration scheme with adaptive time stepping, the integrator will store its estimate for the next step size in this value.
◆ get_dt() [2/2]
|
inline |
Returns the step size used by the integrator.
When using a integration scheme with adaptive time stepping, the integrator will store its estimate for the next step size in this value.
◆ get_integrator_core() [1/2]
|
inline |
Access the IntegratorCore used in the simulation.
- Returns
- A reference to the IntegratorCore used in the simulation
◆ get_integrator_core() [2/2]
|
inline |
Access the IntegratorCore used in the simulation.
- Returns
- A reference to the IntegratorCore used in the simulation
◆ get_model() [1/2]
|
inline |
Get a reference to the model owned and used by the simulation.
- Returns
- The simulation model.
◆ get_model() [2/2]
|
inline |
Get a reference to the model owned and used by the simulation.
- Returns
- The simulation model.
◆ get_result() [1/2]
|
inline |
Returns the simulation result describing the model population in each time step.
Which compartments are used by the model is defined by the Comp template argument for the CompartmentalModel (usually an enum named InfectionState).
- Returns
- A TimeSeries to represent a numerical solution for the population of the model. For each simulated time step, the TimeSeries contains the population size in each compartment.
◆ get_result() [2/2]
|
inline |
Returns the simulation result describing the model population in each time step.
Which compartments are used by the model is defined by the Comp template argument for the CompartmentalModel (usually an enum named InfectionState).
- Returns
- A TimeSeries to represent a numerical solution for the population of the model. For each simulated time step, the TimeSeries contains the population size in each compartment.
◆ operator=()
|
inline |
◆ set_integrator_core()
|
inline |
Set the IntegratorCore used in the simulation.
- Parameters
-
[in] integrator_core A unique pointer to an object derived from IntegratorCore.
Member Data Documentation
◆ m_dt
|
private |
The time step used (and possibly set) by m_integrator::m_core::step.
◆ m_integrator
|
private |
Integrates the DerivFunction (see advance) and stores resutls in m_result.
◆ m_model
|
private |
The model defining the ODE system and initial conditions.
◆ m_result
|
private |
The simulation results.
Generated by