model.h Source File

CPP API: model.h Source File
abm/model.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2020-2026 MEmilio
3 *
4 * Authors: Daniel Abele, Majid Abedi, Elisabeth Kluth, David Kerkmann, Sascha Korf, Martin J. Kuehn, Khoa Nguyen
5 *
6 * Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 #ifndef MIO_ABM_MODEL_H
21 #define MIO_ABM_MODEL_H
22 
23 #include "abm/infection_state.h"
24 #include "abm/model_functions.h"
25 #include "abm/location_type.h"
26 #include "abm/mobility_data.h"
27 #include "abm/parameters.h"
28 #include "abm/location.h"
29 #include "abm/person.h"
30 #include "abm/person_id.h"
31 #include "abm/time.h"
32 #include "abm/trip_list.h"
33 #include "abm/random_events.h"
34 #include "abm/testing_strategy.h"
36 #include "memilio/utils/logging.h"
38 #include "memilio/utils/stl_util.h"
39 
40 #include <bitset>
41 #include <cstdint>
42 #include <vector>
43 
44 namespace mio
45 {
46 namespace abm
47 {
48 
53 class Model
54 {
55 public:
56  using LocationIterator = std::vector<Location>::iterator;
57  using ConstLocationIterator = std::vector<Location>::const_iterator;
58  using PersonIterator = std::vector<Person>::iterator;
59  using ConstPersonIterator = std::vector<Person>::const_iterator;
60  using ActivenessIterator = std::vector<bool>::iterator;
61  using ConstActivenessIterator = std::vector<bool>::const_iterator;
63  const Parameters&);
64 
70  Model(size_t num_agegroups, int id = 0)
71  : parameters(num_agegroups)
72  , m_id(id)
73  , m_trip_list()
74  , m_use_mobility_rules(true)
77  {
78  assert(num_agegroups < MAX_NUM_AGE_GROUPS && "MAX_NUM_AGE_GROUPS exceeded.");
79  }
80 
85  Model(const Parameters& params, int id = 0)
86  : parameters(params.get_num_groups())
87  , m_id(id)
88  , m_trip_list()
89  , m_use_mobility_rules(true)
92  {
93  parameters = params;
94  }
95 
96  Model(const Model& other, int id = 0)
97  : parameters(other.parameters)
105  , m_id(id)
106  , m_persons(other.m_persons)
107  , m_locations(other.m_locations)
111  , m_trip_list(other.m_trip_list)
115  , m_rng(other.m_rng)
117  {
118  }
119  Model& operator=(const Model&) = default;
120  Model(Model&&) = default;
121  Model& operator=(Model&&) = default;
122 
127  template <class IOContext>
128  void serialize(IOContext& io) const
129  {
130  auto obj = io.create_object("Model");
131  obj.add_element("parameters", parameters);
132  // skip caches, they are rebuild by the deserialized model
133  obj.add_list("persons", get_persons().begin(), get_persons().end());
134  obj.add_list("locations", get_locations().begin(), get_locations().end());
135  obj.add_list("activeness_statuses", m_activeness_statuses.begin(), m_activeness_statuses.end());
136  obj.add_element("location_types", m_has_locations.to_ulong());
137  obj.add_element("testing_strategy", m_testing_strategy);
138  obj.add_element("trip_list", m_trip_list);
139  obj.add_element("use_mobility_rules", m_use_mobility_rules);
140  obj.add_element("cemetery_id", m_cemetery_id);
141  obj.add_element("rng", m_rng);
142  }
143 
148  template <class IOContext>
149  static IOResult<Model> deserialize(IOContext& io)
150  {
151  auto obj = io.expect_object("Model");
152  auto params = obj.expect_element("parameters", Tag<Parameters>{});
153  auto persons = obj.expect_list("persons", Tag<Person>{});
154  auto locations = obj.expect_list("locations", Tag<Location>{});
155  auto activeness_statuses = obj.expect_list("activeness_statuses", Tag<bool>{});
156  auto location_types = obj.expect_element("location_types", Tag<unsigned long>{});
157  auto trip_list = obj.expect_element("trip_list", Tag<TripList>{});
158  auto use_mobility_rules = obj.expect_element("use_mobility_rules", Tag<bool>{});
159  auto cemetery_id = obj.expect_element("cemetery_id", Tag<LocationId>{});
160  auto rng = obj.expect_element("rng", Tag<RandomNumberGenerator>{});
161  return apply(
162  io,
163  [](auto&& params_, auto&& persons_, auto&& locations_, auto&& activeness_statuses_, auto&& location_types_,
164  auto&& trip_list_, auto&& use_mobility_rules_, auto&& cemetery_id_, auto&& rng_) {
165  Model model{params_};
166  model.m_persons.assign(persons_.cbegin(), persons_.cend());
167  model.m_locations.assign(locations_.cbegin(), locations_.cend());
168  model.m_activeness_statuses.assign(activeness_statuses_.cbegin(), activeness_statuses_.cend());
169  model.m_has_locations = location_types_;
170  model.m_trip_list = trip_list_;
171  model.m_use_mobility_rules = use_mobility_rules_;
172  model.m_cemetery_id = cemetery_id_;
173  model.m_rng = rng_;
174  return model;
175  },
176  params, persons, locations, activeness_statuses, location_types, trip_list, use_mobility_rules, cemetery_id,
177  rng);
178  }
179 
185  void begin_step(TimePoint t, TimeSpan dt);
186 
192  void evolve(TimePoint t, TimeSpan dt);
193 
200  LocationId add_location(LocationType type, uint32_t num_cells = 1);
201 
208  PersonId add_person(const LocationId id, AgeGroup age);
209 
215  PersonId add_person(Person&& person);
216 
250  LocationId find_location(LocationType type, const PersonId person) const;
251 
259  void assign_location(PersonId person, LocationId location)
260  {
261  assign_location(get_person(person), location);
262  }
263 
270 
278 
284 
285  const TripList& get_trip_list() const;
286 
293  void use_mobility_rules(bool param);
294  bool use_mobility_rules() const;
295 
300  bool has_location(LocationType type) const
301  {
302  return m_has_locations[size_t(type)];
303  }
304 
311  template <class C = std::initializer_list<LocationType>>
312  bool has_locations(const C& location_types) const
313  {
314  return std::all_of(location_types.begin(), location_types.end(), [&](auto loc) {
315  return has_location(loc);
316  });
317  }
318 
324 
325  const TestingStrategy& get_testing_strategy() const;
326 
331 
337  RandomNumberGenerator& get_rng()
338  {
339  return m_rng;
340  }
341 
346  int get_id() const
347  {
348  return m_id;
349  }
350 
356  const Person& get_person(PersonId person_id) const
357  {
358  return get_person_impl(*this, person_id);
359  }
360 
362  {
363  return get_person_impl(*this, person_id);
364  }
365 
373  size_t get_subpopulation(LocationId location, TimePoint t, InfectionState state) const
374  {
375  return std::count_if(m_persons.begin(), m_persons.end(), [&](auto&& p) {
376  return p.get_location_model_id() == m_id && p.get_location() == location &&
377  p.get_infection_state(t) == state;
378  });
379  }
380 
386  size_t get_number_persons(LocationId location) const
387  {
391  }
392  return m_local_population_cache[location.get()];
393  }
394 
402  size_t get_number_persons_age(LocationId location, CellIndex cell_idx, AgeGroup age) const
403  {
407  }
408  auto& m_local_population_by_age = m_local_population_by_age_cache[location.get()];
409  return m_local_population_by_age[{cell_idx, age}];
410  }
411 
412  // Change the Location of a Person. this requires that Location is part of this Model.
420  inline void change_location(PersonId person, LocationId destination, TransportMode mode = TransportMode::Unknown,
421  const std::vector<uint32_t>& cells = {0})
422  {
423  change_location(get_person(person), destination, mode, cells);
424  }
425 
432  inline void interact(PersonId person, TimePoint t, TimeSpan dt)
433  {
434  interact(get_person(person), t, dt);
435  }
436 
444  {
445  assert(id != LocationId::invalid_id() && "Given LocationId must be valid.");
446  assert(id < LocationId((uint32_t)m_locations.size()) && "Given LocationId is not in this Model.");
447  return m_locations[id.get()];
448  }
449 
457  void assign_location(Person& person, LocationId location)
458  {
459  person.set_assigned_location(get_location(location).get_type(), location, m_id);
460  }
461 
463  {
464  assert(id != LocationId::invalid_id() && "Given LocationId must be valid.");
465  assert(id < LocationId((uint32_t)m_locations.size()) && "Given LocationId is not in this Model.");
466  return m_locations[id.get()];
467  }
477  {
478  return get_location(get_person(id).get_location());
479  }
480 
481  inline const Location& get_location(PersonId id) const
482  {
483  return get_location(get_person(id).get_location());
484  }
494  uint32_t get_person_index(PersonId person_id) const
495  {
496  mio::log_debug("get_person_index is used leading to a search in m_persons.");
497  auto it = std::find_if(m_persons.begin(), m_persons.end(), [person_id](auto& person) {
498  return person.get_id() == person_id;
499  });
500  if (it == m_persons.end()) {
501  log_error("Given PersonId is not in this Model.");
503  }
504  else {
505  return static_cast<uint32_t>(std::distance(m_persons.begin(), it));
506  }
507  }
508 
509 protected:
515  void interaction(TimePoint t, TimeSpan dt);
521  void perform_mobility(TimePoint t, TimeSpan dt);
522 
525 
527  void build_exposure_caches();
528 
536 
537  // Change the Location of a Person. this requires that Location is part of this Model.
545  inline void change_location(Person& person, LocationId destination, TransportMode mode = TransportMode::Unknown,
546  const std::vector<uint32_t>& cells = {0})
547  {
548  LocationId origin = get_location(person).get_id();
549  auto old_cells = person.get_cells();
550  const bool has_changed_location = mio::abm::change_location(person, get_location(destination), mode, cells);
551  // if the person has changed location, invalidate exposure caches but keep population caches valid
552  if (has_changed_location) {
555  --m_local_population_cache[origin.get()];
556  ++m_local_population_cache[destination.get()];
557  for (CellIndex cell : old_cells) {
558  auto& local_population_by_age = m_local_population_by_age_cache[origin.get()];
559  --local_population_by_age[{cell, person.get_age()}];
560  }
561  for (CellIndex cell : cells) {
562  auto& local_population_by_age = m_local_population_by_age_cache[destination.get()];
563  ++local_population_by_age[{cell, person.get_age()}];
564  }
565  }
566  }
567  }
568 
575  inline Location& get_location(Person& person)
576  {
577  return get_location(person.get_location());
578  }
579 
580  inline const Location& get_location(Person& person) const
581  {
582  return get_location(person.get_location());
583  }
584 
591  LocationId find_location(LocationType type, const Person& person) const
592  {
593  auto location_id = person.get_assigned_location(type);
594  assert(location_id != LocationId::invalid_id() && "The person has no assigned location of that type.");
595  return location_id;
596  }
597 
604  inline void interact(Person& person, TimePoint t, TimeSpan dt)
605  {
607  // checking caches is only needed for external calls
608  // during simulation (i.e. in evolve()), the caches are computed in begin_step
611  }
612  auto personal_rng = PersonalRandomNumberGenerator(person);
613  auto location = person.get_location();
614  mio::abm::interact(personal_rng, person, get_location(location),
615  m_local_population_by_age_cache[location.get()], m_air_exposure_rates_cache[location.get()],
616  m_contact_exposure_rates_cache[location.get()], t, dt, parameters);
617  }
618 
626  template <class M>
627  static std::conditional_t<std::is_const_v<M>, const Person&, Person&> get_person_impl(M& m, PersonId person_id)
628  {
629  if (m.m_person_ids_equal_index) {
630  assert(static_cast<uint32_t>(person_id.get()) < m.m_persons.size() &&
631  "Given PersonId is not in this Model.");
632  return m.m_persons[static_cast<uint32_t>(person_id.get())];
633  }
634  else {
635  mio::log_warning("get_person is accessed by PersonId which does not align with the index of the person due "
636  "to former removal of persons. Therefore m_persons is searched.");
637  auto it = std::find_if(m.m_persons.begin(), m.m_persons.end(), [person_id](auto& person) {
638  return person.get_id() == person_id;
639  });
640  assert(it != m.m_persons.end() && "Given PersonId is not in this Model.");
641  return *it;
642  };
643  }
644 
645  mutable Eigen::Matrix<std::atomic_int_fast32_t, Eigen::Dynamic, 1>
647  mutable Eigen::Matrix<PopulationByAge, Eigen::Dynamic, 1>
649  Eigen::Matrix<AirExposureRates, Eigen::Dynamic, 1>
651  Eigen::Matrix<ContactExposureRates, Eigen::Dynamic, 1>
653  mutable bool m_is_local_population_cache_valid = false;
656 
657  int m_id;
658  std::vector<Person> m_persons;
659  std::vector<Location> m_locations;
660  std::vector<bool>
662  std::bitset<size_t(LocationType::Count)>
667  std::vector<MobilityRuleType> m_mobility_rules;
668  LocationId m_cemetery_id; // Central cemetery for all dead persons.
669  RandomNumberGenerator m_rng;
671 };
672 
673 } // namespace abm
674 } // namespace mio
675 
676 #endif
A range of items defined by two iterators.
Definition: stl_util.h:99
T get() const
Definition: type_safe.h:66
All Locations in the simulated Model where Persons gather.
Definition: location.h:92
LocationId get_id() const
Get the location's identifier in a Model.
Definition: location.h:143
The Model of the Simulation.
Definition: abm/model.h:54
TestingStrategy m_testing_strategy
List of TestingSchemes that are checked for testing.
Definition: abm/model.h:664
Range< ConstPersonIterator > get_persons() const
Get a range of all Persons in the Model.
Definition: abm/model.cpp:356
std::vector< Location >::iterator LocationIterator
Definition: abm/model.h:56
LocationId m_cemetery_id
Current number of Persons in a given location.
Definition: abm/model.h:668
Model(Model &&)=default
std::vector< bool >::const_iterator ConstActivenessIterator
Definition: abm/model.h:61
void interaction(TimePoint t, TimeSpan dt)
Persons interact at their Location and may become infected.
Definition: abm/model.cpp:91
static std::conditional_t< std::is_const_v< M >, const Person &, Person & > get_person_impl(M &m, PersonId person_id)
Implementation of Model::get_person.
Definition: abm/model.h:627
size_t get_number_persons_age(LocationId location, CellIndex cell_idx, AgeGroup age) const
Get the number of Persons of a specific AgeGroup in a specific Cell at the Location.
Definition: abm/model.h:402
TripList m_trip_list
List of all Trips the Persons do.
Definition: abm/model.h:665
const Location & get_location(Person &person) const
Current number of Persons in a given location.
Definition: abm/model.h:580
std::vector< bool > m_activeness_statuses
Vector with activeness status for every person. Is only used for abm graph model or hybrid model.
Definition: abm/model.h:661
void begin_step(TimePoint t, TimeSpan dt)
Prepare the Model for the next Simulation step.
Definition: abm/model.cpp:337
void build_compute_local_population_cache() const
Shape the cache and store how many Persons are at any Location. Use from single thread!
Definition: abm/model.cpp:224
bool m_use_mobility_rules
Whether mobility rules are considered.
Definition: abm/model.h:666
bool m_exposure_caches_need_rebuild
Current number of Persons in a given location.
Definition: abm/model.h:655
std::vector< bool >::iterator ActivenessIterator
Definition: abm/model.h:60
Range< ConstLocationIterator > get_locations() const
Get a range of all Locations in the Model.
Definition: abm/model.cpp:347
bool m_person_ids_equal_index
Current number of Persons in a given location.
Definition: abm/model.h:670
bool has_locations(const C &location_types) const
Check if at least one Location of every specified LocationType exists.
Definition: abm/model.h:312
Location & get_location(LocationId id)
Get a reference to a location in this Model.
Definition: abm/model.h:462
size_t get_subpopulation_combined(TimePoint t, InfectionState s) const
Get the number of Persons in one InfectionState at all Locations.
Definition: abm/model.cpp:381
size_t get_subpopulation(LocationId location, TimePoint t, InfectionState state) const
Get the number of Persons of a particular InfectionState for all Cells.
Definition: abm/model.h:373
uint32_t get_person_index(PersonId person_id) const
Get index of person in m_persons.
Definition: abm/model.h:494
std::vector< Location > m_locations
Vector of every Location.
Definition: abm/model.h:659
bool m_is_local_population_cache_valid
Current number of Persons in a given location.
Definition: abm/model.h:653
std::vector< Location >::const_iterator ConstLocationIterator
Definition: abm/model.h:57
void interact(PersonId person, TimePoint t, TimeSpan dt)
Let a person interact with the population at its current location.
Definition: abm/model.h:432
void assign_location(Person &person, LocationId location)
Assign a Location to a Person.
Definition: abm/model.h:457
TestingStrategy & get_testing_strategy()
Get the TestingStrategy.
Definition: abm/model.cpp:417
Location & get_location(PersonId id)
Get a reference to the location of a person.
Definition: abm/model.h:476
bool m_are_exposure_caches_valid
Current number of Persons in a given location.
Definition: abm/model.h:654
const Person & get_person(PersonId person_id) const
Get a reference to a Person from this Model.
Definition: abm/model.h:356
const Location & get_location(PersonId id) const
Get a reference to the location of a person.
Definition: abm/model.h:481
LocationId find_location(LocationType type, const PersonId person) const
Find an assigned Location of a Person.
Definition: abm/model.cpp:376
Model(size_t num_agegroups, int id=0)
Create a Model.
Definition: abm/model.h:70
Person & get_person(PersonId person_id)
Definition: abm/model.h:361
Model(const Model &other, int id=0)
Definition: abm/model.h:96
Eigen::Matrix< ContactExposureRates, Eigen::Dynamic, 1 > m_contact_exposure_rates_cache
Cache for local exposure through contacts in #transmissions/day.
Definition: abm/model.h:652
bool use_mobility_rules() const
Definition: abm/model.cpp:412
bool has_location(LocationType type) const
Check if at least one Location with a specified LocationType exists.
Definition: abm/model.h:300
void perform_mobility(TimePoint t, TimeSpan dt)
Persons change location in the Model according to rules.
Definition: abm/model.cpp:104
std::vector< Person >::iterator PersonIterator
Definition: abm/model.h:58
size_t get_subpopulation_combined_per_location_type(TimePoint t, InfectionState s, LocationType type) const
Get the number of Persons in one InfectionState at all Locations of a type.
Definition: abm/model.cpp:389
Range< ConstActivenessIterator > get_activeness_statuses() const
Get a range of all Persons activeness statuses in the Model.
Definition: abm/model.cpp:366
void build_exposure_caches()
Shape the air and contact exposure cache according to the current Locations.
Definition: abm/model.cpp:260
LocationId add_location(LocationType type, uint32_t num_cells=1)
Add a Location to the Model.
Definition: abm/model.cpp:41
int m_id
Model id. Is only used for abm graph model or hybrid model.
Definition: abm/model.h:657
void evolve(TimePoint t, TimeSpan dt)
Evolve the Model one time step.
Definition: abm/model.cpp:82
Eigen::Matrix< std::atomic_int_fast32_t, Eigen::Dynamic, 1 > m_local_population_cache
Current number of Persons in a given location.
Definition: abm/model.h:646
std::vector< Person >::const_iterator ConstPersonIterator
Definition: abm/model.h:59
LocationType(*)(PersonalRandomNumberGenerator &, const Person &, TimePoint, TimeSpan, const Parameters &) MobilityRuleType
Definition: abm/model.h:63
std::vector< MobilityRuleType > m_mobility_rules
Rules that govern the mobility between Locations.
Definition: abm/model.h:667
static IOResult< Model > deserialize(IOContext &io)
deserialize an object of this class.
Definition: abm/model.h:149
RandomNumberGenerator m_rng
Global random number generator.
Definition: abm/model.h:669
Model & operator=(const Model &)=default
TripList & get_trip_list()
Get the mobility data.
Definition: abm/model.cpp:397
Location & get_location(Person &person)
Get a reference to the location of a person.
Definition: abm/model.h:575
const Location & get_location(LocationId id) const
Get a reference to a location in this Model.
Definition: abm/model.h:443
int get_id() const
Get the model id.
Definition: abm/model.h:346
std::bitset< size_t(LocationType::Count)> m_has_locations
Flags for each LocationType, set if a Location of that type exists.
Definition: abm/model.h:663
void interact(Person &person, TimePoint t, TimeSpan dt)
Let a person interact with the population at its current location.
Definition: abm/model.h:604
void assign_location(PersonId person, LocationId location)
Assign a Location to a Person.
Definition: abm/model.h:259
Eigen::Matrix< PopulationByAge, Eigen::Dynamic, 1 > m_local_population_by_age_cache
Current number of Persons per AgeGroup in a given location.
Definition: abm/model.h:648
LocationId find_location(LocationType type, const Person &person) const
Find an assigned Location of a Person.
Definition: abm/model.h:591
RandomNumberGenerator & get_rng()
Get the RandomNumberGenerator used by this Model for random events.
Definition: abm/model.h:337
Eigen::Matrix< AirExposureRates, Eigen::Dynamic, 1 > m_air_exposure_rates_cache
Cache for local exposure through droplets in #transmissions/day.
Definition: abm/model.h:650
void compute_exposure_caches(TimePoint t, TimeSpan dt)
Store all air/contact exposures for the current simulation step.
Definition: abm/model.cpp:279
void change_location(Person &person, LocationId destination, TransportMode mode=TransportMode::Unknown, const std::vector< uint32_t > &cells={0})
Let a Person change to another Location.
Definition: abm/model.h:545
PersonId add_person(const LocationId id, AgeGroup age)
Add a Person to the Model.
Definition: abm/model.cpp:55
Parameters parameters
The simulation parameters of the Model.
Definition: abm/model.h:330
void change_location(PersonId person, LocationId destination, TransportMode mode=TransportMode::Unknown, const std::vector< uint32_t > &cells={0})
Let a Person change to another Location.
Definition: abm/model.h:420
Model & operator=(Model &&)=default
std::vector< Person > m_persons
Vector of every Person.
Definition: abm/model.h:658
void serialize(IOContext &io) const
serialize this.
Definition: abm/model.h:128
Model(const Parameters &params, int id=0)
Create a Model.
Definition: abm/model.h:85
size_t get_number_persons(LocationId location) const
Get the total number of Persons at the Location.
Definition: abm/model.h:386
Parameters of the simulation that are the same everywhere within the Model.
Definition: abm/parameters.h:764
Agents in the simulated Model that can carry and spread the Infection.
Definition: person.h:51
AgeGroup get_age() const
Get the AgeGroup of this Person.
Definition: person.h:121
LocationId get_location() const
Get the current Location of the Person.
Definition: person.cpp:96
void set_assigned_location(LocationType type, LocationId id, int model_id)
Set an assigned Location of the Person.
Definition: person.cpp:119
std::vector< uint32_t > & get_cells()
Get index of Cells of the Person.
Definition: person.cpp:207
LocationId get_assigned_location(LocationType type) const
Returns the index of an assigned Location of the Person.
Definition: person.cpp:125
Random number generator of individual persons.
Definition: personal_rng.h:50
Set of TestingSchemes that are checked for testing.
Definition: testing_strategy.h:168
Represents a point in time.
Definition: time.h:175
A duration of time.
Definition: time.h:36
A list of Trips a Person follows.
Definition: trip_list.h:99
static min_max_return_type< ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 >, ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > >::type max(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &a, const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &b)
Definition: ad.hpp:2596
bool change_location(Person &person, const Location &destination, const TransportMode mode, const std::vector< uint32_t > &cells)
Change a persons location to another location.
Definition: model_functions.cpp:162
void interact(PersonalRandomNumberGenerator &personal_rng, Person &person, const Location &location, const PopulationByAge &local_population_by_age, const AirExposureRates &local_air_exposure, const ContactExposureRates &local_contact_exposure, const TimePoint t, const TimeSpan dt, const Parameters &global_parameters)
Let a Person interact with the population at its current Location, possibly getting infected.
Definition: model_functions.cpp:63
TransportMode
Mode of Transport.
Definition: mobility_data.h:35
LocationType
Type of a Location.
Definition: location_type.h:34
constexpr const int MAX_NUM_AGE_GROUPS
Maximum number of age groups allowed in the model.
Definition: models/abm/config.h:31
InfectionState
InfectionState in ABM.
Definition: abm/infection_state.h:35
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
requires details::IsElementReference< M > RowMajorIterator< M, false > end(M &m)
create a non-const end iterator for the matrix m.
Definition: eigen_util.h:449
boost::outcome_v2::in_place_type_t< T > Tag
Type that is used for overload resolution.
Definition: io.h:407
void log_warning(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:112
details::ApplyResultT< F, T... > apply(IOContext &io, F f, const IOResult< T > &... rs)
Evaluate a function with zero or more unpacked IOResults as arguments.
Definition: io.h:481
void log_error(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:100
void log_debug(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:118
requires details::IsElementReference< M > RowMajorIterator< M, false > begin(M &m)
create a non-const iterator to first element of the matrix m.
Definition: eigen_util.h:421
boost::outcome_v2::unchecked< T, IOStatus > IOResult
Value-or-error type for operations that return a value but can fail.
Definition: io.h:353
The AgeGroup struct is used as a dynamically sized tag for all age dependent categories.
Definition: age_group.h:32
Definition: location.h:37
Unique identifier for a Location within a Model.
Definition: location_id.h:34
static const LocationId invalid_id()
Value for invalid IDs.
Definition: location_id.h:48
Unique ID for a Person within a Model.
Definition: person_id.h:33