GraphABModel Class Reference

CPP API: mio::GraphABModel Class Reference

#include <graph_abmodel.h>

Inheritance diagram for mio::GraphABModel:
Collaboration diagram for mio::GraphABModel:

Public Member Functions

void evolve (TimePoint t, TimeSpan dt)
 Evolve the Graph Model one time step. More...
 
std::vector< size_t > & get_person_buffer ()
 Get person buffer. More...
 
 GraphABModel (size_t num_agegroups, int id, std::vector< Base::MobilityRuleType > mobility_rules=std::vector< Base::MobilityRuleType >{&get_buried, &return_home_when_recovered, &go_to_hospital, &go_to_icu, &go_to_school, &go_to_work, &go_to_shop, &go_to_event, &go_to_quarantine})
 
void remove_person (size_t pos)
 Removes person from the model. More...
 
- Public Member Functions inherited from mio::abm::Model
LocationId add_location (LocationType type, uint32_t num_cells=1)
 Add a Location to the Model. More...
 
PersonId add_person (const LocationId id, AgeGroup age)
 Add a Person to the Model. More...
 
PersonId add_person (Person &&person)
 Adds a copy of a given Person to the Model. More...
 
void assign_location (PersonId person, LocationId location)
 Assign a Location to a Person. More...
 
void begin_step (TimePoint t, TimeSpan dt)
 Prepare the Model for the next Simulation step. More...
 
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. More...
 
void evolve (TimePoint t, TimeSpan dt)
 Evolve the Model one time step. More...
 
LocationId find_location (LocationType type, const PersonId person) const
 Find an assigned Location of a Person. More...
 
int get_id () const
 Get the model id. More...
 
size_t get_number_persons (LocationId location) const
 Get the total number of Persons at the Location. More...
 
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. More...
 
Personget_person (PersonId person_id)
 
const Personget_person (PersonId person_id) const
 Get a reference to a Person from this Model. More...
 
RandomNumberGenerator & get_rng ()
 Get the RandomNumberGenerator used by this Model for random events. More...
 
size_t get_subpopulation (LocationId location, TimePoint t, InfectionState state) const
 Get the number of Persons of a particular InfectionState for all Cells. More...
 
size_t get_subpopulation_combined (TimePoint t, InfectionState s) const
 Get the number of Persons in one InfectionState at all Locations. More...
 
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. More...
 
TestingStrategyget_testing_strategy ()
 Get the TestingStrategy. More...
 
const TestingStrategyget_testing_strategy () const
 
TripListget_trip_list ()
 Get the mobility data. More...
 
const TripListget_trip_list () const
 
bool has_location (LocationType type) const
 Check if at least one Location with a specified LocationType exists. More...
 
template<class C = std::initializer_list<LocationType>>
bool has_locations (const C &location_types) const
 Check if at least one Location of every specified LocationType exists. More...
 
void interact (PersonId person, TimePoint t, TimeSpan dt)
 Let a person interact with the population at its current location. More...
 
 Model (const Model &other, int id=0)
 
 Model (const Parameters &params, int id=0)
 Create a Model. More...
 
 Model (Model &&)=default
 
 Model (size_t num_agegroups, int id=0)
 Create a Model. More...
 
Modeloperator= (const Model &)=default
 
Modeloperator= (Model &&)=default
 
template<class IOContext >
void serialize (IOContext &io) const
 serialize this. More...
 
bool use_mobility_rules () const
 
void use_mobility_rules (bool param)
 Decide if mobility rules (like go to school/work) are used or not; The mobility rules regarding hospitalization/ICU/quarantine are always used. More...
 
Range< ConstLocationIteratorget_locations () const
 Get a range of all Locations in the Model. More...
 
Range< LocationIteratorget_locations ()
 Get a range of all Locations in the Model. More...
 
Range< ConstPersonIteratorget_persons () const
 Get a range of all Persons in the Model. More...
 
Range< PersonIteratorget_persons ()
 Get a range of all Persons in the Model. More...
 
Range< ConstActivenessIteratorget_activeness_statuses () const
 Get a range of all Persons activeness statuses in the Model. More...
 
Range< ActivenessIteratorget_activeness_statuses ()
 Get a range of all Persons activeness statuses in the Model. More...
 
const Locationget_location (LocationId id) const
 Get a reference to a location in this Model. More...
 
void assign_location (Person &person, LocationId location)
 Assign a Location to a Person. More...
 
Locationget_location (LocationId id)
 Get a reference to a location in this Model. More...
 
Locationget_location (PersonId id)
 Get a reference to the location of a person. More...
 
const Locationget_location (PersonId id) const
 Get a reference to the location of a person. More...
 
uint32_t get_person_index (PersonId person_id) const
 Get index of person in m_persons. More...
 

Private Types

using Base = Model
 

Private Member Functions

void perform_mobility (TimePoint t, TimeSpan dt)
 

Private Attributes

std::vector< size_t > m_person_buffer
 List with indices of persons that are subject to move to another node. More...
 

Additional Inherited Members

- Public Types inherited from mio::abm::Model
using ActivenessIterator = std::vector< bool >::iterator
 
using Compartments = mio::abm::InfectionState
 
using ConstActivenessIterator = std::vector< bool >::const_iterator
 
using ConstLocationIterator = std::vector< Location >::const_iterator
 
