FlowSimulationBase< FP, M, Integrands > Class Template Reference

CPP API: mio::details::FlowSimulationBase< FP, M, Integrands > Class Template Reference
mio::details::FlowSimulationBase< FP, M, Integrands > Class Template Reference

Base class to define a FlowSimulation. More...

#include <flow_simulation_base.h>

Inheritance diagram for mio::details::FlowSimulationBase< FP, M, Integrands >:
Collaboration diagram for mio::details::FlowSimulationBase< FP, M, Integrands >:

Public Types

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

 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...
 

Protected Member Functions

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...
 

Private Attributes

mio::TimeSeries< FP > m_flow_result
 Flow result of the simulation. More...
 

Detailed Description

template<typename FP, IsFlowModel< FP > M, class... Integrands>
class mio::details::FlowSimulationBase< FP, M, Integrands >

Base class to define a FlowSimulation.

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 FlowSimulation.

Template Parameters
FPA floating point type, e.g. double.
MAn implementation of FlowModel.
IntegrandsOne or more function types used for defining the right hand side of a system of equations.

Member Typedef Documentation

◆ Base

template<typename FP , IsFlowModel< FP > M, class... Integrands>
using mio::details::FlowSimulationBase< FP, M, Integrands >::Base = SimulationBase<FP, M, Integrands...>

◆ Core

template<typename FP , IsFlowModel< FP > M, class... Integrands>
using mio::details::FlowSimulationBase< FP, M, Integrands >::Core = IntegratorCore<FP, Integrands...>

◆ Model

template<typename FP , IsFlowModel< FP > M, class... Integrands>
using mio::details::FlowSimulationBase< FP, M, Integrands >::Model = M

Constructor & Destructor Documentation

◆ FlowSimulationBase()

template<typename FP , IsFlowModel< FP > M, class... Integrands>
mio::details::FlowSimulationBase< FP, M, Integrands >::FlowSimulationBase ( Model const &  model,
std::unique_ptr< Core > &&  integrator_core,
FP  t0,
FP  dt 
)
inline

Create a FlowSimulationBase.

Parameters
[in]modelAn instance of a FlowModel.
[in]integrator_coreA unique pointer to an object derived from IntegratorCore.
[in]t0Start time.
[in]dtInitial step size of integration.

Member Function Documentation

◆ compute_population_results()

template<typename FP , IsFlowModel< FP > M, class... Integrands>
void mio::details::FlowSimulationBase< FP, M, Integrands >::compute_population_results ( )
inlineprotected

Computes the distribution of the Population to the InfectionStates based on the simulated flows.

Uses the same method as the DerivFunction used in advance to compute the population given the flows and initial values. Adds time points to Base::m_result until it has the same number of time points as m_flow_result. Does not recalculate older values.

◆ get_flows() [1/2]

template<typename FP , IsFlowModel< FP > M, class... Integrands>
TimeSeries<FP>& mio::details::FlowSimulationBase< FP, M, Integrands >::get_flows ( )
inline

Returns the simulation result describing the transitions between compartments for each time step.

Which flows are used by the model is defined by the Flows template argument for the FlowModel. To get the correct index for the flow between two compartments use FlowModel::get_flat_flow_index.

Returns
A TimeSeries to represent a numerical solution for the flows in the model. For each simulated time step, the TimeSeries contains the value of each flow.

◆ get_flows() [2/2]

template<typename FP , IsFlowModel< FP > M, class... Integrands>
const TimeSeries<FP>& mio::details::FlowSimulationBase< FP, M, Integrands >::get_flows ( ) const
inline

Returns the simulation result describing the transitions between compartments for each time step.

Which flows are used by the model is defined by the Flows template argument for the FlowModel. To get the correct index for the flow between two compartments use FlowModel::get_flat_flow_index.

Returns
A TimeSeries to represent a numerical solution for the flows in the model. For each simulated time step, the TimeSeries contains the value of each flow.

Member Data Documentation

◆ m_flow_result

template<typename FP , IsFlowModel< FP > M, class... Integrands>
mio::TimeSeries<FP> mio::details::FlowSimulationBase< FP, M, Integrands >::m_flow_result
private

Flow result of the simulation.