Person Class Reference

CPP API: mio::abm::Person Class Reference
mio::abm::Person Class Reference

Agents in the simulated Model that can carry and spread the Infection. More...

#include <person.h>

Collaboration diagram for mio::abm::Person:

Public Member Functions

void add_new_infection (Infection &&inf)
 Adds a new Infection to the list of Infections. More...
 
void add_new_vaccination (ProtectionType v, TimePoint t)
 Add a new vaccination. More...
 
void add_test_result (TimePoint t, TestType type, bool result)
 Add TestResult to the Person. More...
 
void add_time_at_location (const TimeSpan dt)
 Add to the time the Person has been at its current Location. More...
 
auto default_serialize ()
 This method is used by the default serialization feature. More...
 
AgeGroup get_age () const
 Get the AgeGroup of this Person. More...
 
LocationId get_assigned_location (LocationType type) const
 Returns the index of an assigned Location of the Person. More...
 
int get_assigned_location_model_id (LocationType type) const
 Returns the model id of an assigned location of the Person. More...
 
const std::vector< int > & get_assigned_location_model_ids () const
 Get the assigned locations' model ids of the Person. More...
 
const std::vector< LocationId > & get_assigned_locations () const
 Get the assigned Locations of the Person. More...
 
std::vector< uint32_t > & get_cells ()
 Get index of Cells of the Person. More...
 
const std::vector< uint32_t > & get_cells () const
 
ScalarType get_compliance (InterventionType intervention_type) const
 Get the compliance of the Person for an Intervention. More...
 
TimeSpan get_go_to_school_time (const Parameters &params) const
 Draw at what time the Person goes to work. More...
 
TimeSpan get_go_to_work_time (const Parameters &params) const
 Draw at what time the Person goes to work. More...
 
PersonId get_id () const
 Get the PersonId of the Person. More...
 
Infectionget_infection ()
 Get the latest #Infection of the Person. More...
 
const Infectionget_infection () const
 
InfectionState get_infection_state (TimePoint t) const
 Get the InfectionState of the Person at a specific TimePoint. More...
 
mio::abm::TransportMode get_last_transport_mode () const
 Get the transport mode the Person used to get to its current Location. More...
 
ProtectionEvent get_latest_protection (TimePoint t) const
 Get the latest ProtectionType and its initial TimePoint of the Person. More...
 
LocationId get_location () const
 Get the current Location of the Person. More...
 
int get_location_model_id () const
 
LocationType get_location_type () const
 
Maskget_mask ()
 Get the current Mask of the Person. More...
 
const Maskget_mask () const
 
ScalarType get_mask_protective_factor (const Parameters &params) const
 Get the protection of the Mask. More...
 
ScalarType get_protection_factor (TimePoint t, VirusVariant virus, const Parameters &params) const
 Get the multiplicative factor on how likely an #Infection is due to the immune system. More...
 
Counter< uint32_t > & get_rng_counter ()
 Get this persons RandomNumberGenerator counter. More...
 
uint32_t get_rng_index ()
 Get this Person's index that is used for the RandomNumberGenerator. More...
 
mio::Key< uint64_t > get_rng_key ()
 Get this Person's key that is used for the RandomNumberGenerator. More...
 
TestResult get_test_result (TestType type) const
 Get the most recent TestResult performed from the Person based on the TestType. More...
 
bool get_tested (PersonalRandomNumberGenerator &rng, TimePoint t, const TestParameters &params)
 Simulates a viral test and returns the test result of the Person. More...
 
TimeSpan get_time_at_location () const
 Get the time the Person has been at its current Location. More...
 
bool goes_to_school (TimePoint t, const Parameters &params) const
 Draw if the Person goes to school or stays at home during lockdown. More...
 
bool goes_to_work (TimePoint t, const Parameters &params) const
 Draw if the Person goes to work or is in home office during lockdown at a specific TimePoint. More...
 
bool is_compliant (PersonalRandomNumberGenerator &rng, InterventionType intervention) const
 Checks whether the Person complies an Intervention. More...
 
