Model< FP > Class Template Reference

CPP API: mio::oseirmetapop::Model< FP > Class Template Reference
mio::oseirmetapop::Model< FP > Class Template Reference

The Model holds the Parameters and the initial Populations for every region and defines the ordinary differential equations. More...

#include <model.h>

Inheritance diagram for mio::oseirmetapop::Model< FP >:
Collaboration diagram for mio::oseirmetapop::Model< FP >:

Public Member Functions

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
 Compute the values of the flows between compartments at a given time. More...
 
IOResult< ScalarTypeget_reproduction_number (size_t t_idx, const mio::TimeSeries< ScalarType > &y)
 Computes the reproduction number at a given index time of the Model output obtained by the Simulation. More...
 
Eigen::VectorXd get_reproduction_numbers (const mio::TimeSeries< ScalarType > &y)
 Computes the reproduction number for all time points of the Model output obtained by the Simulation. More...
 
 Model (int num_regions, int num_agegroups)
 Create a Model with the given number of Regions and AgeGroups. More...
 
template<class IOContext >
void serialize (IOContext &io) const
 serialize this. More...
 
void set_commuting_strengths ()
 Set the CommutingStrengths matrix without data. More...
 
void set_commuting_strengths (const Eigen::MatrixXd &commuting_strengths)
 Set the CommutingStrengths matrix and update the PopulationAfterCommuting. More...
 
- Public Member Functions inherited from mio::FlowModel< ScalarType, InfectionState, mio::Populations< ScalarType, mio::regions::Region, AgeGroup, InfectionState >, Parameters< ScalarType >, Flows >
 FlowModel (Args... args)
 Default constructor, forwarding args to Base constructor. More...
 
void get_derivatives (Eigen::Ref< const Eigen::VectorX< ScalarType >> flows, Eigen::Ref< Eigen::VectorX< ScalarType >> dydt) const
 Compute the right-hand-side of the ODE dydt = f(y, t) from flow values. More...
 
void get_derivatives (Eigen::Ref< const Eigen::VectorX< ScalarType >> pop, Eigen::Ref< const Eigen::VectorX< ScalarType >> y, ScalarType t, Eigen::Ref< Eigen::VectorX< ScalarType >> dydt) const final
 Compute the right-hand-side f(y, t) of the ODE and store it in dydt. More...
 
constexpr size_t get_flat_flow_index () const
 A flat index into an array of flows (as computed by get_flows), if the only used category in Pop is Comp. More...
 
size_t get_flat_flow_index (const FlowIndex &indices) const
 A flat index into an array of flows (as computed by get_flows), given the indices of each category. More...
 
virtual void get_flows (Eigen::Ref< const Eigen::VectorX< ScalarType >>, Eigen::Ref< const Eigen::VectorX< ScalarType >>, ScalarType, Eigen::Ref< Eigen::VectorX< ScalarType >>) const=0
 
Eigen::VectorX< ScalarTypeget_initial_flows () const
 Initial values for flows. More...
 
- Public Member Functions inherited from mio::CompartmentalModel< FP, Comp, Pop, Params >
bool apply_constraints ()
 Checks whether the model satisfies all constraints. More...
 
