Initializer< FP, Model > Class Template Reference

CPP API: mio::lsecir::Initializer< FP, Model > Class Template Reference
mio::lsecir::Initializer< FP, Model > Class Template Reference

Class that can be used to compute an initialization vector out of flows for an LCT Model with division in groups. More...

#include <initializer_flows.h>

Collaboration diagram for mio::lsecir::Initializer< FP, Model >:

Public Types

using LctStatesGroups = typename Model::LctStatesGroups
 

Public Member Functions

bool compute_initialization_vector (Eigen::VectorX< FP > const &total_population, Eigen::VectorX< FP > const &deaths, Eigen::VectorX< FP > const &total_confirmed_cases)
 Core function of Initializer. More...
 
 Initializer (TimeSeries< FP > &&flows, Model &model)
 Constructs a new Initializer object. More...
 
void set_tol_for_support_max (FP new_tol)
 Setter for the tolerance used to calculate the maximum support of ErlangDensitys. More...
 

Private Member Functions

bool check_constraints () const
 Checks constraints of the Initializer including checks for the model. More...
 
template<InfectionState State, size_t Group>
bool compute_compartment (Eigen::VectorX< FP > &init, Eigen::Index idx_incoming_flow, FP transition_rate) const
 Computes a slice of the initial value vector for each subcompartment of one InfectionState for a specified group. More...
 
template<size_t Group = 0>
bool compute_initialization_vector_impl (Eigen::VectorX< FP > &init, Eigen::VectorX< FP > const &total_population, Eigen::VectorX< FP > const &deaths, Eigen::VectorX< FP > const &total_confirmed_cases)
 Implementation of the calculation of the initial value vector slice that corresponds to a specified group. More...
 

Private Attributes

FP m_dt {}
 Step size of the times in m_flows and time step for the approximation of the integral. More...
 
TimeSeries< FP > m_flows
 TimeSeries with the flows which are used to calculate the initial vector. More...
 
Modelm_model
 The LCT-SECIR model for which the initialization should be performed. More...
 
FP m_tol {1e-10}
 Tolerance used to calculate the maximum support of the ErlangDensitys. More...
 

Detailed Description

template<typename FP, typename Model>
class mio::lsecir::Initializer< FP, Model >

Class that can be used to compute an initialization vector out of flows for an LCT Model with division in groups.

The initialization method is based on the fact that the LCT model is a special case of an IDE model with special choices of stay time distributions (so-called Erlang distributions). Accordingly, the method for calculating initial values for the compartments from given flows/transitions is taken from the IDE-SECIR model. We cannot use the functionality of the IDE model directly, as we have to calculate a division into sub-compartments and not only the sizes of the compartments. See also the IDE-SECIR model for the general method and for a better understanding of flows/transitions.

Template Parameters
Modelis expected to be an LCT-SECIR model defined in models/lct_secir/model.h.

Member Typedef Documentation

◆ LctStatesGroups

template<typename FP , typename Model >
using mio::lsecir::Initializer< FP, Model >::LctStatesGroups = typename Model::LctStatesGroups

Constructor & Destructor Documentation

◆ Initializer()

template<typename FP , typename Model >
mio::lsecir::Initializer< FP, Model >::Initializer ( TimeSeries< FP > &&  flows,
Model model 
)
inline

Constructs a new Initializer object.

Parameters
[in]flowsInitializing TimeSeries with flows fitting to these defined in InfectionTransition. For each group of m_model, InfectionTransition::Count entries are required. Timesteps should be equidistant and the values should be non-negative. The time history has to be long enough so that it is possible to calculate the initial vector. The length of the required time history depends on the Erlang densities used to compute the initial vector.
[in,out]modelThe LCT-SECIR model for which the initialization should be performed.

Member Function Documentation

◆ check_constraints()

template<typename FP , typename Model >
bool mio::lsecir::Initializer< FP, Model >::check_constraints ( ) const
inlineprivate

Checks constraints of the Initializer including checks for the model.

Returns
Returns true if one (or more) constraint(s) are not satisfied, otherwise false.

