1#ifndef UTOPIA_MODELS_SEIRD_PARAMS_HH
2#define UTOPIA_MODELS_SEIRD_PARAMS_HH
56 for (
const auto&
v :
cont) {
62 change_p_exposed {[&]() {
64 if (
not cfg[
"change_p_exposed"]
or
65 not cfg[
"change_p_exposed"].size()) {
67 return TimesValuesQueue {};
71 throw std::invalid_argument(
72 "Parameter change_p_exposed need be "
73 "a sequence of pairs, but was not! Given infection control "
83 std::sort(
cont.begin(),
85 [](
const auto&
a,
const auto&
b) {
86 return a.first < b.first;
90 TimesValuesQueue
q {};
91 for (
const auto&
v :
cont) {
131 enabled(
get_as<bool>(
"enabled", cfg)),
132 num_additional_immunities {
133 get_as<
std::size_t>(
"num_additional_immunities", cfg, 0)},
135 auto cont = get_as<std::vector<std::size_t>>(
"at_times", cfg, {});
137 std::sort(cont.begin(), cont.end());
141 for (
const auto& v : cont) {
147 change_p_immune {[&]() {
149 if (not cfg[
"change_p_immune"] or
150 not cfg[
"change_p_immune"].size()) {
152 return TimesValuesQueue {};
154 else if (not cfg[
"change_p_immune"].IsSequence()) {
156 throw std::invalid_argument(
157 "Parameter change_p_immune need be "
158 "a sequence of pairs, but was not! Given infection control "
160 DataIO::to_string(cfg));
163 auto cont = get_as<std::vector<std::pair<std::size_t, double>>>(
168 std::sort(cont.begin(),
170 [](
const auto& a,
const auto& b) {
171 return a.first < b.first;
175 TimesValuesQueue q {};
176 for (
const auto& v : cont) {
193 std::queue<std::tuple<std::size_t, unsigned, Kind, double>>;
212 enabled(
get_as<bool>(
"enabled", cfg)), change_p_transmit {[&]() {
214 if (not cfg[
"change_p_transmit"] or
215 not cfg[
"change_p_transmit"].size()) {
219 else if (not cfg[
"change_p_transmit"].IsSequence()) {
221 throw std::invalid_argument(
222 "Parameter change_p_transmit need be "
223 "a sequence of tuples, but was not! Given transmit control "
225 DataIO::to_string(cfg));
230 std::vector<std::tuple<std::size_t, unsigned, Kind, double>> cont;
231 for (
const auto& cfg_item :
232 get_as<DataIO::Config>(
"change_p_transmit", cfg)) {
233 const auto time = get_as<std::size_t>(
"time", cfg_item);
234 const auto num_cells = get_as<unsigned>(
"num_cells", cfg_item);
235 const auto cell_kind =
237 const auto p_transmit = get_as<double>(
"p_transmit", cfg_item);
239 cont.emplace_back(time, num_cells, cell_kind, p_transmit);
243 std::sort(cont.begin(),
245 [](
const auto& a,
const auto& b) {
246 return std::get<0>(a) < std::get<0>(b);
251 for (
const auto& v : cont) {
312 p_susceptible(
get_as<double>(
"p_susceptible", cfg)),
313 p_immune(
get_as<double>(
"p_immune", cfg)),
314 p_random_immunity(
get_as<double>(
"p_random_immunity", cfg)),
315 p_exposed(
get_as<double>(
"p_exposed", cfg)),
316 p_infected(
get_as<double>(
"p_infected", cfg)),
317 p_recovered(
get_as<double>(
"p_recovered", cfg)),
318 p_deceased(
get_as<double>(
"p_deceased", cfg)),
319 p_empty(
get_as<double>(
"p_empty", cfg)),
320 p_lose_immunity(
get_as<double>(
"p_lose_immunity", cfg)),
321 move_away_from_infected(
get_as<bool>(
"move_away_from_infected", cfg)),
322 p_move_randomly(
get_as<double>(
"p_move_randomly", cfg)),
323 exposure_control(
get_as<DataIO::
Config>(
"exposure_control", cfg)),
324 immunity_control(
get_as<DataIO::
Config>(
"immunity_control", cfg)),
325 transmission_control(
get_as<DataIO::
Config>(
"transmission_control", cfg))
327 if ((p_susceptible > 1) or (p_susceptible < 0)) {
328 throw std::invalid_argument(
329 "Invalid p_susceptible! Need be a value "
330 "in range [0, 1] and specify the probability per time step "
331 "and cell with which an empty cell turns into a susceptible "
333 std::to_string(p_susceptible));
335 if ((p_immune > 1) or (p_immune < 0)) {
336 throw std::invalid_argument(
337 "Invalid p_immune! Need be a value "
338 "in range [0, 1] and specify the probability per time step "
339 "and cell with which an empty cell turns into a susceptible "
341 std::to_string(p_immune));
343 if ((p_random_immunity > 1) or (p_random_immunity < 0)) {
344 throw std::invalid_argument(
345 "Invalid p_random_immunity! Need be in range "
347 std::to_string(p_random_immunity));
349 if ((p_exposed > 1) or (p_exposed < 0)) {
350 throw std::invalid_argument(
"Invalid p_exposed! Need be a value "
351 "in range [0, 1], was " +
352 std::to_string(p_exposed));
354 if ((p_infected > 1) or (p_infected < 0)) {
355 throw std::invalid_argument(
"Invalid p_infected! Need be a value "
356 "in range [0, 1], was " +
357 std::to_string(p_infected));
359 if ((p_recovered > 1) or (p_recovered < 0)) {
360 throw std::invalid_argument(
"Invalid p_recovered! Need be a value "
361 "in range [0, 1], was " +
362 std::to_string(p_recovered));
364 if ((p_deceased > 1) or (p_deceased < 0)) {
365 throw std::invalid_argument(
"Invalid p_deceased! Need be a value "
366 "in range [0, 1], was " +
367 std::to_string(p_deceased));
369 if (((p_deceased + p_recovered) > 1)) {
370 throw std::invalid_argument(
371 "Invalid p_deceased and p_recovered! The sum needs to be a value "
372 "smaller than 1, was " +
373 std::to_string(p_deceased + p_recovered));
375 if ((p_empty > 1) or (p_empty < 0)) {
376 throw std::invalid_argument(
"Invalid p_empty! Need be a value "
377 "in range [0, 1], was " +
378 std::to_string(p_empty));
380 if ((p_lose_immunity > 1) or (p_lose_immunity < 0)) {
381 throw std::invalid_argument(
382 "Invalid p_lose_immunity! Need be a value "
383 "in range [0, 1], was " +
384 std::to_string(p_lose_immunity));
386 if ((p_move_randomly > 1) or (p_move_randomly < 0)) {
387 throw std::invalid_argument(
388 "Invalid p_move_randomly! Need be a value "
389 "in range [0, 1], was " +
390 std::to_string(p_move_randomly));
YAML::Node Config
Type of a variadic dictionary-like data structure used throughout Utopia.
Definition types.hh:71
ReturnType get_as(const std::string &key, const DataIO::Config &node)
This function is a wrapper around the yaml-cpp YAML::Node::as function.
Definition cfg_utils.hh:158
std::string to_string(const Config &node)
Given a config node, returns a string representation of it.
Definition cfg_utils.hh:110
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213
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
DataIO::Config Config
Type of a variadic dictionary-like data structure used throughout Utopia.
Definition types.hh:80
Definition parallel.hh:235
Parameters specifying the exposure control.
Definition params.hh:16
TimesQueue at_times
Add additional exposures at these time steps.
Definition params.hh:32
const std::size_t num_additional_exposures
The number of exposures added to the default p_expose.
Definition params.hh:29
const bool enabled
Whether exposure control is enabled.
Definition params.hh:26
TimesValuesQueue change_p_exposed
Change p_expose to new value at given times.
Definition params.hh:39
std::queue< std::pair< std::size_t, double > > TimesValuesQueue
The type of the change p_exposed pairs.
Definition params.hh:22
ExposureContParams(const DataIO::Config &cfg)
Configuration constructor.
Definition params.hh:45
std::queue< std::size_t > TimesQueue
Type of the times queue.
Definition params.hh:19
Parameters specifying the immunity control.
Definition params.hh:101
const std::size_t num_additional_immunities
The number of immunities added to the default p_expose.
Definition params.hh:114
TimesValuesQueue change_p_immune
Change p_immune to new value at given times.
Definition params.hh:124
std::queue< std::size_t > TimesQueue
Type of the times queue.
Definition params.hh:104
std::queue< std::pair< std::size_t, double > > TimesValuesQueue
The type of the change p_immune pairs.
Definition params.hh:107
TimesQueue at_times
Add additional immunities at these time steps.
Definition params.hh:117
const bool enabled
Whether immunity control is enabled.
Definition params.hh:111
ImmunityContParams(const DataIO::Config &cfg)
Configuration constructor.
Definition params.hh:130
Parameters of the SEIRD.
Definition params.hh:261
double p_deceased
Probability for a cell to desease.
Definition params.hh:287
double p_lose_immunity
The probability to loose immunity if a cell is recovered.
Definition params.hh:293
Params(const DataIO::Config &cfg)
Construct the parameters from the given configuration node.
Definition params.hh:311
const double p_susceptible
Probability per site and time step to go from state empty to susceptible.
Definition params.hh:263
const ImmunityContParams immunity_control
Immunity control parameters.
Definition params.hh:305
bool move_away_from_infected
Whether to globally allow moving away from infected neighboring cells.
Definition params.hh:296
double p_move_randomly
Probability to move randomly if the neighboring cell is empty.
Definition params.hh:299
const double p_random_immunity
Definition params.hh:270
double p_immune
Probability per transition to susceptible via p_susceptible to be immune.
Definition params.hh:266
double p_exposed
Definition params.hh:274
const TransmitContParams transmission_control
Transmit control parameters.
Definition params.hh:308
double p_empty
Probability for a cell to become empty.
Definition params.hh:290
double p_infected
Definition params.hh:281
double p_recovered
Probability for a cell to recover.
Definition params.hh:284
const ExposureContParams exposure_control
Exposure control parameters.
Definition params.hh:302
Parameters specifying the transmit control.
Definition params.hh:186
const bool enabled
Whether immunity control is enabled.
Definition params.hh:197
TransmitContParams(const DataIO::Config &cfg)
Configuration constructor.
Definition params.hh:211
TimesValuesQueue change_p_transmit
Change p_transmit to new value at given times.
Definition params.hh:205
std::queue< std::size_t > TimesQueue
Type of the times queue.
Definition params.hh:189
std::queue< std::tuple< std::size_t, unsigned, Kind, double > > TimesValuesQueue
The type of the change p_transmit tuples.
Definition params.hh:193