1 #ifndef UTOPIA_MODELS_SEIRD_STATE_HH
2 #define UTOPIA_MODELS_SEIRD_STATE_HH
58 auto sfk = std::map<const Kind, std::string>{};
60 for (
auto i = 0u; i < static_cast<char>(
Kind::COUNT); i++) {
61 const Kind kind =
static_cast<Kind>(i);
64 [&](
const auto& kv){ return kv.second == kind; });
65 sfk[kind] = item->first;
78 auto names = std::array<std::string, static_cast<char>(
Kind::COUNT)>{};
79 for (
auto i = 0u; i < static_cast<char>(
Kind::COUNT); i++) {
126 if (cfg[
"p_susceptible"]) {
127 const auto init_density = get_as<double>(
"p_susceptible", cfg);
129 if (init_density < 0. or init_density > 1.) {
130 throw std::invalid_argument(
"p_susceptible needs to be in "
131 "interval [0., 1.], but was " +
136 if (std::uniform_real_distribution<double>(0., 1.)(*
rng) <
143 if (cfg[
"p_immune"]) {
144 const auto init_density = get_as<double>(
"p_immune", cfg);
146 if (init_density < 0. or init_density > 1.) {
147 throw std::invalid_argument(
"p_immune needs to be in "
148 "interval [0., 1.], but was " +
154 if (std::uniform_real_distribution<double>(0., 1.)(*
rng) <
164 if (cfg[
"p_transmit"]) {
170 template<
typename RNG>
172 const std::shared_ptr<RNG>&
rng)
174 const auto mode = get_as<std::string>(
"mode", cfg);
176 if (mode ==
"value") {
178 return get_as<double>(
"default",
179 get_as<DataIO::Config>(
"value", cfg));
181 else if (mode ==
"uniform") {
182 const auto range = get_as<std::pair<double, double>>(
184 get_as<DataIO::Config>(
"uniform", cfg));
187 std::uniform_real_distribution<double> distr(
range.first,
194 throw std::invalid_argument(fmt::format(
195 "Invalid mode! Need be either 'value' or 'uniform', was '{}'!",
@ empty
Every entity is utterly alone in the world.
YAML::Node Config
Type of a variadic dictionary-like data structure used throughout Utopia.
Definition: types.hh:71
std::string to_string(const Config &node)
Given a config node, returns a string representation of it.
Definition: cfg_utils.hh:110
decltype(auto) range(const Graph &g)
Get the iterator range over selected graph entities.
Definition: iterator.hh:149
std::mt19937 rng
– Type definitions ----------------------------------------------------—
Definition: test_revision.cc:17
Definition: counters.hh:10
const std::map< const std::string, Kind > kind_from_string
Map the Kind name given as a string to the actual Kind.
Definition: state.hh:42
const std::map< const Kind, std::string > string_from_kind
The inverse of the kind_from_string mapping.
Definition: state.hh:56
Kind
The kind of the cell.
Definition: state.hh:16
@ source
Cell is an infection source: constantly infected, spreading infection.
@ inert
Cell does not partake in the dynamics.
@ COUNT
The number of kinds (COUNT)
@ recovered
Cell is recovered.
@ infected
Cell is infected.
@ deceased
Cell is deceased.
@ exposed
Cell is exposed to the dease but not yet infected.
@ susceptible
Cell represents a susceptible.
const std::array< std::string, static_cast< char >Kind::COUNT)> kind_names
The associated string names of each Kind enum entry.
Definition: state.hh:76
The full cell struct for the SEIRD model.
Definition: state.hh:90
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
State(const DataIO::Config &cfg, const std::shared_ptr< RNG > &rng)
Construct the cell state from a configuration and an RNG.
Definition: state.hh:115