initializer_flows.h Source File
|
CPP API
|
initializer_flows.h
Go to the documentation of this file.
88 bool compute_initialization_vector(Eigen::VectorX<FP> const& total_population, Eigen::VectorX<FP> const& deaths,
94 bool error = compute_initialization_vector_impl(init, total_population, deaths, total_confirmed_cases);
134 bool compute_initialization_vector_impl(Eigen::VectorX<FP>& init, Eigen::VectorX<FP> const& total_population,
138 static_assert((Group < Model::num_groups) && (Group >= 0), "The template parameter Group should be valid.");
154 init, first_index_flows + (Eigen::Index)InfectionTransition::InfectedNoSymptomsToInfectedSymptoms,
169 // Number of recovered is equal to the cumulative number of confirmed cases minus the number of people
173 init.segment(first_index + LctStateGroup::template get_first_index<InfectionState::InfectedSymptoms>(),
189 init[first_index + LctStateGroup::template get_first_index<InfectionState::Dead>()] = deaths[Group];
191 for (size_t state_idx : {LctStateGroup::template get_first_index<InfectionState::Susceptible>(),
195 log_error("Initialization failed. Values of total_confirmed_cases, deaths and total_population do not "
202 return compute_initialization_vector_impl<Group + 1>(init, total_population, deaths, total_confirmed_cases);
215 if (!((Eigen::Index)InfectionTransition::Count * Model::num_groups == m_flows.get_num_elements())) {
226 if (!(floating_point_equal<FP>(m_dt, m_flows.get_time(i) - m_flows.get_time(i - 1), 1e-8, 1e-14))) {
257 bool compute_compartment(Eigen::VectorX<FP>& init, Eigen::Index idx_incoming_flow, FP transition_rate) const
263 size_t num_subcompartments = type_at_index_t<Group, LctStatesGroups>::template get_num_subcompartments<State>();
286 log_error("Initialization failed. Not enough time points for the transitions are given. More than {} "
300 "Initialization failed. Result for at least one subcompartment is less than zero. Please check "
size_t get_num_compartments() const
get_num_compartments Returns the number of compartments.
Definition: lct_populations.h:75
Eigen::VectorX< FP > get_compartments() const
Returns an Eigen copy of the vector of populations.
Definition: lct_populations.h:125
stores vectors of values at time points (or some other abstract variable) the value at each time poin...
Definition: time_series.h:58
Class that can be used to compute an initialization vector out of flows for an LCT Model with divisio...
Definition: initializer_flows.h:54
FP m_dt
Step size of the times in m_flows and time step for the approximation of the integral.
Definition: initializer_flows.h:312
void set_tol_for_support_max(FP new_tol)
Setter for the tolerance used to calculate the maximum support of ErlangDensitys.
Definition: initializer_flows.h:113
Initializer(TimeSeries< FP > &&flows, Model &model)
Constructs a new Initializer object.
Definition: initializer_flows.h:68
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 g...
Definition: initializer_flows.h:134
FP m_tol
Tolerance used to calculate the maximum support of the ErlangDensitys.
Definition: initializer_flows.h:313
Model & m_model
The LCT-SECIR model for which the initialization should be performed.
Definition: initializer_flows.h:311
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.
Definition: initializer_flows.h:88
TimeSeries< FP > m_flows
TimeSeries with the flows which are used to calculate the initial vector.
Definition: initializer_flows.h:310
typename Model::LctStatesGroups LctStatesGroups
Definition: initializer_flows.h:56
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 spec...
Definition: initializer_flows.h:257
bool check_constraints() const
Checks constraints of the Initializer including checks for the model.
Definition: initializer_flows.h:213
bool check_constraints() const
Checks that the model satisfies all constraints (e.g.
Definition: lct_secir/model.h:135
TypeList< LctStates... > LctStatesGroups
Definition: lct_secir/model.h:57
static double ceil(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &x)
Definition: ad.hpp:2449
@ InfectedSevereToInfectedCritical
@ InfectedSymptomsToInfectedSevere
@ InfectedNoSymptomsToInfectedSymptoms
@ SusceptibleToExposed
@ ExposedToInfectedNoSymptoms
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
void log_warning(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:112
typename type_at_index< Index, Types... >::type type_at_index_t
The type at the Index-th position in the list Types.
Definition: metaprogramming.h:118
void log_error(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:100
constexpr std::tuple_element< I, std::tuple< Index< CategoryTags >... > >::type & get(Index< CategoryTags... > &i) noexcept
Retrieves the Index (by reference) at the Ith position of a MultiIndex.
Definition: index.h:294
Definition: io.h:94
Class that defines the probability density function corresponding to the Erlang distribution with the...
Definition: state_age_function.h:720
ScalarType get_support_max(ScalarType dt, ScalarType tol=1e-10) override
Computes the maximum of the support of the function.
Definition: state_age_function.h:762
ScalarType eval(ScalarType state_age) override
Defines ErlangDensity depending on state_age.
Definition: state_age_function.h:741
void set_distribution_parameter(FP new_distribution_parameter)
Set the m_distribution_parameter object.
Definition: state_age_function.h:169
Average time spent in the Exposed compartment for each group.
Definition: lct_secir/parameters.h:44
Average time treated by ICU before dead or recover for each group in the SECIR model in day unit.
Definition: lct_secir/parameters.h:111
Average time spent in the TimeInfectedNoSymptoms before developing symptoms or recover for each group...
Definition: lct_secir/parameters.h:61
Average time being in the Hospital before treated by ICU or recover for each group in the SECIR model...
Definition: lct_secir/parameters.h:95
Average time spent in the TimeInfectedSymptoms before going to hospital or recover for each group in ...
Definition: lct_secir/parameters.h:78
Generated by