FlowSimulation< FP, M > Class Template Reference

CPP API: mio::FlowSimulation< FP, M > Class Template Reference
mio::FlowSimulation< FP, M > Class Template Reference

A class for simulating a FlowModel. More...

#include <flow_simulation.h>

Inheritance diagram for mio::FlowSimulation< FP, M >:
Collaboration diagram for mio::FlowSimulation< FP, M >:

Public Types

using Base = details::FlowSimulationBase< FP, M, OdeIntegrator< FP > >
 
using Model = M
 
- Public Types inherited from mio::details::FlowSimulationBase< FP, M, OdeIntegrator< FP > >
using Base = SimulationBase< FP, M, Integrands... >
 
using Core = IntegratorCore< FP, Integrands... >
 
using Model = M
 
- Public Types inherited from mio::details::SimulationBase< FP, M, Integrands... >
using Core = IntegratorCore< FP, Integrands... >
 
using Model = M
 

Public Member Functions

Eigen::Ref< Eigen::VectorX< FP > > advance (FP tmax)
 Run the simulation up to a given time. More...
 
 FlowSimulation (Model const &model, FP t0=0., FP dt=0.1)
 Set up the simulation with an ODE solver. More...
 
- Public Member Functions inherited from mio::details::FlowSimulationBase< FP, M, OdeIntegrator< FP > >
 FlowSimulationBase (Model const &model, std::unique_ptr< Core > &&integrator_core, FP t0, FP dt)
 Create a FlowSimulationBase. More...
 
TimeSeries< FP > & get_flows ()
 Returns the simulation result describing the transitions between compartments for each time step. More...
 
const TimeSeries< FP > & get_flows () const
 Returns the simulation result describing the transitions between compartments for each time step. More...
 
- Public Member Functions inherited from mio::details::SimulationBase< FP, M, Integrands... >
SimulationBaseoperator= (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...
 
Coreget_integrator_core ()
 Access the IntegratorCore used in the simulation. More...
 
const Coreget_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 Modelget_model () const
 Get a reference to the model owned and used by the simulation. More...
 
Modelget_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...
 

Private Attributes

Eigen::VectorX< FP > m_pop
 pre-allocated temporary, used during computation of flow derivatives More...
 

Additional Inherited Members

- Protected Member Functions inherited from mio::details::FlowSimulationBase< FP, M, OdeIntegrator< FP > >
void compute_population_results ()
 Computes the distribution of the Population to the InfectionStates based on the simulated flows. More...
 
- Protected Member Functions inherited from mio::details::SimulationBase< FP, M, Integrands... >
Eigen::Ref< Eigen::VectorX< FP > > advance (const Integrands &... fs, FP tmax, TimeSeries< FP > &results)
 Run the simulation up to a given time. More...
 

Detailed Description

template<typename FP, IsFlowModel< FP > M>
class mio::FlowSimulation< FP, M >

A class for simulating a FlowModel.

Template Parameters
FPA floating point type, e.g. double.
MAn implementation of a FlowModel.

Member Typedef Documentation

◆ Base

template<typename FP , IsFlowModel< FP > M>
using mio::FlowSimulation< FP, M >::Base = details::FlowSimulationBase<FP, M, OdeIntegrator<FP> >

◆ Model

template<typename FP , IsFlowModel< FP > M>
using mio::FlowSimulation< FP, M >::Model = M

Constructor & Destructor Documentation

◆ FlowSimulation()

template<typename FP , IsFlowModel< FP > M>
mio::FlowSimulation< FP, M >::FlowSimulation ( Model const &  model,
FP  t0 = 0.,
FP  dt = 0.1 
)
inline

Set up the simulation with an ODE solver.

Parameters
[in]modelAn instance of a FlowModel.
[in]t0Start time.
[in]dtInitial step size of integration.

Member Function Documentation

◆ advance()

template<typename FP , IsFlowModel< FP > M>
Eigen::Ref<Eigen::VectorX<FP> > mio::FlowSimulation< FP, M >::advance ( FP  tmax)
inline

Run the simulation up to a given time.

The time tmax must be greater than get_result().get_last_time_point(), which is used as the starting point. The initial value is get_result().get_last_value().

Parameters
[in]tmaxNext stopping point of the simulation.
Returns
The simulation result at tmax.

Member Data Documentation

◆ m_pop

template<typename FP , IsFlowModel< FP > M>
Eigen::VectorX<FP> mio::FlowSimulation< FP, M >::m_pop
private

pre-allocated temporary, used during computation of flow derivatives