model.h Source File
|
CPP API
|
ode_seir/model.h
Go to the documentation of this file.
53 : public FlowModel<FP, InfectionState, mio::Populations<FP, AgeGroup, InfectionState>, Parameters<FP>, Flows>
55 using Base = FlowModel<FP, InfectionState, mio::Populations<FP, AgeGroup, InfectionState>, Parameters<FP>, Flows>;
67 : Base(Populations({AgeGroup(num_agegroups), InfectionState::Count}), ParameterSet(AgeGroup(num_agegroups)))
71 void get_flows(Eigen::Ref<const Eigen::VectorX<FP>> pop, Eigen::Ref<const Eigen::VectorX<FP>> y, FP t,
90 const FP coeffStoE = params.template get<ContactPatterns<FP>>().get_cont_freq_mat().get_matrix_at(
94 flows[Base::template get_flat_flow_index<InfectionState::Susceptible, InfectionState::Exposed>(i)] +=
97 flows[Base::template get_flat_flow_index<InfectionState::Exposed, InfectionState::Infected>(i)] =
99 flows[Base::template get_flat_flow_index<InfectionState::Infected, InfectionState::Recovered>(i)] =
113 return mio::failure(mio::StatusCode::OutOfRange, "t_idx is not a valid index for the TimeSeries");
122 ContactMatrixGroup<FP> const& contact_matrix = params.template get<ContactPatterns<ScalarType>>();
124 Eigen::MatrixX<FP> F = Eigen::MatrixX<FP>::Zero(total_infected_compartments, total_infected_compartments);
125 Eigen::MatrixX<FP> V = Eigen::MatrixX<FP>::Zero(total_infected_compartments, total_infected_compartments);
134 FP coeffStoE = contact_matrix.get_matrix_at(SimulationTime<FP>(y.get_time(t_idx)))(i.get(), j.get()) *
193 auto time_late = std::distance(times.begin(), std::lower_bound(times.begin(), times.end(), t_value));
198 auto result = linear_interpolation(t_value, y.get_time(time_late - 1), y.get_time(time_late), y1, y2);
represents a collection of contact frequency matrices that whose sum is the total number of contacts.
Definition: contact_matrix.h:536
mio::Index< Tag > size() const
returns the size along the dimension provided as template parameter
Definition: custom_index_array.h:204
size_t get_flat_index(Index const &index) const
get_flat_index returns the flat index into the stored array, given the indices of each category
Definition: custom_index_array.h:309
A FlowModel is a CompartmentalModel defined by the flows between compartments.
Definition: flow_model.h:74
FP get_group_total(mio::Index< T > group_idx) const
get_group_total returns the total population of a group in one category
Definition: populations.h:136
stores vectors of values at time points (or some other abstract variable) the value at each time poin...
Definition: time_series.h:58
Eigen::Ref< const Vector > get_value(Eigen::Index i) const
reference to value vector at time point i
Definition: time_series.h:298
FP & get_last_time()
time of time point at index num_time_points - 1
Definition: time_series.h:286
Eigen::Index get_num_time_points() const
number of time points in the series
Definition: time_series.h:197
FP & get_time(Eigen::Index i)
time of time point at index i
Definition: time_series.h:272
Parameters of the simulation that are the same everywhere within the Model.
Definition: abm/parameters.h:764
size_t get_num_groups() const
Get the number of the age groups.
Definition: abm/parameters.h:783
Definition: ode_seir/model.h:54
void get_flows(Eigen::Ref< const Eigen::VectorX< FP >> pop, Eigen::Ref< const Eigen::VectorX< FP >> y, FP t, Eigen::Ref< Eigen::VectorX< FP >> flows) const override
Definition: ode_seir/model.h:71
IOResult< FP > get_reproduction_number(FP t_value, const mio::TimeSeries< FP > &y)
Computes the reproduction number at a given time point of the Model output obtained by the Simulation...
Definition: ode_seir/model.h:180
void serialize(IOContext &io) const
serialize this.
Definition: ode_seir/model.h:207
static IOResult< Model > deserialize(IOContext &io)
deserialize an object of this class.
Definition: ode_seir/model.h:219
IOResult< FP > get_reproduction_number(size_t t_idx, const mio::TimeSeries< FP > &y)
Computes the reproduction number at a given index time of the Model output obtained by the Simulation...
Definition: ode_seir/model.h:110
Model(const Populations &pop, const ParameterSet ¶ms)
Definition: ode_seir/model.h:61
Eigen::VectorX< FP > get_reproduction_numbers(const mio::TimeSeries< FP > &y)
Computes the reproduction number for all time points of the Model output obtained by the Simulation.
Definition: ode_seir/model.h:164
Parameters of an age-resolved SECIR/SECIHURD model.
Definition: ode_seir/parameters.h:112
@ Susceptible
@ Recovered
@ Exposed
@ Infected
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
Range< MultiIndexIterator< Index< Categories... > > > make_index_range(Index< Categories... > dimensions)
Construct a range that can be used to iterate over all MultiIndices in the given dimensions.
Definition: index_range.h:168
auto failure(const IOStatus &s)
Create an object that is implicitly convertible to an error IOResult<T>.
Definition: io.h:380
@ OutOfRange
boost::outcome_v2::in_place_type_t< T > Tag
Type that is used for overload resolution.
Definition: io.h:407
details::ApplyResultT< F, T... > apply(IOContext &io, F f, const IOResult< T > &... rs)
Evaluate a function with zero or more unpacked IOResults as arguments.
Definition: io.h:481
auto linear_interpolation(const X &x_eval, const X &x_1, const X &x_2, const V &y1, const V &y2)
Linear interpolation between two data values.
Definition: interpolation.h:44
auto success()
Create an object that is implicitly convertible to a succesful IOResult<void>.
Definition: io.h:359
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
boost::outcome_v2::unchecked< T, IOStatus > IOResult
Value-or-error type for operations that return a value but can fail.
Definition: io.h:353
The AgeGroup struct is used as a dynamically sized tag for all age dependent categories.
Definition: age_group.h:32
Populations populations
Definition: compartmental_model.h:156
mio::Populations< FP, AgeGroup, InfectionState > Populations
Definition: compartmental_model.h:62
Parameters< FP > ParameterSet
Definition: compartmental_model.h:63
ParameterSet parameters
Definition: compartmental_model.h:157
A Flow defines a possible transition between two Compartments in a FlowModel.
Definition: flow.h:33
Collection of types. Each type is mapped to an index of type size_t.
Definition: type_list.h:32
probability of getting infected from a contact
Definition: ode_seir/parameters.h:43
Generated by