parameters_io.h Source File
|
CPP API
|
models/ide_secir/parameters_io.h
Go to the documentation of this file.
79 IOResult<void> set_initial_flows(Model& model, const ScalarType dt, const std::vector<EntryType> rki_data,
93 auto max_date_entry = std::max_element(rki_data.begin(), rki_data.end(), [](auto&& a, auto&& b) {
115 model.transitions = TimeSeries<ScalarType>(Eigen::Index(InfectionTransition::Count) * num_age_groups);
124 // InfectedNoSymptomsToInfectedSymptoms on this time window to compute all consecutive transitions on the time
149 .get<TransitionDistributions>()[group][Eigen::Index(InfectionTransition::ExposedToInfectedNoSymptoms)]
168 .get<TransitionDistributions>()[group][Eigen::Index(InfectionTransition::InfectedCriticalToDead)]
172 (mean_ExposedToInfectedNoSymptoms[group] + mean_InfectedNoSymptomsToInfectedSymptoms[group]) / dt))) {
174 (mean_ExposedToInfectedNoSymptoms[group] + mean_InfectedNoSymptomsToInfectedSymptoms[group]) / dt));
182 i * dt, TimeSeries<ScalarType>::Vector::Constant((size_t)InfectionTransition::Count * num_age_groups, 0.));
185 // Setting the entries in m_total_confirmed_cases to zero before overwriting it with the RKI data.
186 model.total_confirmed_cases = CustomIndexArray<ScalarType, AgeGroup>(AgeGroup(num_age_groups), 0.);
187 //--- Calculate the flow InfectedNoSymptomsToInfectedSymptoms using the RKI data and store in the m_transitions object.---
190 1); // Need -1 if first time point is integer and just the floor value if not, therefore use ceil and -1
195 // Go through the entries of rki_data and check if date is needed for calculation. Confirmed cases are scaled.
196 // Define dummy variables to store the first and the last index of the TimeSeries where the considered entry of
206 // If we don't have age resolution and use EntryType=ConfirmedCasesNoAge, the index is set to 1.
207 // If we consider multiple age groups and use EntryType=ConfirmedCasesDataEntry, it is determined accordingly.
224 idx_needed_last = Eigen::Index(std::min(std::ceil((offset - model.transitions.get_time(0) + 1) / dt),
252 // This is done because the RKI reports death with the date of positive test instead of the date of deaths.
266 std::ceil(-mean_InfectedSymptomsToInfectedSevere[group] - mean_InfectedSevereToInfectedCritical[group] -
283 log_error("Necessary range of dates needed to compute initial values does not exist in RKI data.");
287 auto min_date_entry = std::min_element(rki_data.begin(), rki_data.end(), [](auto&& a, auto&& b) {
293 log_warning("RKI data is needed from {} to compute initial values. RKI data is only available from {}. Missing "
298 //--- Calculate the flows "after" InfectedNoSymptomsToInfectedSymptoms (that were set above using rki_data). ---
299 // Set m_support_max_vector and m_derivative_vector in the model which is needed for the following computations.
340 // Use mean value of the TransitionDistribution InfectedNoSymptomsToInfectedSymptoms for the calculation.
342 Eigen::Index index_shift_mean = Eigen::Index(std::round(mean_InfectedNoSymptomsToInfectedSymptoms[group] / dt));
344 model.get_transition_flat_index(Eigen::Index(InfectionTransition::ExposedToInfectedNoSymptoms), group);
358 (mean_ExposedToInfectedNoSymptoms[group] + mean_InfectedNoSymptomsToInfectedSymptoms[group]) / dt));
359 int StEi = model.get_transition_flat_index(Eigen::Index(InfectionTransition::SusceptibleToExposed), group);
369 // If we previously calculated the transition ExposedToInfectedNoSymptoms, we can calculate this transition
378 // At the end of the calculation, delete all time points that are not required for the simulation.
380 model.transitions = TimeSeries<ScalarType>(Eigen::Index(InfectionTransition::Count) * num_age_groups);
static double floor(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &x)
Definition: ad.hpp:2451
static min_max_return_type< ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 >, ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > >::type min(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &a, const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &b)
Definition: ad.hpp:2599
static min_max_return_type< ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 >, ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > >::type max(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &a, const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &b)
Definition: ad.hpp:2596
static double ceil(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &x)
Definition: ad.hpp:2449
@ InfectedSevereToInfectedCritical
@ InfectedCriticalToRecovered
@ InfectedSymptomsToInfectedSevere
@ InfectedNoSymptomsToRecovered
@ InfectedNoSymptomsToInfectedSymptoms
@ InfectedSevereToRecovered
@ SusceptibleToExposed
@ InfectedCriticalToDead
@ InfectedSymptomsToRecovered
@ ExposedToInfectedNoSymptoms
IOResult< void > set_initial_flows(Model &model, const ScalarType dt, const std::vector< EntryType > rki_data, const Date date, const CustomIndexArray< ScalarType, AgeGroup > scale_confirmed_cases)
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
@ OutOfRange
@ InvalidFileFormat
void log_warning(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:112
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
Date offset_date_by_days(Date date, int offset_days)
Computes the new date corresponding to a given date and a offset in days.
Definition: date.h:242
Generated by