Simulation< Implementation > Class Template Reference

CPP API: mio::dabm::Simulation< Implementation > Class Template Reference
mio::dabm::Simulation< Implementation > Class Template Reference

A specialized Simulation for mio::dabm::Model. More...

#include <simulation.h>

Collaboration diagram for mio::dabm::Simulation< Implementation >:

Classes

struct  Event
 Struct defining an adoption event for an agent and target infection state. More...
 

Public Types

using Model = dabm::Model< Implementation >
 

Public Member Functions

void advance (const ScalarType t_max)
 Advance simulation to tmax. More...
 
Modelget_model ()
 
const Modelget_model () const
 Returns the model used in the simulation. More...
 
TimeSeries< ScalarType > & get_result ()
 Returns the final simulation result. More...
 
const TimeSeries< ScalarType > & get_result () const
 
 Simulation (const Model &model, ScalarType t0=0, ScalarType dt=0.1)
 Set up the simulation for a diffusive ABM. More...
 

Private Types

using Status = typename Implementation::Status
 

Private Member Functions

void compute_current_rates_and_events ()
 Calculate current values for m_current_rates and m_current_events. More...
 

Private Attributes

std::vector< Eventm_current_events
 Contains an event corresponding to each rate in m_current_rates. More...
 
std::vector< ScalarTypem_current_rates
 Current adoption rates. More...
 
ScalarType m_dt
 Start time of the simulation and integration step size. More...
 
std::unique_ptr< Modelm_model
 Pointer to the model used in the simulation. More...
 
mio::TimeSeries< ScalarTypem_result
 Result time series. More...
 
ScalarType m_t0
 

Detailed Description

template<class Implementation>
class mio::dabm::Simulation< Implementation >

A specialized Simulation for mio::dabm::Model.

Template Parameters
ImplementationA class implementing all functions and types marked with the using keyword in Model, see dabm::Model.

Member Typedef Documentation

◆ Model

template<class Implementation >
using mio::dabm::Simulation< Implementation >::Model = dabm::Model<Implementation>

◆ Status

template<class Implementation >
using mio::dabm::Simulation< Implementation >::Status = typename Implementation::Status
private

Constructor & Destructor Documentation

◆ Simulation()

template<class Implementation >
mio::dabm::Simulation< Implementation >::Simulation ( const Model model,
ScalarType  t0 = 0,
ScalarType  dt = 0.1 
)
inline

Set up the simulation for a diffusive ABM.

Parameters
[in]modelAn instance of mio::dabm::Model.
[in]t0Start time.
[in]dtStep size of integration.

Member Function Documentation

◆ advance()

template<class Implementation >
void mio::dabm::Simulation< Implementation >::advance ( const ScalarType  t_max)
inline

Advance simulation to tmax.

This function performs a temporal Gillespie.

Parameters
tmaxNext stopping point of simulation.

◆ compute_current_rates_and_events()

template<class Implementation >
void mio::dabm::Simulation< Implementation >::compute_current_rates_and_events ( )
inlineprivate

Calculate current values for m_current_rates and m_current_events.

◆ get_model() [1/2]

template<class Implementation >
Model& mio::dabm::Simulation< Implementation >::get_model ( )
inline

◆ get_model() [2/2]

template<class Implementation >
const Model& mio::dabm::Simulation< Implementation >::get_model ( ) const
inline

Returns the model used in the simulation.

◆ get_result() [1/2]

template<class Implementation >
TimeSeries<ScalarType>& mio::dabm::Simulation< Implementation >::get_result ( )
inline

Returns the final simulation result.

Returns
A TimeSeries to represent the final simulation result.

◆ get_result() [2/2]

template<class Implementation >
const TimeSeries<ScalarType>& mio::dabm::Simulation< Implementation >::get_result ( ) const
inline

Member Data Documentation

◆ m_current_events

template<class Implementation >
std::vector<Event> mio::dabm::Simulation< Implementation >::m_current_events
private

Contains an event corresponding to each rate in m_current_rates.

◆ m_current_rates

template<class Implementation >
std::vector<ScalarType> mio::dabm::Simulation< Implementation >::m_current_rates
private

Current adoption rates.

◆ m_dt

template<class Implementation >
ScalarType mio::dabm::Simulation< Implementation >::m_dt
private

Start time of the simulation and integration step size.

◆ m_model

template<class Implementation >
std::unique_ptr<Model> mio::dabm::Simulation< Implementation >::m_model
private

Pointer to the model used in the simulation.

◆ m_result

template<class Implementation >
mio::TimeSeries<ScalarType> mio::dabm::Simulation< Implementation >::m_result
private

Result time series.

◆ m_t0

template<class Implementation >
ScalarType mio::dabm::Simulation< Implementation >::m_t0
private