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

Parameters specifying the transmit control. More...

#include <params.hh>

Public Types

using TimesQueue = std::queue< std::size_t >
 Type of the times queue.
 
using TimesValuesQueue = std::queue< std::tuple< std::size_t, unsigned, Kind, double > >
 The type of the change p_transmit tuples.
 

Public Member Functions

 TransmitContParams (const DataIO::Config &cfg)
 Configuration constructor.
 

Public Attributes

const bool enabled
 Whether immunity control is enabled.
 
TimesValuesQueue change_p_transmit
 Change p_transmit to new value at given times.
 

Detailed Description

Parameters specifying the transmit control.

Member Typedef Documentation

◆ TimesQueue

Type of the times queue.

◆ TimesValuesQueue

The type of the change p_transmit tuples.

Constructor & Destructor Documentation

◆ TransmitContParams()

Utopia::Models::SEIRD::TransmitContParams::TransmitContParams ( const DataIO::Config cfg)
inline

Configuration constructor.

Construct an TransmitContParams object with required parameters being extracted from a configuration node with the same parameter names.

211 :
212 enabled(get_as<bool>("enabled", cfg)), change_p_transmit {[&]() {
213 // Check the parameter
214 if (not cfg["change_p_transmit"] or
215 not cfg["change_p_transmit"].size()) {
216 // Key did not exist or was empty; return empty queue.
217 return TimesValuesQueue {};
218 }
219 else if (not cfg["change_p_transmit"].IsSequence()) {
220 // Inform about bad type of the given configuration entry
221 throw std::invalid_argument(
222 "Parameter change_p_transmit need be "
223 "a sequence of tuples, but was not! Given transmit control "
224 "parameters:\n" +
225 DataIO::to_string(cfg));
226 }
227
228 // Create the container with Kind as type in the third place
229 // and fill it up with the
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);
238
239 cont.emplace_back(time, num_cells, cell_kind, p_transmit);
240 }
241
242 // Sort such that low times are in the beginning of the queue
243 std::sort(cont.begin(),
244 cont.end(),
245 [](const auto& a, const auto& b) {
246 return std::get<0>(a) < std::get<0>(b);
247 });
248
249 // Copy elements into the queue
251 for (const auto& v : cont) {
252 q.push(v);
253 }
254
255 return q;
256 }()} {};
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
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
const bool enabled
Whether immunity control is enabled.
Definition params.hh:197
TimesValuesQueue change_p_transmit
Change p_transmit to new value at given times.
Definition params.hh:205
std::queue< std::tuple< std::size_t, unsigned, Kind, double > > TimesValuesQueue
The type of the change p_transmit tuples.
Definition params.hh:193

Member Data Documentation

◆ change_p_transmit

TimesValuesQueue Utopia::Models::SEIRD::TransmitContParams::change_p_transmit
mutable

Change p_transmit to new value at given times.

Each element of this container provides a tuple of [time, num_cells, cell_kind, p_transmit]. If the iteration step (time) of the simulation is reached p_transmit is set to p_transmit for a subset of num_cells randomly drawn cells of kind cell_kind.

◆ enabled

const bool Utopia::Models::SEIRD::TransmitContParams::enabled

Whether immunity control is enabled.


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