bool check_constraints () const
 Checks that the model satisfies all constraints (e.g. More...
 
 CompartmentalModel (CompartmentalModel &&)=default
 
 CompartmentalModel (const CompartmentalModel &)=default
 
 CompartmentalModel (Populations const &po, ParameterSet const &pa)
 CompartmentalModel default constructor. More...
 
void eval_right_hand_side (Eigen::Ref< const Eigen::VectorX< FP >> pop, Eigen::Ref< const Eigen::VectorX< FP >> y, FP t, Eigen::Ref< Eigen::VectorX< FP >> dydt) const
 This function evaluates the right-hand-side f of the ODE dydt = f(y, t). More...
 
virtual void get_derivatives (Eigen::Ref< const Eigen::VectorX< FP >>, Eigen::Ref< const Eigen::VectorX< FP >>, FP, Eigen::Ref< Eigen::VectorX< FP >>) const
 
Eigen::VectorX< FP > get_initial_values () const
 Get the initial conditions for the ODE dydt = f(y, t). More...
 
CompartmentalModeloperator= (CompartmentalModel &&)=default
 
CompartmentalModeloperator= (const CompartmentalModel &)=default
 
virtual ~CompartmentalModel ()=default
 

Static Public Member Functions

template<class IOContext >
static IOResult< Modeldeserialize (IOContext &io)
 deserialize an object of this class. More...
 

Private Types

using Base = FlowModel< FP, InfectionState, mio::Populations< FP, mio::regions::Region, AgeGroup, InfectionState >, Parameters< FP >, Flows >
 

Additional Inherited Members

- Public Types inherited from mio::FlowModel< ScalarType, InfectionState, mio::Populations< ScalarType, mio::regions::Region, AgeGroup, InfectionState >, Parameters< ScalarType >, Flows >
using Base = CompartmentalModel< ScalarType, InfectionState, mio::Populations< ScalarType, mio::regions::Region, AgeGroup, InfectionState >, Parameters< ScalarType > >
 
- Public Types inherited from mio::CompartmentalModel< FP, Comp, Pop, Params >
using Compartments = Comp
 
using ParameterSet = Params
 
using Populations = Pop
 
- Public Attributes inherited from mio::CompartmentalModel< FP, Comp, Pop, Params >
ParameterSet parameters {}
 
Populations populations {}
 

Detailed Description

template<typename FP = ScalarType>
class mio::oseirmetapop::Model< FP >

The Model holds the Parameters and the initial Populations for every region and defines the ordinary differential equations.

Member Typedef Documentation

◆ Base

template<typename FP = ScalarType>
using mio::oseirmetapop::Model< FP >::Base = FlowModel<FP, InfectionState, mio::Populations<FP, mio::regions::Region, AgeGroup, InfectionState>, Parameters<FP>, Flows>
private

Constructor & Destructor Documentation

◆ Model()

template<typename FP = ScalarType>
mio::oseirmetapop::Model< FP >::Model ( int  num_regions,
int  num_agegroups 
)
inline

Create a Model with the given number of Regions and AgeGroups.

Parameters
[in]num_regionsThe number of Regions.
[in]num_agegroupsThe number of AgeGroups.

Member Function Documentation

◆ deserialize()

template<typename FP = ScalarType>
template<class IOContext >
static IOResult<Model> mio::oseirmetapop::Model< FP >::deserialize ( IOContext &  io)
inlinestatic

deserialize an object of this class.

See also
mio::deserialize

◆ get_flows()

template<typename FP = ScalarType>
void mio::oseirmetapop::Model< FP >::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
inlineoverride

Compute the values of the flows between compartments at a given time.

Parameters
[in]popThe current population by #InfectionState, AgeGroup and Region.
[in]yThe current population by #InfectionState, AgeGroup and Region.
[in]tThe current time.
[in,out]flowsThe computed flows between compartments.

◆ get_reproduction_number()

template<typename FP = ScalarType>
IOResult<ScalarType> mio::oseirmetapop::Model< FP >::get_reproduction_number ( size_t  t_idx,
const mio::TimeSeries< ScalarType > &  y 
)
inline

Computes the reproduction number at a given index time of the Model output obtained by the Simulation.

Parameters
[in]t_idxThe index time at which the reproduction number is computed.
[in]yThe TimeSeries obtained from the Model Simulation.
Returns
The computed reproduction number at the provided index time.

◆ get_reproduction_numbers()

template<typename FP = ScalarType>
Eigen::VectorXd mio::oseirmetapop::Model< FP >::get_reproduction_numbers ( const mio::TimeSeries< ScalarType > &  y)
inline

Computes the reproduction number for all time points of the Model output obtained by the Simulation.

Parameters
[in]yThe TimeSeries obtained from the Model Simulation.
Returns
Vector containing all reproduction numbers

◆ serialize()

template<typename FP = ScalarType>
template<class IOContext >
void mio::oseirmetapop::Model< FP >::serialize ( IOContext &  io) const
inline

serialize this.

See also
mio::serialize

◆ set_commuting_strengths() [1/2]

template<typename FP = ScalarType>
void mio::oseirmetapop::Model< FP >::set_commuting_strengths ( )
inline

Set the CommutingStrengths matrix without data.

This function sets the CommutingStrengths matrix to the identity matrix, which corresponds to no commuting between Regions. This prevents division by zero but does not produce meaningful results.

◆ set_commuting_strengths() [2/2]

template<typename FP = ScalarType>
void mio::oseirmetapop::Model< FP >::set_commuting_strengths ( const Eigen::MatrixXd &  commuting_strengths)
inline

Set the CommutingStrengths matrix and update the PopulationAfterCommuting.

Parameters
[in]commuting_strengthsThe matrix containing the fractions of the commuting population between Regions.