parameters_io.h Source File
|
CPP API
|
models/lct_secir/parameters_io.h
Go to the documentation of this file.
78 ScalarType severePerInfectedSymptoms, ScalarType criticalPerSevere, ScalarType scale_confirmed_cases)
85 populations[first_index_group + LctStateGroup::template get_first_index<InfectionState::Recovered>()] +=
94 (ScalarType)LctStateGroup::template get_num_subcompartments<InfectionState::InfectedNoSymptoms>();
97 first_index_group + LctStateGroup::template get_first_index<InfectionState::InfectedNoSymptoms>() +
99 for (int i = 0; i < (int)LctStateGroup::template get_num_subcompartments<InfectionState::InfectedNoSymptoms>();
107 populations[last_index_INS - i] -= (i * time_INS_per_subcomp - std::floor(i * time_INS_per_subcomp)) *
136 for (int i = 0; i < (int)LctStateGroup::template get_num_subcompartments<InfectionState::Exposed>(); i++) {
138 std::floor(staytimes[(size_t)InfectionState::InfectedNoSymptoms] + i * time_Exposed_per_subcomp)) {
146 std::ceil(staytimes[(size_t)InfectionState::InfectedNoSymptoms] + i * time_Exposed_per_subcomp)) {
149 std::floor(staytimes[(size_t)InfectionState::InfectedNoSymptoms] + i * time_Exposed_per_subcomp)) *
155 (1 - (staytimes[(size_t)InfectionState::InfectedNoSymptoms] + (i + 1) * time_Exposed_per_subcomp -
161 std::ceil(staytimes[(size_t)InfectionState::InfectedNoSymptoms] + (i + 1) * time_Exposed_per_subcomp)) {
172 if (offset >= std::floor(-staytimes[(size_t)InfectionState::InfectedSymptoms]) && offset <= 0) {
176 (ScalarType)LctStateGroup::template get_num_subcompartments<InfectionState::InfectedSymptoms>();
179 first_index_group + LctStateGroup::template get_first_index<InfectionState::InfectedSymptoms>();
180 for (int i = 0; i < (int)LctStateGroup::template get_num_subcompartments<InfectionState::InfectedSymptoms>();
194 (1 - (-i * time_IS_per_subcomp - std::floor(-i * time_IS_per_subcomp))) * scale_confirmed_cases *
198 populations[first_index_IS + i] += (-i * time_IS_per_subcomp - std::floor(-i * time_IS_per_subcomp)) *
215 for (int i = 0; i < (int)LctStateGroup::template get_num_subcompartments<InfectionState::InfectedSevere>();
218 std::floor(-staytimes[(size_t)InfectionState::InfectedSymptoms] - time_ISev_per_subcomp * (i + 1))) {
227 std::ceil(-staytimes[(size_t)InfectionState::InfectedSymptoms] - time_ISev_per_subcomp * (i + 1))) {
241 std::floor(-staytimes[(size_t)InfectionState::InfectedSymptoms] - i * time_ISev_per_subcomp))) *
244 if (offset == std::ceil(-staytimes[(size_t)InfectionState::InfectedSymptoms] - time_ISev_per_subcomp * i)) {
263 (ScalarType)LctStateGroup::template get_num_subcompartments<InfectionState::InfectedCritical>();
266 first_index_group + LctStateGroup::template get_first_index<InfectionState::InfectedCritical>();
267 for (int i = 0; i < (int)LctStateGroup::template get_num_subcompartments<InfectionState::InfectedCritical>();
316 // This is because the RKI reports deaths with the date of the positive test, not the date of death.
320 populations[first_index_group + LctStateGroup::template get_first_index<InfectionState::Dead>()] +=
322 (-staytimes[(size_t)InfectionState::InfectedSymptoms] - staytimes[(size_t)InfectionState::InfectedSevere] -
332 populations[first_index_group + LctStateGroup::template get_first_index<InfectionState::Dead>()] +=
333 (-staytimes[(size_t)InfectionState::InfectedSymptoms] - staytimes[(size_t)InfectionState::InfectedSevere] -
368 IOResult<void> set_initial_values_from_confirmed_cases(Populations& populations, const std::vector<EntryType>& rki_data,
373 static_assert((Group < Populations::num_groups) && (Group >= 0), "The template parameter Group should be valid.");
379 staytimes[(size_t)InfectionState::Exposed] = parameters.template get<TimeExposed<ScalarType>>()[Group];
390 ScalarType prob_SeverePerInfectedSymptoms = parameters.template get<SeverePerInfectedSymptoms<ScalarType>>()[Group];
391 ScalarType prob_CriticalPerSevere = parameters.template get<CriticalPerSevere<ScalarType>>()[Group];
393 ScalarType min_offset_needed = std::floor(-staytimes[(size_t)InfectionState::InfectedSymptoms] -
397 std::ceil(staytimes[(size_t)InfectionState::Exposed] + staytimes[(size_t)InfectionState::InfectedNoSymptoms]);
402 // Go through the entries of rki_data and check if the entry is age resolved and is referring to
404 // needed for calculation, another function to handle the entry is called. Confirmed cases are scaled by scale_confirmed_cases.
426 populations[first_index_group + LctStateGroup::template get_first_index<InfectionState::Recovered>()] -=
428 .segment(first_index_group + LctStateGroup::template get_first_index<InfectionState::InfectedSymptoms>(),
433 populations[first_index_group + LctStateGroup::template get_first_index<InfectionState::Recovered>()] -=
434 populations[first_index_group + LctStateGroup::template get_first_index<InfectionState::Dead>()];
437 populations[first_index_group + LctStateGroup::template get_first_index<InfectionState::Susceptible>()] =
444 "Necessary range of dates needed to compute initial values does not exist in RKI data for group {:d}.",
452 if (floating_point_less<ScalarType>((ScalarType)populations[i], 0., Limits<ScalarType>::zero_tolerance())) {
453 log_error("Something went wrong in the initialization of group {:d}. At least one entry is negative.",
494 .segment(first_index_group + LctStateGroup::template get_first_index<InfectionState::InfectedCritical>(),
514 IOResult<ScalarType> get_icu_from_divi_data(const std::vector<DiviEntry>& divi_data, const Date date)
553 IOResult<void> rescale_to_divi_data(Populations& populations, const ScalarType infectedCritical_reported,
556 if (floating_point_less<ScalarType>(infectedCritical_reported, 0., Limits<ScalarType>::zero_tolerance())) {
557 log_error("The provided reported number of InfectedCritical is negative. Please check the data.");
565 if (floating_point_equal<ScalarType>(infectedCritical_populations, 0., Limits<ScalarType>::zero_tolerance())) {
566 if (!(floating_point_equal<ScalarType>(infectedCritical_reported, 0., Limits<ScalarType>::zero_tolerance()))) {
567 log_info("The calculated number of patients in intensive care is zero, although the reported number is "
575 subcompartment < LctStateGroup::template get_num_subcompartments<InfectionState::InfectedCritical>();
583 populations[first_index_group + LctStateGroup::template get_first_index<InfectionState::Recovered>()] -=
591 ScalarType scaling_factor_infectedCritical = infectedCritical_reported / infectedCritical_populations;
592 populations[first_index_group + LctStateGroup::template get_first_index<InfectionState::Recovered>()] +=
601 subcompartment < LctStateGroup::template get_num_subcompartments<InfectionState::InfectedCritical>();
604 LctStateGroup::template get_first_index<InfectionState::InfectedCritical>() + subcompartment] *=
611 populations[first_index_group + LctStateGroup::template get_first_index<InfectionState::Recovered>()],
614 "Scaling with reported DIVI data led to a negative entry in the Recovered compartment for group {:d}.",
672 IOResult<void> set_initial_values_from_reported_data(const std::vector<EntryType>& rki_data, Populations& populations,
688 auto max_date_entry = std::max_element(rki_data.begin(), rki_data.end(), [](auto&& a, auto&& b) {
705 IOResult<void> ioresult_confirmedcases = details::set_initial_values_from_confirmed_cases<Populations, EntryType>(
719 return details::rescale_to_divi_data<Populations>(populations, infectedCritical_reported.value(),
static double floor(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &x)
Definition: ad.hpp:2451
static double ceil(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &x)
Definition: ad.hpp:2449
@ InfectedSevere
@ InfectedCritical
@ Exposed
@ InfectedSymptoms
@ InfectedNoSymptoms
int size(Comm comm)
Return the size of the given communicator.
Definition: miompi.cpp:75
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
auto failure(const IOStatus &s)
Create an object that is implicitly convertible to an error IOResult<T>.
Definition: io.h:380
@ InvalidValue
@ OutOfRange
@ InvalidFileFormat
auto success()
Create an object that is implicitly convertible to a succesful IOResult<void>.
Definition: io.h:359
int get_offset_in_days(Date date1, Date date2)
Computes the offset in days given two dates: first date minus second date.
Definition: date.h:310
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
static constexpr FP zero_tolerance()=delete
Generated by