◆ compute_compartment()

template<typename FP , typename Model >
template<InfectionState State, size_t Group>
bool mio::lsecir::Initializer< FP, Model >::compute_compartment ( Eigen::VectorX< FP > &  init,
Eigen::Index  idx_incoming_flow,
FP  transition_rate 
) const
inlineprivate

Computes a slice of the initial value vector for each subcompartment of one InfectionState for a specified group.

Template Parameters
GroupThe group for which the corresponding slice of the initial value vector is calculated.
StateThe InfectionState for which the corresponding slice of the initial value vector is calculated
Parameters
[out]initThe initial value vector under consideration.
[in]idx_incoming_flowIndex of the flow which is relevant for the calculation, so the flow to the InfectionState.
[in]transition_rateSpecifies the transition rate of the InfectionState. 'This is equal to 1 / (expected time in the InfectionState).
Returns
Returns true if one (or more) constraint(s) of the computed slice of the initial value vector are not satisfied, otherwise false.

◆ compute_initialization_vector()

template<typename FP , typename Model >
bool mio::lsecir::Initializer< FP, Model >::compute_initialization_vector ( Eigen::VectorX< FP > const &  total_population,
Eigen::VectorX< FP > const &  deaths,
Eigen::VectorX< FP > const &  total_confirmed_cases 
)
inline

Core function of Initializer.

Computes a vector that can be used for the initialization of an LCT model stratified by groups with the number of persons for each subcompartment for each group. The initial value vector is updated in the model.

Parameters
[in]total_populationThe total size of the considered population.
[in]deathsNumber of deceased people from the disease at time 0.
[in]total_confirmed_casesTotal number of confirmed cases at time 0.
Returns
Returns true if one (or more) constraint(s) of the model, the initial flows or the computed initial value vector are not satisfied, otherwise false.

◆ compute_initialization_vector_impl()

template<typename FP , typename Model >
template<size_t Group = 0>
bool mio::lsecir::Initializer< FP, Model >::compute_initialization_vector_impl ( Eigen::VectorX< FP > &  init,
Eigen::VectorX< FP > const &  total_population,
Eigen::VectorX< FP > const &  deaths,
Eigen::VectorX< FP > const &  total_confirmed_cases 
)
inlineprivate

Implementation of the calculation of the initial value vector slice that corresponds to a specified group.

Computes a vector that can be used for the initialization of an LCT model stratified by groups with the number of persons for each subcompartment. The groups are calculated recursively.

Template Parameters
GroupThe group for which the corresponding slice of the initial value vector is calculated.
Parameters
[out]initThe initial value vector under consideration.
[in]total_populationThe total size of the considered population.
[in]deathsNumber of deceased people from the disease at time 0.
[in]total_confirmed_casesTotal number of confirmed cases at time 0.
Returns
Returns true if one (or more) constraint(s) of the computed initial value vector are not satisfied, otherwise false.

◆ set_tol_for_support_max()

template<typename FP , typename Model >
void mio::lsecir::Initializer< FP, Model >::set_tol_for_support_max ( FP  new_tol)
inline

Setter for the tolerance used to calculate the maximum support of ErlangDensitys.

Parameters
[in]new_tolNew tolerance.

Member Data Documentation

◆ m_dt

template<typename FP , typename Model >
FP mio::lsecir::Initializer< FP, Model >::m_dt {}
private

Step size of the times in m_flows and time step for the approximation of the integral.

◆ m_flows

template<typename FP , typename Model >
TimeSeries<FP> mio::lsecir::Initializer< FP, Model >::m_flows
private

TimeSeries with the flows which are used to calculate the initial vector.

◆ m_model

template<typename FP , typename Model >
Model& mio::lsecir::Initializer< FP, Model >::m_model
private

The LCT-SECIR model for which the initialization should be performed.

◆ m_tol

template<typename FP , typename Model >
FP mio::lsecir::Initializer< FP, Model >::m_tol {1e-10}
private

Tolerance used to calculate the maximum support of the ErlangDensitys.