FeedbackSimulation< FP, Sim, ContactPatterns > Class Template Reference
|
CPP API
|
A generic feedback simulation extending existing simulations with a feedback mechanism. More...
#include <feedback_simulation.h>
Public Types | |
| using | Model = typename Sim::Model |
Public Member Functions | |
| void | add_icu_occupancy (FP t) |
| Adds the current (local) ICU occupancy into the parameter containing all historical ICU occupancy values. More... | |
| auto | advance (const FP tmax, const FP dt_feedback=1.0) |
| Advances the simulation until tmax while applying feedback at fixed intervals. More... | |
| void | apply_feedback (FP t) |
| Transforms the perceived risk into a contact reduction factor and applies it to the contact patterns. More... | |
| FP | calc_risk_perceived () |
| Calculates the perceived risk based on ICU occupancy data. More... | |
| FeedbackSimulation (Sim &&sim, const std::vector< size_t > &icu_indices) | |
| Constructs the FeedbackSimulation by taking ownership of an existing simulation instance. More... | |
| auto & | get_model () |
| Returns the model used in the simulation. More... | |
| const auto & | get_model () const |
| auto & | get_parameters () |
| Returns the local feedback parameters. More... | |
| auto & | get_perceived_risk () |
| auto & | get_perceived_risk () const |
| Returns the perceived risk time series. More... | |
| auto & | get_result () |
| Returns the simulation result. More... | |
| void | set_global_icu_occupancy (const mio::TimeSeries< FP > &icu_global) |
| Sets the global ICU occupancy time series. More... | |
| void | set_regional_icu_occupancy (const mio::TimeSeries< FP > &icu_regional) |
| Sets the regional ICU occupancy time series. More... | |
Private Attributes | |
| FeedbackSimulationParameters< FP > | m_feedback_parameters |
| The feedback parameters. More... | |
| mio::TimeSeries< FP > | m_global_icu_occupancy |
| The global ICU occupancy time series. More... | |
| std::vector< size_t > | m_icu_indices |
| The ICU compartment indices from the model. More... | |
| mio::TimeSeries< FP > | m_perceived_risk |
| The perceived risk time series. More... | |
| mio::TimeSeries< FP > | m_regional_icu_occupancy |
| The regional ICU occupancy time series. More... | |
| Sim | m_simulation |
| The simulation instance. More... | |
Detailed Description
template<typename FP, typename Sim, typename ContactPatterns>
class mio::FeedbackSimulation< FP, Sim, ContactPatterns >
A generic feedback simulation extending existing simulations with a feedback mechanism.
This class wraps any simulation (e.g. Simulation or FlowSimulation) and applies additional feedback logic in a model-independent way. Model-specific details—such as the ICU compartments— are provided via arguments.
- Template Parameters
-
FP The floating point type. Sim The simulation type. ContactPatterns The model-specific contact patterns type.
Member Typedef Documentation
◆ Model
| using mio::FeedbackSimulation< FP, Sim, ContactPatterns >::Model = typename Sim::Model |
Constructor & Destructor Documentation
◆ FeedbackSimulation()
|
inlineexplicit |
Constructs the FeedbackSimulation by taking ownership of an existing simulation instance.
- Parameters
-
sim The simulation instance to be extended with feedback mechanism. icu_indices A vector of indices indicating ICU compartments for specific model.
Member Function Documentation
◆ add_icu_occupancy()
|
inline |
Adds the current (local) ICU occupancy into the parameter containing all historical ICU occupancy values.
This function use the latest simulation results and extracts the ICU occupancy based on the indices given. The occupancy values are then normalized to 100,000 inhabitants, and then stored (as a new time point) in the ICUOccupancyHistory parameter.
- Parameters
-
t The current simulation time at which the ICU occupancy is recorded.
◆ advance()
|
inline |
Advances the simulation until tmax while applying feedback at fixed intervals.
The simulation is advanced in steps of dt_feedback. At each step, feedback is applied, then the simulation is advanced, and afterwards the current ICU occupancy is stored.
Note that the simulation may make additional substeps depending on its own timestep dt. When using fixed-step integrators, dt_feedback should be an integer multiple of the simulation timestep dt.
- Parameters
-
tmax The maximum simulation time. dt_feedback The feedback time step (default 1.0).
- Returns
- The result in the last time step of the simulation.
◆ apply_feedback()
|
inline |
Transforms the perceived risk into a contact reduction factor and applies it to the contact patterns.
This function computes a contact reduction factor for each location based on the perceived risk. For smooth transitions, we use a softplus function as described in Dönges et al. (doi.org/10.3389/fphy.2022.842180).
- Parameters
-
t The simulation time at which the feedback adjustments are applied.
◆ calc_risk_perceived()
|
inline |
Calculates the perceived risk based on ICU occupancy data.
The risk is computed as a weighted sum of ICU occupancy over recent time points using a gamma-distribution acting as memory kernel.
- Returns
- The computed (local) perceived risk.
◆ get_model() [1/2]
|
inline |
Returns the model used in the simulation.
◆ get_model() [2/2]
|
inline |
◆ get_parameters()
|
inline |
Returns the local feedback parameters.
◆ get_perceived_risk() [1/2]
|
inline |
◆ get_perceived_risk() [2/2]
|
inline |
Returns the perceived risk time series.
◆ get_result()
|
inline |
Returns the simulation result.
◆ set_global_icu_occupancy()
|
inline |
Sets the global ICU occupancy time series.
This is used in the graph simulation to initialize and update the global ICU occupancy.
- Parameters
-
icu_global The global ICU occupancy time series.
◆ set_regional_icu_occupancy()
|
inline |
Sets the regional ICU occupancy time series.
This is used in the graph simulation to initialize and update the regional ICU occupancy.
- Parameters
-
icu_regional The regional ICU occupancy time series.
Member Data Documentation
◆ m_feedback_parameters
|
private |
The feedback parameters.
◆ m_global_icu_occupancy
|
private |
The global ICU occupancy time series.
◆ m_icu_indices
|
private |
The ICU compartment indices from the model.
◆ m_perceived_risk
|
private |
The perceived risk time series.
◆ m_regional_icu_occupancy
|
private |
The regional ICU occupancy time series.
◆ m_simulation
|
private |
The simulation instance.
Generated by