using ConstPersonIterator = std::vector< Person >::const_iterator
 
using LocationIterator = std::vector< Location >::iterator
 
using MobilityRuleType = LocationType(*)(PersonalRandomNumberGenerator &, const Person &, TimePoint, TimeSpan, const Parameters &)
 
using PersonIterator = std::vector< Person >::iterator
 
- Static Public Member Functions inherited from mio::abm::Model
template<class IOContext >
static IOResult< Modeldeserialize (IOContext &io)
 deserialize an object of this class. More...
 
- Public Attributes inherited from mio::abm::Model
Parameters parameters
 The simulation parameters of the Model. More...
 
- Protected Member Functions inherited from mio::abm::Model
void interaction (TimePoint t, TimeSpan dt)
 Persons interact at their Location and may become infected. More...
 
void perform_mobility (TimePoint t, TimeSpan dt)
 Persons change location in the Model according to rules. More...
 
void build_compute_local_population_cache () const
 Shape the cache and store how many Persons are at any Location. Use from single thread! More...
 
void build_exposure_caches ()
 Shape the air and contact exposure cache according to the current Locations. More...
 
void compute_exposure_caches (TimePoint t, TimeSpan dt)
 Store all air/contact exposures for the current simulation step. More...
 
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. More...
 
Locationget_location (Person &person)
 Get a reference to the location of a person. More...
 
const Locationget_location (Person &person) const
 Current number of Persons in a given location. More...
 
LocationId find_location (LocationType type, const Person &person) const
 Find an assigned Location of a Person. More...
 
void interact (Person &person, TimePoint t, TimeSpan dt)
 Let a person interact with the population at its current location. More...
 
- Static Protected Member Functions inherited from mio::abm::Model
template<class M >
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. More...
 
- Protected Attributes inherited from mio::abm::Model
Eigen::Matrix< std::atomic_int_fast32_t, Eigen::Dynamic, 1 > m_local_population_cache
 Current number of Persons in a given location. More...
 
Eigen::Matrix< PopulationByAge, Eigen::Dynamic, 1 > m_local_population_by_age_cache
 Current number of Persons per AgeGroup in a given location. More...
 
Eigen::Matrix< AirExposureRates, Eigen::Dynamic, 1 > m_air_exposure_rates_cache
 Cache for local exposure through droplets in #transmissions/day. More...
 
Eigen::Matrix< ContactExposureRates, Eigen::Dynamic, 1 > m_contact_exposure_rates_cache
 Cache for local exposure through contacts in #transmissions/day. More...
 
bool m_is_local_population_cache_valid = false
 Current number of Persons in a given location. More...
 
bool m_are_exposure_caches_valid = false
 Current number of Persons in a given location. More...
 
bool m_exposure_caches_need_rebuild = true
 Current number of Persons in a given location. More...
 
int m_id
 Model id. Is only used for abm graph model or hybrid model. More...
 
std::vector< Personm_persons
 Vector of every Person. More...
 
std::vector< Locationm_locations
 Vector of every Location. More...
 
std::vector< bool > m_activeness_statuses
 Vector with activeness status for every person. Is only used for abm graph model or hybrid model. More...
 
std::bitset< size_t(LocationType::Count)> m_has_locations
 Flags for each LocationType, set if a Location of that type exists. More...
 
TestingStrategy m_testing_strategy
 List of TestingSchemes that are checked for testing. More...
 
TripList m_trip_list
 List of all Trips the Persons do. More...
 
bool m_use_mobility_rules
 Whether mobility rules are considered. More...
 
std::vector< MobilityRuleTypem_mobility_rules
 Rules that govern the mobility between Locations. More...
 
LocationId m_cemetery_id
 Current number of Persons in a given location. More...
 
RandomNumberGenerator m_rng
 Global random number generator. More...
 
bool m_person_ids_equal_index
 Current number of Persons in a given location. More...
 

Member Typedef Documentation

◆ Base

using mio::GraphABModel::Base = Model
private

Constructor & Destructor Documentation

◆ GraphABModel()

mio::GraphABModel::GraphABModel ( size_t  num_agegroups,
int  id,
std::vector< Base::MobilityRuleType mobility_rules = std::vector<Base::MobilityRuleType>{&get_buried, &return_home_when_recovered, &go_to_hospital, &go_to_icu, &go_to_school, &go_to_work, &go_to_shop, &go_to_event, &go_to_quarantine} 
)
inline

Member Function Documentation

◆ evolve()

void mio::GraphABModel::evolve ( TimePoint  t,
TimeSpan  dt 
)
inline

Evolve the Graph Model one time step.

Parameters
[in]tCurrent time.
[in]dtLength of the time step.

◆ get_person_buffer()

std::vector<size_t>& mio::GraphABModel::get_person_buffer ( )
inline

Get person buffer.

◆ perform_mobility()

void mio::GraphABModel::perform_mobility ( TimePoint  t,
TimeSpan  dt 
)
inlineprivate

◆ remove_person()

void mio::GraphABModel::remove_person ( size_t  pos)
inline

Removes person from the model.

Parameters
[in]posIndex of person in m_persons vector.

Member Data Documentation

◆ m_person_buffer

std::vector<size_t> mio::GraphABModel::m_person_buffer
private

List with indices of persons that are subject to move to another node.