Skip to content

Class ContactTracing

ClassList > ContactTracing

Class for tracing contacts between agents. More...

  • #include <contacttracing-bones.hpp>

Public Functions

Type Name
ContactTracing ()
ContactTracing (size_t n_agents, size_t max_contacts)
Construct a new Contact Tracing object.
void add_contact (size_t agent_a, size_t agent_b, size_t day)
Add a contact between two agents at a given day.
std::pair< size_t, size_t > get_contact (size_t agent, size_t idx)
Get the contact object.
size_t get_n_contacts (size_t agent)
Get the number of contacts for an agent.
void print (size_t agent)
Print the contacts of an agent.
void reset (size_t n_agents, size_t max_contacts)
Reset the contact tracing data.

Detailed Description

The class assumes that contacts are stored in a matrix-like structure, where rows are agents and columns are contacts in a column-major format. Each entry stores the id of the contact and the day of the contact is stored in a parallel array.

The maximum number of contacts per agent is fixed at initialization time. If more contacts are added, they will overwrite previous contacts in a circular buffer fashion.

Public Functions Documentation

function ContactTracing [1/2]

inline ContactTracing::ContactTracing () 

function ContactTracing [2/2]

Construct a new Contact Tracing object.

inline ContactTracing::ContactTracing (
    size_t n_agents,
    size_t max_contacts
) 

Parameters:

  • n_agents Agents in the system, usually Model <TSeq>::size().
  • max_contacts Maximum number of contacts to track per agent.

function add_contact

Add a contact between two agents at a given day.

inline void ContactTracing::add_contact (
    size_t agent_a,
    size_t agent_b,
    size_t day
) 

Parameters:


function get_contact

Get the contact object.

inline std::pair< size_t, size_t > ContactTracing::get_contact (
    size_t agent,
    size_t idx
) 

Parameters:

  • agent Source agent (id)
  • idx Index of the contact (0 to get_n_contacts(agent)-1)

Returns:

std::pair<size_t, size_t> with (contact_id, contact_day)

Exception:

  • std::out_of_range if idx is out of range.

function get_n_contacts

Get the number of contacts for an agent.

inline size_t ContactTracing::get_n_contacts (
    size_t agent
) 

Parameters:

Returns:

size_t Number of contacts recorded for that agent (can be more than max_contacts)


function print

Print the contacts of an agent.

inline void ContactTracing::print (
    size_t agent
) 

Parameters:


function reset

Reset the contact tracing data.

inline void ContactTracing::reset (
    size_t n_agents,
    size_t max_contacts
) 

Usually called by Model <TSeq>:: reset().

Parameters:

  • n_agents Number of agents
  • max_contacts Maximum number of contacts to track per agent


The documentation for this class was generated from the following file epiworld-src/include/epiworld/contacttracing-bones.hpp