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<char>::iterator;
61  using ConstActivenessIterator = std::vector<char>::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 
251  LocationId find_location(LocationType type, const PersonId person) const;
252 
260  void assign_location(PersonId person, LocationId location)
261  {
262  assign_location(get_person(person), location);
263  }
264 
271 
279 
285 
286  const TripList& get_trip_list() const;
287 
294  void use_mobility_rules(bool param);
295  bool use_mobility_rules() const;
296 
301  bool has_location(LocationType type) const
302  {
303  return m_has_locations[size_t(type)];
304  }
305 
312  template <class C = std::initializer_list<LocationType>>
313  bool has_locations(const C& location_types) const
314  {
315  return std::all_of(location_types.begin(), location_types.end(), [&](auto loc) {
316  return has_location(loc);
317  });
318  }
319 
325 
326  const TestingStrategy& get_testing_strategy() const;
327 
332 
339  RandomNumberGenerator& get_rng()
340  {
341  return m_rng;
342  }
343  const RandomNumberGenerator& get_rng() const
344  {
345  return m_rng;
346  }
357  void reset_rng(Counter<uint32_t> counter = {})
358  {
359  m_rng.set_counter(Counter<uint64_t>(static_cast<uint64_t>(counter.get())));
360  for (Person& person : get_persons()) {
361  person.get_rng_counter() = counter;
362  }
363  }
364  void reset_rng(const std::vector<uint32_t>& seeds, Counter<uint32_t> counter = {})
365  {
366  m_rng.seed(seeds);
367  reset_rng(counter);
368  }
375  int get_id() const
376  {
377  return m_id;
378  }
379 
385  const Person& get_person(PersonId person_id) const
386  {
387  return get_person_impl(*this, person_id);
388  }
389 
391  {
392  return get_person_impl(*this, person_id);
393  }
394 
402  size_t get_subpopulation(LocationId location, TimePoint t, InfectionState state) const
403  {
404  return std::count_if(m_persons.begin(), m_persons.end(), [&](auto&& p) {
405  return p.get_location_model_id() == m_id && p.get_location() == location &&
406  p.get_infection_state(t) == state;
407  });
408  }
409 
415  size_t get_number_persons(LocationId location) const
416  {
420  }
421  return m_local_population_cache[location.get()];
422  }
423 
431  size_t get_number_persons_age(LocationId location, CellIndex cell_idx, AgeGroup age) const
432  {
436  }
437  auto& m_local_population_by_age = m_local_population_by_age_cache[location.get()];
438  return m_local_population_by_age[{cell_idx, age}];
439  }
440 
441  // Change the Location of a Person. this requires that Location is part of this Model.
449  inline void change_location(PersonId person, LocationId destination, TransportMode mode = TransportMode::Unknown,
450  const std::vector<uint32_t>& cells = {0})
451  {
452  change_location(get_person(person), destination, mode, cells);
453  }
454 
461  inline void interact(PersonId person, TimePoint t, TimeSpan dt)
462  {
463  interact(get_person(person), t, dt);
464  }
465 
473  {
474  assert(id != LocationId::invalid_id() && "Given LocationId must be valid.");
475  assert(id < LocationId((uint32_t)m_locations.size()) && "Given LocationId is not in this Model.");
476  return m_locations[id.get()];
477  }
478 
486  void assign_location(Person& person, LocationId location)
487  {
488  person.set_assigned_location(get_location(location).get_type(), location, m_id);
489  }
490 
492  {
493  assert(id != LocationId::invalid_id() && "Given LocationId must be valid.");
494  assert(id < LocationId((uint32_t)m_locations.size()) && "Given LocationId is not in this Model.");
495  return m_locations[id.get()];
496  }
506  {
507  return get_location(get_person(id).get_location());
508  }
509 
510  inline const Location& get_location(PersonId id) const
511  {
512  return get_location(get_person(id).get_location());
513  }
523  uint32_t get_person_index(PersonId person_id) const
524  {
525  mio::log_debug("get_person_index is used leading to a search in m_persons.");
526  auto it = std::find_if(m_persons.begin(), m_persons.end(), [person_id](auto& person) {
527  return person.get_id() == person_id;
528  });
529  if (it == m_persons.end()) {
530  log_error("Given PersonId is not in this Model.");
532  }
533  else {
534  return static_cast<uint32_t>(std::distance(m_persons.begin(), it));
535  }
536  }
537 
538 protected:
544  void interaction(TimePoint t, TimeSpan dt);
550  void perform_mobility(TimePoint t, TimeSpan dt);
551 
554 
556  void build_exposure_caches();
557 
565 
566  // Change the Location of a Person. this requires that Location is part of this Model.
574  inline void change_location(Person& person, LocationId destination, TransportMode mode = TransportMode::Unknown,
575  const std::vector<uint32_t>& cells = {0})
576  {
577  LocationId origin = get_location(person).get_id();
578  auto old_cells = person.get_cells();
579  const bool has_changed_location = mio::abm::change_location(person, get_location(destination), mode, cells);
580  // if the person has changed location, invalidate exposure caches but keep population caches valid
581  if (has_changed_location) {
584  --m_local_population_cache[origin.get()];
585  ++m_local_population_cache[destination.get()];
586  for (CellIndex cell : old_cells) {
587  auto& local_population_by_age = m_local_population_by_age_cache[origin.get()];
588  --local_population_by_age[{cell, person.get_age()}];
589  }
590  for (CellIndex cell : cells) {
591  auto& local_population_by_age = m_local_population_by_age_cache[destination.get()];
592  ++local_population_by_age[{cell, person.get_age()}];
593  }
594  }
595  }
596  }
597 
604  inline Location& get_location(Person& person)
605  {
606  return get_location(person.get_location());
607  }
608 
609  inline const Location& get_location(Person& person) const
610  {
611  return get_location(person.get_location());
612  }
613 
620  LocationId find_location(LocationType type, const Person& person) const
621  {
622  auto location_id = person.get_assigned_location(type);
623  assert(location_id != LocationId::invalid_id() && "The person has no assigned location of that type.");
624  return location_id;
625  }
626 
633  inline void interact(Person& person, TimePoint t, TimeSpan dt)
634  {
636  // checking caches is only needed for external calls
637  // during simulation (i.e. in evolve()), the caches are computed in begin_step
640  }
641  auto personal_rng = PersonalRandomNumberGenerator(m_rng, person);
642  auto location = person.get_location();
643  mio::abm::interact(personal_rng, person, get_location(location),
644  m_local_population_by_age_cache[location.get()], m_air_exposure_rates_cache[location.get()],
645  m_contact_exposure_rates_cache[location.get()], t, dt, parameters);
646  }
647 
655  template <class M>
656  static std::conditional_t<std::is_const_v<M>, const Person&, Person&> get_person_impl(M& m, PersonId person_id)
657  {
658  if (m.m_person_ids_equal_index) {
659  assert(static_cast<uint32_t>(person_id.get()) < m.m_persons.size() &&
660  "Given PersonId is not in this Model.");
661  return m.m_persons[static_cast<uint32_t>(person_id.get())];
662  }
663  else {
664  mio::log_warning("get_person is accessed by PersonId which does not align with the index of the person due "
665  "to former removal of persons. Therefore m_persons is searched.");
666  auto it = std::find_if(m.m_persons.begin(), m.m_persons.end(), [person_id](auto& person) {
667  return person.get_id() == person_id;
668  });
669  assert(it != m.m_persons.end() && "Given PersonId is not in this Model.");
670  return *it;
671  };
672  }
673 
674  mutable Eigen::Matrix<std::atomic_int_fast32_t, Eigen::Dynamic, 1>
676  mutable Eigen::Matrix<PopulationByAge, Eigen::Dynamic, 1>
678  Eigen::Matrix<AirExposureRates, Eigen::Dynamic, 1>
680  Eigen::Matrix<ContactExposureRates, Eigen::Dynamic, 1>
682  mutable bool m_is_local_population_cache_valid = false;
685 
686  int m_id;
687  std::vector<Person> m_persons;
688  std::vector<Location> m_locations;
689  std::vector<char> m_activeness_statuses;
693  std::bitset<size_t(LocationType::Count)>
698  std::vector<MobilityRuleType> m_mobility_rules;
699  LocationId m_cemetery_id; // Central cemetery for all dead persons.
700  RandomNumberGenerator m_rng;
702 };
703 
704 } // namespace abm
705 } // namespace mio
706 
707 #endif
A range of items defined by two iterators.
Definition: stl_util.h:115
T get() const
Returns the underlying value.
Definition: type_safe.h:89
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:695
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:699
Model(Model &&)=default
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:656
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:431
TripList m_trip_list
List of all Trips the Persons do.
Definition: abm/model.h:696
const Location & get_location(Person &person) const
Current number of Persons in a given location.
Definition: abm/model.h:609
std::vector< char >::iterator ActivenessIterator
Definition: abm/model.h:60
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:697
bool m_exposure_caches_need_rebuild
Current number of Persons in a given location.
Definition: abm/model.h:684
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:701
bool has_locations(const C &location_types) const
Check if at least one Location of every specified LocationType exists.
Definition: abm/model.h:313
Location & get_location(LocationId id)
Get a reference to a location in this Model.
Definition: abm/model.h:491
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:402
uint32_t get_person_index(PersonId person_id) const
Get index of person in m_persons.
Definition: abm/model.h:523
std::vector< Location > m_locations
Vector of every Location.
Definition: abm/model.h:688
bool m_is_local_population_cache_valid
Current number of Persons in a given location.
Definition: abm/model.h:682
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:461
void assign_location(Person &person, LocationId location)
Assign a Location to a Person.
Definition: abm/model.h:486
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:505
bool m_are_exposure_caches_valid
Current number of Persons in a given location.
Definition: abm/model.h:683
const Person & get_person(PersonId person_id) const
Get a reference to a Person from this Model.
Definition: abm/model.h:385
const Location & get_location(PersonId id) const
Get a reference to the location of a person.
Definition: abm/model.h:510
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:390
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:681
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:301
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:686
void evolve(TimePoint t, TimeSpan dt)
Evolve the Model one time step.
Definition: abm/model.cpp:82
void reset_rng(Counter< uint32_t > counter={})
Sets the RNG counters of the model and all persons to 0 (or to the optional counter argument).
Definition: abm/model.h:357
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:675
std::vector< Person >::const_iterator ConstPersonIterator
Definition: abm/model.h:59
std::vector< char >::const_iterator ConstActivenessIterator
Definition: abm/model.h:61
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:698
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:700
Model & operator=(const Model &)=default
std::vector< char > m_activeness_statuses
Vector with activeness status for every person.
Definition: abm/model.h:689
TripList & get_trip_list()
Get the mobility data.
Definition: abm/model.cpp:397
const RandomNumberGenerator & get_rng() const
Get the RandomNumberGenerator used by this Model for random events.
Definition: abm/model.h:343
Location & get_location(Person &person)
Get a reference to the location of a person.
Definition: abm/model.h:604
const Location & get_location(LocationId id) const
Get a reference to a location in this Model.
Definition: abm/model.h:472
int get_id() const
Get the model id.
Definition: abm/model.h:375
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:694
void interact(Person &person, TimePoint t, TimeSpan dt)
Let a person interact with the population at its current location.
Definition: abm/model.h:633
void assign_location(PersonId person, LocationId location)
Assign a Location to a Person.
Definition: abm/model.h:260
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:677
LocationId find_location(LocationType type, const Person &person) const
Find an assigned Location of a Person.
Definition: abm/model.h:620
RandomNumberGenerator & get_rng()
Get the RandomNumberGenerator used by this Model for random events.
Definition: abm/model.h:339
Eigen::Matrix< AirExposureRates, Eigen::Dynamic, 1 > m_air_exposure_rates_cache
Cache for local exposure through droplets in #transmissions/day.
Definition: abm/model.h:679
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:574
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:331
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:449
Model & operator=(Model &&)=default
std::vector< Person > m_persons
Vector of every Person.
Definition: abm/model.h:687
void serialize(IOContext &io) const
serialize this.
Definition: abm/model.h:128
void reset_rng(const std::vector< uint32_t > &seeds, Counter< uint32_t > counter={})
Sets the RNG counters of the model and all persons to 0 (or to the optional counter argument).
Definition: abm/model.h:364
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:415
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:50
AgeGroup get_age() const
Get the AgeGroup of this Person.
Definition: person.h:120
LocationId get_location() const
Get the current Location of the Person.
Definition: person.cpp:93
void set_assigned_location(LocationType type, LocationId id, int model_id)
Set an assigned Location of the Person.
Definition: person.cpp:116
std::vector< uint32_t > & get_cells()
Get index of Cells of the Person.
Definition: person.cpp:204
LocationId get_assigned_location(LocationType type) const
Returns the index of an assigned Location of the Person.
Definition: person.cpp:122
Random number generator of individual persons.
Definition: personal_rng.h:49
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:408
void log_warning(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:126
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:482
void log_error(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:114
void log_debug(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:132
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:354
Typesafe index representing an age group.
Definition: age_group.h:40
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