bool is_in_quarantine (TimePoint t, const Parameters &params) const
 Answers the question if a Person is currently in quarantine. More...
 
bool is_infected (TimePoint t) const
 Returns if the Person is infected at the TimePoint. More...
 
bool operator== (const Person &other) const
 Compare two Persons. More...
 
 Person (const Person &other, PersonId person_id)
 
 Person (mio::RandomNumberGenerator &rng, LocationType location_type, LocationId location_id, int location_model_id, AgeGroup age, PersonId person_id=PersonId::invalid_ID())
 Create a Person. More...
 
void remove_quarantine ()
 Removes the quarantine status of the Person. More...
 
void set_assigned_location (LocationType type, LocationId id, int model_id)
 Set an assigned Location of the Person. More...
 
void set_compliance (InterventionType intervention_type, ScalarType value)
 For every InterventionType a Person has a compliance value between 0 and 1. More...
 
void set_last_transport_mode (const mio::abm::TransportMode mode)
 Set the transport mode the Person used to get to its current Location. More...
 
void set_location (LocationType type, LocationId id, int model_id)
 Change the location of the person. More...
 
void set_mask (MaskType type, TimePoint t)
 Change the mask to new type. More...
 
std::vector< ProtectionEvent > & get_vaccinations ()
 Get all vaccinations of the Person. More...
 
const std::vector< ProtectionEvent > & get_vaccinations () const
 Get all vaccinations of the Person. More...
 

Private Attributes

AgeGroup m_age
 AgeGroup the Person belongs to. More...
 
std::vector< int > m_assigned_location_model_ids
 Vector with model ids of the assigned locations. Only used in graph abm. More...
 
std::vector< LocationIdm_assigned_locations
 
std::vector< uint32_t > m_cells
 Vector with all Cells the Person visits at its current Location. More...
 
std::vector< ScalarTypem_compliance
 Vector of compliance values for all InterventionTypes. Values from 0 to 1. More...
 
TimePoint m_home_isolation_start
 TimePoint when the Person started isolation at home. More...
 
std::vector< Infectionm_infections
 Vector with all Infections the Person had. More...
 
mio::abm::TransportMode m_last_transport_mode
 TransportMode the Person used to get to its current Location. More...
 
LocationId m_location
 Current Location of the Person. More...
 
int m_location_model_id
 Model id of the current Location. Only used for Graph ABM. More...
 
LocationType m_location_type
 Type of the current Location. More...
 
Mask m_mask
 The Mask of the Person. More...
 
PersonId m_person_id
 Unique identifier of a person. More...
 
ScalarType m_random_goto_school_hour
 Value to determine at what time the Person goes to school. More...
 
ScalarType m_random_goto_work_hour
 Value to determine at what time the Person goes to work. More...
 
ScalarType m_random_schoolgroup
 Value to determine if the Person goes to school or stays at home during lockdown. More...
 
ScalarType m_random_workgroup
 Value to determine if the Person goes to work or works from home during lockdown. More...
 
Counter< uint32_t > m_rng_counter {0}
 counter for RandomNumberGenerator. More...
 
uint32_t m_rng_index
 Index for PersonalRandomNumberGenerator. More...
 
mio::Key< uint64_t > m_rng_key
 Key for PersonalRandomNumberGenerator. More...
 
CustomIndexArray< TestResult, TestTypem_test_results
 CustomIndexArray for TestResults. More...
 
TimeSpan m_time_at_location
 Time the Person has spent at its current Location so far. More...
 
std::vector< ProtectionEventm_vaccinations
 ! Vector with the indices of the assigned Locations so that the Person always visits the same Home or School etc. More...
 

Detailed Description

Agents in the simulated Model that can carry and spread the Infection.

Constructor & Destructor Documentation

◆ Person() [1/2]

mio::abm::Person::Person ( mio::RandomNumberGenerator &  rng,
LocationType  location_type,
LocationId  location_id,
int  location_model_id,
AgeGroup  age,
PersonId  person_id = PersonId::invalid_ID() 
)
explicit

Create a Person.

Parameters
[in,out]rngRandomNumberGenerator.
[in,out]locationInitial Location of the Person.
[in]ageThe AgeGroup of the Person.
[in]person_indexIndex of the Person.

◆ Person() [2/2]

mio::abm::Person::Person ( const Person other,
PersonId  person_id 
)
explicit

Member Function Documentation

◆ add_new_infection()

void mio::abm::Person::add_new_infection ( Infection &&  inf)

Adds a new Infection to the list of Infections.

Parameters
[in]infThe new Infection.

◆ add_new_vaccination()

void mio::abm::Person::add_new_vaccination ( ProtectionType  v,
TimePoint  t 
)
inline

Add a new vaccination.

Parameters
[in]vProtectionType (i. e. vaccine) the person takes.
[in]tTimePoint of the vaccination.

◆ add_test_result()

void mio::abm::Person::add_test_result ( TimePoint  t,
TestType  type,
bool  result 
)

Add TestResult to the Person.

Parameters
[in]tThe TimePoint of the test.
[in]typeThe TestType of the test.
[in]resultThe result of the test.

◆ add_time_at_location()

void mio::abm::Person::add_time_at_location ( const TimeSpan  dt)
inline

Add to the time the Person has been at its current Location.

Parameters
[in]dtTimeSpan the Person has spent at the Location.

◆ default_serialize()

auto mio::abm::Person::default_serialize ( )
inline

This method is used by the default serialization feature.

◆ get_age()

AgeGroup mio::abm::Person::get_age ( ) const
inline

Get the AgeGroup of this Person.

Returns
AgeGroup of the Person.

◆ get_assigned_location()

LocationId mio::abm::Person::get_assigned_location ( LocationType  type) const

Returns the index of an assigned Location of the Person.

Assume that a Person has at most one assigned Location of a certain LocationType.

Parameters
[in]typeLocationType of the assigned Location.
Returns
The index in the LocationId of the assigned Location.

◆ get_assigned_location_model_id()

int mio::abm::Person::get_assigned_location_model_id ( LocationType  type) const

Returns the model id of an assigned location of the Person.

Assume that a Person has at most one assigned Location of a certain LocationType.

Parameters
[in]typeLocationType of the assigned Location.
Returns
The model id of the assigned Location.

◆ get_assigned_location_model_ids()

const std::vector<int>& mio::abm::Person::get_assigned_location_model_ids ( ) const
inline

Get the assigned locations' model ids of the Person.

Returns
A vector with the model ids of the assigned locations of the Person

◆ get_assigned_locations()

const std::vector<LocationId>& mio::abm::Person::get_assigned_locations ( ) const
inline

Get the assigned Locations of the Person.

Returns
A vector with the indices of the assigned Locations of the Person.

◆ get_cells() [1/2]

std::vector< uint32_t > & mio::abm::Person::get_cells ( )

Get index of Cells of the Person.

Returns
A vector of all Cell indices the Person visits at the current Location.

◆ get_cells() [2/2]

const std::vector< uint32_t > & mio::abm::Person::get_cells ( ) const

◆ get_compliance()

ScalarType mio::abm::Person::get_compliance ( InterventionType  intervention_type) const
inline

Get the compliance of the Person for an Intervention.

Parameters
[in]intervention_typeThe InterventionType.
Returns
The probability that the Person complies to an Intervention.

◆ get_go_to_school_time()

TimeSpan mio::abm::Person::get_go_to_school_time ( const Parameters params) const

Draw at what time the Person goes to work.

Every Person has a random number to determine what time to go to school. Depending on this number Person decides what time has to go to school.

Parameters
[in]paramsParameters that describe the mobility between Locations.
Returns
The time of going to school.

◆ get_go_to_work_time()

TimeSpan mio::abm::Person::get_go_to_work_time ( const Parameters params) const

Draw at what time the Person goes to work.

Every Person has a random number to determine what time to go to work. Depending on this number Person decides what time has to go to work.

Parameters
[in]paramsParameters that describe the mobility between Locations.
Returns
The time of going to work.

◆ get_id()

PersonId mio::abm::Person::get_id ( ) const

Get the PersonId of the Person.

Returns
The PersonId.

◆ get_infection() [1/2]

Infection & mio::abm::Person::get_infection ( )

Get the latest #Infection of the Person.

Returns
The latest #Infection of the Person.

◆ get_infection() [2/2]

const Infection & mio::abm::Person::get_infection ( ) const

◆ get_infection_state()

InfectionState mio::abm::Person::get_infection_state ( TimePoint  t) const

Get the InfectionState of the Person at a specific TimePoint.

Parameters
[in]tTimePoint of querry. Usually the current time of the Simulation.
Returns
The InfectionState of the latest Infection at time t.

◆ get_last_transport_mode()

mio::abm::TransportMode mio::abm::Person::get_last_transport_mode ( ) const
inline

Get the transport mode the Person used to get to its current Location.

Returns
TransportMode the Person used to get to its current Location.

◆ get_latest_protection()

ProtectionEvent mio::abm::Person::get_latest_protection ( TimePoint  t) const

Get the latest ProtectionType and its initial TimePoint of the Person.

Parameters
[in]tTimePoint to check.

◆ get_location()

LocationId mio::abm::Person::get_location ( ) const

Get the current Location of the Person.

Returns
Current Location of the Person.

◆ get_location_model_id()

int mio::abm::Person::get_location_model_id ( ) const
inline

◆ get_location_type()

LocationType mio::abm::Person::get_location_type ( ) const
inline

◆ get_mask() [1/2]

Mask& mio::abm::Person::get_mask ( )
inline

Get the current Mask of the Person.

Returns
Reference to the Mask object of the Person.

◆ get_mask() [2/2]

const Mask& mio::abm::Person::get_mask ( ) const
inline

◆ get_mask_protective_factor()

ScalarType mio::abm::Person::get_mask_protective_factor ( const Parameters params) const

Get the protection of the Mask.

A value of 1 represents full protection and a value of 0 means no protection. This depends on the MaskType of the Mask the Person is wearing.

Parameters
[in]paramsThe parameters of the Infection that are the same everywhere within the Model.
Returns
The reduction factor of getting an Infection when wearing the Mask.

◆ get_protection_factor()

ScalarType mio::abm::Person::get_protection_factor ( TimePoint  t,
VirusVariant  virus,
const Parameters params 
) const

Get the multiplicative factor on how likely an #Infection is due to the immune system.

Parameters
[in]tTimePoint of check.
[in]virusVirusVariant to check
[in]paramsParameters in the model.
Returns
Protection factor for general #Infection of the immune system to the given VirusVariant at the given TimePoint.

◆ get_rng_counter()

Counter<uint32_t>& mio::abm::Person::get_rng_counter ( )
inline

Get this persons RandomNumberGenerator counter.

See also
mio::abm::PersonalRandomNumberGenerator.

◆ get_rng_index()

uint32_t mio::abm::Person::get_rng_index ( )
inline

Get this Person's index that is used for the RandomNumberGenerator.

See also
mio::abm::PersonalRandomNumberGenerator.

◆ get_rng_key()

mio::Key<uint64_t> mio::abm::Person::get_rng_key ( )
inline

Get this Person's key that is used for the RandomNumberGenerator.

See also
mio::abm::PersonalRandomNumberGenerator.

◆ get_test_result()

TestResult mio::abm::Person::get_test_result ( TestType  type) const

Get the most recent TestResult performed from the Person based on the TestType.

If time_of_testing == TimePoint(std::numeric_limits<int>::min()), there is no previous TestResult.

Parameters
[in]typeThe TestType of the test.
Returns
The latest TestResult of the given Type.

◆ get_tested()

bool mio::abm::Person::get_tested ( PersonalRandomNumberGenerator rng,
TimePoint  t,
const TestParameters params 
)

Simulates a viral test and returns the test result of the Person.

If the test is positive, the Person has to quarantine. If the test is negative, quarantine ends.

Parameters
[in,out]rngRandomNumberGenerator of the Person.
[in]tTimePoint of the test.
[in]paramsSensitivity and specificity of the test method.
Returns
True if the test result of the Person is positive.

◆ get_time_at_location()

TimeSpan mio::abm::Person::get_time_at_location ( ) const
inline

Get the time the Person has been at its current Location.

Returns
TimeSpan the Person has been at the Location.

◆ get_vaccinations() [1/2]

std::vector<ProtectionEvent>& mio::abm::Person::get_vaccinations ( )
inline

Get all vaccinations of the Person.

Returns
A vector with all vaccinations.

◆ get_vaccinations() [2/2]

const std::vector<ProtectionEvent>& mio::abm::Person::get_vaccinations ( ) const
inline

Get all vaccinations of the Person.

Returns
A vector with all vaccinations.

◆ goes_to_school()

bool mio::abm::Person::goes_to_school ( TimePoint  t,
const Parameters params 
) const

Draw if the Person goes to school or stays at home during lockdown.

Every Person has a random number that determines if they go to school in case of a lockdown.

Parameters
[in]tThe TimePoint of interest. Usually the current time of the Simulation.
[in]paramsParameters that describe the mobility between Locations.
Returns
True if the Person goes to school.

◆ goes_to_work()

bool mio::abm::Person::goes_to_work ( TimePoint  t,
const Parameters params 
) const

Draw if the Person goes to work or is in home office during lockdown at a specific TimePoint.

Every Person has a random number. Depending on this number and the time, the Person works from home in case of a lockdown.

Parameters
[in]tThe TimePoint of interest. Usually the current time of the Simulation.
[in]paramsParameters that describe the mobility between Locations.
Returns
True the Person works from home.

◆ is_compliant()

bool mio::abm::Person::is_compliant ( PersonalRandomNumberGenerator rng,
InterventionType  intervention 
) const

Checks whether the Person complies an Intervention.

Parameters
[in,out]rngPersonalRandomNumberGenerator of the Person.
[in]interventionThe InterventionType.
Returns
Checks whether the Person complies an Intervention.

◆ is_in_quarantine()

bool mio::abm::Person::is_in_quarantine ( TimePoint  t,
const Parameters params 
) const
inline

Answers the question if a Person is currently in quarantine.

If a Person is in quarantine this Person cannot change to Locations other than Home or the Hospital.

Parameters
[in]tThe TimePoint of interest. Usually the current time of the Simulation.
[in]paramsParameter that includes the length of a quarantine.
Returns
True if the Person is in quarantine.

◆ is_infected()

bool mio::abm::Person::is_infected ( TimePoint  t) const

Returns if the Person is infected at the TimePoint.

Parameters
[in]tTimePoint of querry. Usually the current time of the Simulation.
Returns
True if the Person is infected at the TimePoint.

◆ operator==()

bool mio::abm::Person::operator== ( const Person other) const
inline

Compare two Persons.

◆ remove_quarantine()

void mio::abm::Person::remove_quarantine ( )

Removes the quarantine status of the Person.

◆ set_assigned_location()

void mio::abm::Person::set_assigned_location ( LocationType  type,
LocationId  id,
int  model_id = 0 
)

Set an assigned Location of the Person.

Important: Setting incorrect values will cause issues during simulation. It is preferable to use Model::assign_location with a valid LocationId, obtained e.g. through Model::add_location.

The assigned Location is saved by the index of its LocationId. Assume that a Person has at most one assigned Location of a certain LocationType.

Parameters
[in]typeThe LocationType of the Location.
[in]idThe LocationId of the Location.
[in]model_idThe model id of the Location.

◆ set_compliance()

void mio::abm::Person::set_compliance ( InterventionType  intervention_type,
ScalarType  value 
)
inline

For every InterventionType a Person has a compliance value between 0 and 1.

0 means that the Person never complies to the Intervention. 1 means that the Person always complies to the Intervention.

Parameters
[in]intervention_typeThe InterventionType.
[in]valueThe compliance value.

◆ set_last_transport_mode()

void mio::abm::Person::set_last_transport_mode ( const mio::abm::TransportMode  mode)
inline

Set the transport mode the Person used to get to its current Location.

Parameters
[in]modeTransportMode the Person used to get to its current Location.

◆ set_location()

void mio::abm::Person::set_location ( LocationType  type,
LocationId  id,
int  model_id 
)

Change the location of the person.

Parameters
[in]typeThe LocationType of the new Location.
[in]idThe LocationId of the new Location.
[in]model_idThe model id of the new Location.

◆ set_mask()

void mio::abm::Person::set_mask ( MaskType  type,
TimePoint  t 
)

Change the mask to new type.

Parameters
[in]typeThe required MaskType.
[in]tThe TimePoint of mask change.

Member Data Documentation

◆ m_age

AgeGroup mio::abm::Person::m_age
private

AgeGroup the Person belongs to.

◆ m_assigned_location_model_ids

std::vector<int> mio::abm::Person::m_assigned_location_model_ids
private

Vector with model ids of the assigned locations. Only used in graph abm.

◆ m_assigned_locations

std::vector<LocationId> mio::abm::Person::m_assigned_locations
private

◆ m_cells

std::vector<uint32_t> mio::abm::Person::m_cells
private

Vector with all Cells the Person visits at its current Location.

◆ m_compliance

std::vector<ScalarType> mio::abm::Person::m_compliance
private

Vector of compliance values for all InterventionTypes. Values from 0 to 1.

◆ m_home_isolation_start

TimePoint mio::abm::Person::m_home_isolation_start
private

TimePoint when the Person started isolation at home.

◆ m_infections

std::vector<Infection> mio::abm::Person::m_infections
private

Vector with all Infections the Person had.

◆ m_last_transport_mode

mio::abm::TransportMode mio::abm::Person::m_last_transport_mode
private

TransportMode the Person used to get to its current Location.

◆ m_location

LocationId mio::abm::Person::m_location
private

Current Location of the Person.

◆ m_location_model_id

int mio::abm::Person::m_location_model_id
private

Model id of the current Location. Only used for Graph ABM.

◆ m_location_type

LocationType mio::abm::Person::m_location_type
private

Type of the current Location.

◆ m_mask

Mask mio::abm::Person::m_mask
private

The Mask of the Person.

◆ m_person_id

PersonId mio::abm::Person::m_person_id
private

Unique identifier of a person.

◆ m_random_goto_school_hour

ScalarType mio::abm::Person::m_random_goto_school_hour
private

Value to determine at what time the Person goes to school.

◆ m_random_goto_work_hour

ScalarType mio::abm::Person::m_random_goto_work_hour
private

Value to determine at what time the Person goes to work.

◆ m_random_schoolgroup

ScalarType mio::abm::Person::m_random_schoolgroup
private

Value to determine if the Person goes to school or stays at home during lockdown.

◆ m_random_workgroup

ScalarType mio::abm::Person::m_random_workgroup
private

Value to determine if the Person goes to work or works from home during lockdown.

◆ m_rng_counter

Counter<uint32_t> mio::abm::Person::m_rng_counter {0}
private

counter for RandomNumberGenerator.

◆ m_rng_index

uint32_t mio::abm::Person::m_rng_index
private

◆ m_rng_key

mio::Key<uint64_t> mio::abm::Person::m_rng_key
private

◆ m_test_results

CustomIndexArray<TestResult, TestType> mio::abm::Person::m_test_results
private

CustomIndexArray for TestResults.

◆ m_time_at_location

TimeSpan mio::abm::Person::m_time_at_location
private

Time the Person has spent at its current Location so far.

◆ m_vaccinations

std::vector<ProtectionEvent> mio::abm::Person::m_vaccinations
private

! Vector with the indices of the assigned Locations so that the Person always visits the same Home or School etc.

Vector with all vaccinations the Person has received.