CompartmentalModel< FP, Comp, Pop, Params > Struct Template Reference
|
CPP API
|
CompartmentalModel is a template for a compartmental model for an array of initial populations and a parameter set. More...
#include <compartmental_model.h>
Public Types | |
| using | Compartments = Comp |
| using | ParameterSet = Params |
| using | Populations = Pop |
Public Member Functions | |
| 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... | |
| CompartmentalModel & | operator= (CompartmentalModel &&)=default |
| CompartmentalModel & | operator= (const CompartmentalModel &)=default |
| virtual | ~CompartmentalModel ()=default |
Public Attributes | |
| ParameterSet | parameters {} |
| Populations | populations {} |
Detailed Description
template<typename FP, class Comp, class Pop, class Params>
struct mio::CompartmentalModel< FP, Comp, Pop, Params >
CompartmentalModel is a template for a compartmental model for an array of initial populations and a parameter set.
- Template Parameters
-
FP A floating point type, e.g., double.
The Populations must be a concrete class derived from the Populations template, i.e. a multi-dimensional array of compartment populations where each dimension corresponds to a category.
The ParameterSet must be a concrete class derived form the ParameterSet template, i.e. a compile-time map of parameters used by the model. These can be referenced when defining the flows between compartments and they can be used for parameter studies.
Member Typedef Documentation
◆ Compartments
| using mio::CompartmentalModel< FP, Comp, Pop, Params >::Compartments = Comp |
◆ ParameterSet
| using mio::CompartmentalModel< FP, Comp, Pop, Params >::ParameterSet = Params |
◆ Populations
| using mio::CompartmentalModel< FP, Comp, Pop, Params >::Populations = Pop |
Constructor & Destructor Documentation
◆ CompartmentalModel() [1/3]
|
inline |
CompartmentalModel default constructor.
◆ CompartmentalModel() [2/3]
|
default |
◆ CompartmentalModel() [3/3]
|
default |
◆ ~CompartmentalModel()
|
virtualdefault |
Member Function Documentation
◆ apply_constraints()
|
inline |
Checks whether the model satisfies all constraints.
If not, it changes values to suffice their constraints.
Attention: This function should be used with care. It can not and will not set model parameters and compartments to meaningful values. In most cases it is preferable to use check_constraints, and correct values manually before proceeding with the simulation. The main usage for apply_constraints is in automated tests using random values for initialization.
- Returns
- Returns true if one or more constraints were corrected, false otherwise.
◆ check_constraints()
|
inline |
Checks that the model satisfies all constraints (e.g.
parameter or population constraints).
- Returns
- Returns true if one or more constraints are not satisfied, false otherwise.
◆ eval_right_hand_side()
|
inline |
This function evaluates the right-hand-side f of the ODE dydt = f(y, t).
The heart of the compartmental model is a first order ODE dydt = f(y,t), where y is a flat representation of all the compartmental populations at time t. This function evaluates the right-hand-side f of the ODE from the intercompartmental flows. It can be used in an ODE solver.
The distinction between pop and y is only for the case of mobility. If we have mobility, we want to evaluate the evolution of infection states for a small group of travellers (y) while they are in any population (pop). It is important that pop > y always applies.
If we consider a simulation without mobility, the function is called with model.eval_right_hand_side(y, y, t, dydt).
- Parameters
-
[in] pop The current state of the population in the geographic unit we are considering. [in] y The current state of the model (or a subpopulation) as a flat array. [in] t The current time. [out] dydt A reference to the calculated output.
◆ get_derivatives()
|
inlinevirtual |
Reimplemented in mio::oseair::Model< FP >, mio::osir::Model< FP >, mio::lsecir2d::Model< FP, LctStates >, mio::lsecir::Model< FP, LctStates >, mio::glsecir::Model< FP, NumExposed, NumInfectedNoSymptoms, NumInfectedSymptoms, NumInfectedSevere, NumInfectedCritical >, mio::FlowModel< FP, Comp, Pop, Params, Flows >, mio::FlowModel< FP, InfectionState, Populations< FP, AgeGroup, InfectionState >, Parameters< FP >, Flows >, and mio::FlowModel< FP, InfectionState, mio::Populations< FP, AgeGroup, InfectionState >, Parameters< FP >, Flows >.
◆ get_initial_values()
|
inline |
Get the initial conditions for the ODE dydt = f(y, t).
See eval_right_hand_side for more detail.
- Returns
- Current value of model populations as a flat vector.
◆ operator=() [1/2]
|
default |
◆ operator=() [2/2]
|
default |
Member Data Documentation
◆ parameters
| ParameterSet mio::CompartmentalModel< FP, Comp, Pop, Params >::parameters {} |
◆ populations
| Populations mio::CompartmentalModel< FP, Comp, Pop, Params >::populations {} |
Generated by