Utopia 2
Framework for studying models of complex & adaptive systems.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Utopia::Models::SEIRD::State Struct Reference

The full cell struct for the SEIRD model. More...

#include <state.hh>

Public Member Functions

template<class RNG >
 State (const DataIO::Config &cfg, const std::shared_ptr< RNG > &rng)
 Construct the cell state from a configuration and an RNG.
 

Static Public Member Functions

template<typename RNG >
static double initialize_p_transmit (const DataIO::Config &cfg, const std::shared_ptr< RNG > &rng)
 Initialize p_transmit from a configuration node.
 

Public Attributes

Kind kind
 The cell state.
 
bool immune
 Whether the agent is immune.
 
double p_transmit
 
unsigned exposed_time
 The time passed since first being exposed.
 
unsigned age
 The age of the cell.
 
unsigned num_recoveries
 The number of recoveries.
 
unsigned int cluster_id
 An ID denoting to which cluster this cell belongs.
 

Detailed Description

The full cell struct for the SEIRD model.

Constructor & Destructor Documentation

◆ State()

template<class RNG >
Utopia::Models::SEIRD::State::State ( const DataIO::Config cfg,
const std::shared_ptr< RNG > &  rng 
)
inline

Construct the cell state from a configuration and an RNG.

116 :
118 immune(false),
119 p_transmit(1),
120 exposed_time(0),
121 age(0),
123 cluster_id(0)
124 {
125 // Check if p_susceptible is available to set up cell state
126 if (cfg["p_susceptible"]) {
127 const auto init_density = get_as<double>("p_susceptible", cfg);
128
130 throw std::invalid_argument("p_susceptible needs to be in "
131 "interval [0., 1.], but was " +
132 std::to_string(init_density) + "!");
133 }
134
135 // With this probability, the cell state is a susceptible
136 if (std::uniform_real_distribution<double>(0., 1.)(*rng) <
137 init_density) {
139 }
140
141 // If cells are susceptible check whether they are immune
142 // Check if p_immune is available to set up cell state
143 if (cfg["p_immune"]) {
144 const auto init_density = get_as<double>("p_immune", cfg);
145
147 throw std::invalid_argument("p_immune needs to be in "
148 "interval [0., 1.], but was " +
149 std::to_string(init_density) +
150 "!");
151 }
152
153 // With this probability, the cell state is immune
154 if (std::uniform_real_distribution<double>(0., 1.)(*rng) <
155 init_density) {
156 immune = true;
157 }
158 else {
159 immune = false;
160 }
161 }
162 }
163 // Check if p_transmit is available to set up cell state
164 if (cfg["p_transmit"]) {
165 p_transmit = initialize_p_transmit(cfg["p_transmit"], rng);
166 }
167 }
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213
@ susceptible
Cell represents a susceptible.
unsigned age
The age of the cell.
Definition state.hh:105
double p_transmit
Definition state.hh:99
unsigned int cluster_id
An ID denoting to which cluster this cell belongs.
Definition state.hh:111
static double initialize_p_transmit(const DataIO::Config &cfg, const std::shared_ptr< RNG > &rng)
Initialize p_transmit from a configuration node.
Definition state.hh:171
unsigned num_recoveries
The number of recoveries.
Definition state.hh:108
Kind kind
The cell state.
Definition state.hh:92
bool immune
Whether the agent is immune.
Definition state.hh:95
unsigned exposed_time
The time passed since first being exposed.
Definition state.hh:102

Member Function Documentation

◆ initialize_p_transmit()

template<typename RNG >
static double Utopia::Models::SEIRD::State::initialize_p_transmit ( const DataIO::Config cfg,
const std::shared_ptr< RNG > &  rng 
)
inlinestatic

Initialize p_transmit from a configuration node.

173 {
174 const auto mode = get_as<std::string>("mode", cfg);
175
176 if (mode == "value") {
177 // Return the default value
178 return get_as<double>("default",
179 get_as<DataIO::Config>("value", cfg));
180 }
181 else if (mode == "uniform") {
183 "range",
184 get_as<DataIO::Config>("uniform", cfg));
185
186 // Create a uniform real distribution from the specified range
187 std::uniform_real_distribution<double> distr(range.first,
188 range.second);
189
190 // Draw a random number from the range and return it
191 return distr(*rng);
192 }
193 else {
194 throw std::invalid_argument(fmt::format(
195 "Invalid mode! Need be either 'value' or 'uniform', was '{}'!",
196 mode)
197 );
198 }
199 };
decltype(auto) range(const Graph &g)
Get the iterator range over selected graph entities.
Definition iterator.hh:149

Member Data Documentation

◆ age

unsigned Utopia::Models::SEIRD::State::age

The age of the cell.

◆ cluster_id

unsigned int Utopia::Models::SEIRD::State::cluster_id

An ID denoting to which cluster this cell belongs.

◆ exposed_time

unsigned Utopia::Models::SEIRD::State::exposed_time

The time passed since first being exposed.

◆ immune

bool Utopia::Models::SEIRD::State::immune

Whether the agent is immune.

◆ kind

Kind Utopia::Models::SEIRD::State::kind

The cell state.

◆ num_recoveries

unsigned Utopia::Models::SEIRD::State::num_recoveries

The number of recoveries.

◆ p_transmit

double Utopia::Models::SEIRD::State::p_transmit

The probability to transmit the infection to others if exposed or infected


The documentation for this struct was generated from the following file: