Skip to content

Class DataBase

template <typename TSeq>

ClassList > DataBase

Statistical data about the process. More...

  • #include <database-bones.hpp>

Public Functions

Type Name
DataBase () = delete
DataBase (Model< TSeq > & m)
DataBase (const DataBase< TSeq > & db)
void add_user_data (std::vector< epiworld_double > x)
void add_user_data (epiworld_fast_uint j, epiworld_double x)
void get_active_cases (std::vector< int > & date, std::vector< int > & virus_id, std::vector< int > & count) const
void get_generation_time (std::vector< int > & agent_id, std::vector< int > & virus_id, std::vector< int > & time, std::vector< int > & gentime) const
Get the generation time.
void get_generation_time (std::string fn) const
Write the generation time to a file.
void get_hist_tool (std::vector< int > & date, std::vector< int > & id, std::vector< std::string > & state, std::vector< int > & counts) const
void get_hist_total (std::vector< int > * date, std::vector< std::string > * state, std::vector< int > * counts) const
void get_hist_transition_matrix (std::vector< std::string > & state_from, std::vector< std::string > & state_to, std::vector< int > & date, std::vector< int > & counts, bool skip_zeros) const
void get_hist_virus (std::vector< int > & date, std::vector< int > & id, std::vector< std::string > & state, std::vector< int > & counts) const
void get_hospitalizations (std::vector< int > & date, std::vector< int > & virus_id, std::vector< int > & tool_id, std::vector< int > & count, std::vector< double > & weight) const
Get the full time series of hospitalization data.
Model< TSeq > * get_model ()
size_t get_n_tools () const
Get the number of tools.
size_t get_n_viruses () const
Get the number of viruses.
const std::vector< int > & get_nexposed () const
void get_outbreak_size (std::vector< int > & date, std::vector< int > & virus_id, std::vector< int > & size) const
MapVec_type< int, int > get_reproductive_number () const
Computes the reproductive number of each case.
void get_reproductive_number (std::string fn) const
const std::vector< TSeq > & get_sequence () const
int get_today_total (const std::string & what) const
int get_today_total (const epiworld_fast_uint & what) const
void get_today_total (std::vector< std::string > * state=nullptr, std::vector< int > * counts=nullptr) const
void get_today_transition_matrix (std::vector< int > & counts) const
void get_today_virus (std::vector< std::string > & state, std::vector< int > & id, std::vector< int > & counts) const
std::vector< epiworld_double > get_transition_probability (bool print=true, bool normalize=true) const
Calculates the transition probabilities.
void get_transmissions (std::vector< int > & date, std::vector< int > & source, std::vector< int > & target, std::vector< int > & virus, std::vector< int > & source_exposure_date) const
Get the transmissions object.
void get_transmissions (int * date, int * source, int * target, int * virus, int * source_exposure_date) const
UserData< TSeq > & get_user_data ()
bool operator!= (const DataBase< TSeq > & other) const
bool operator== (const DataBase< TSeq > & other) const
bool operator== (const DataBase< std::vector< int > > & other) const
void record ()
void record_hospitalization (Agent< TSeq > & agent)
Record a hospitalization event for an agent.
void record_tool (Tool< TSeq > & t)
void record_transmission (int i, int j, int virus, int i_expo_date)
void record_virus (Virus< TSeq > & v)
Registering a new variant.
void reset ()
void set_seq_hasher (std::function< std::vector< int >(TSeq)> fun)
void set_user_data (std::vector< std::string > names)
size_t size () const
void write_data (std::string fn_virus_info, std::string fn_virus_hist, std::string fn_tool_info, std::string fn_tool_hist, std::string fn_total_hist, std::string fn_transmission, std::string fn_transition, std::string fn_reproductive_number, std::string fn_generation_time, std::string fn_active_cases, std::string fn_outbreak_size, std::string fn_hospitalizations) const

Detailed Description

Template parameters:

  • TSeq

Public Functions Documentation

function DataBase [1/3]

DataBase::DataBase () = delete

function DataBase [2/3]

inline DataBase::DataBase (
    Model < TSeq > & m
) 

function DataBase [3/3]

inline DataBase::DataBase (
    const DataBase < TSeq > & db
) 

function add_user_data [1/2]

inline void DataBase::add_user_data (
    std::vector< epiworld_double > x
) 

function add_user_data [2/2]

inline void DataBase::add_user_data (
    epiworld_fast_uint j,
    epiworld_double x
) 

function get_active_cases

inline void DataBase::get_active_cases (
    std::vector< int > & date,
    std::vector< int > & virus_id,
    std::vector< int > & count
) const

function get_generation_time [1/2]

Get the generation time.

inline void DataBase::get_generation_time (
    std::vector< int > & agent_id,
    std::vector< int > & virus_id,
    std::vector< int > & time,
    std::vector< int > & gentime
) const

Calculates the generating time

Parameters:

  • agent_id vectors where to save the values

The generation time is the time between the infection of the source and the infection of the target.


function get_generation_time [2/2]

Write the generation time to a file.

inline void DataBase::get_generation_time (
    std::string fn
) const


function get_hist_tool

inline void DataBase::get_hist_tool (
    std::vector< int > & date,
    std::vector< int > & id,
    std::vector< std::string > & state,
    std::vector< int > & counts
) const

function get_hist_total

inline void DataBase::get_hist_total (
    std::vector< int > * date,
    std::vector< std::string > * state,
    std::vector< int > * counts
) const

function get_hist_transition_matrix

inline void DataBase::get_hist_transition_matrix (
    std::vector< std::string > & state_from,
    std::vector< std::string > & state_to,
    std::vector< int > & date,
    std::vector< int > & counts,
    bool skip_zeros
) const

function get_hist_virus

inline void DataBase::get_hist_virus (
    std::vector< int > & date,
    std::vector< int > & id,
    std::vector< std::string > & state,
    std::vector< int > & counts
) const

function get_hospitalizations

Get the full time series of hospitalization data.

inline void DataBase::get_hospitalizations (
    std::vector< int > & date,
    std::vector< int > & virus_id,
    std::vector< int > & tool_id,
    std::vector< int > & count,
    std::vector< double > & weight
) const

Parameters:

  • date Output vector for dates.
  • virus_id Output vector for virus IDs.
  • tool_id Output vector for tool IDs.
  • count Output vector for counts (number of hospitalized individuals).
  • weight Output vector for summed weights (fractional contribution based on tool distribution).

Returns the full time series of hospitalization data. For each unique (virus_id, tool_id) combination observed, returns an entry for every day from 0 to ndays-1.

The count vector contains the actual number of individuals hospitalized for that (date, virus_id, tool_id) combination. This is useful for answering questions like "how many total people were hospitalized?" regardless of their tools.

The weight vector contains fractional contributions: if an agent has N tools, each tool gets weight = 1/N. Summing weights across all tool_ids for a given date and virus_id gives the total number of hospitalizations.


function get_model

inline Model < TSeq > * DataBase::get_model () 

function get_n_tools

Get the number of tools.

inline size_t DataBase::get_n_tools () const


function get_n_viruses

Get the number of viruses.

inline size_t DataBase::get_n_viruses () const


function get_nexposed

const std::vector< int > & DataBase::get_nexposed () const

function get_outbreak_size

inline void DataBase::get_outbreak_size (
    std::vector< int > & date,
    std::vector< int > & virus_id,
    std::vector< int > & size
) const

function get_reproductive_number [1/2]

Computes the reproductive number of each case.

inline MapVec_type < int, int > DataBase::get_reproductive_number () const

By definition, whereas it computes R0 (basic reproductive number) or Rt/R (the effective reproductive number) will depend on whether the virus is allowed to circulate naïvely or not, respectively.

Parameters:

  • fn File where to write out the reproductive number.

In the case of MapVec_type<int,int>, the key is a vector of 3 integers: * Virus id * Source id * Date when the source was infected


function get_reproductive_number [2/2]

inline void DataBase::get_reproductive_number (
    std::string fn
) const

function get_sequence

inline const std::vector< TSeq > & DataBase::get_sequence () const

function get_today_total [1/3]

inline int DataBase::get_today_total (
    const std::string & what
) const

function get_today_total [2/3]

int DataBase::get_today_total (
    const epiworld_fast_uint & what
) const

function get_today_total [3/3]

inline void DataBase::get_today_total (
    std::vector< std::string > * state=nullptr,
    std::vector< int > * counts=nullptr
) const

function get_today_transition_matrix

inline void DataBase::get_today_transition_matrix (
    std::vector< int > & counts
) const

function get_today_virus

inline void DataBase::get_today_virus (
    std::vector< std::string > & state,
    std::vector< int > & id,
    std::vector< int > & counts
) const

function get_transition_probability

Calculates the transition probabilities.

inline std::vector< epiworld_double > DataBase::get_transition_probability (
    bool print=true,
    bool normalize=true
) const

Parameters:

  • print Print the transition matrix.
  • normalize Normalize the transition matrix. Otherwise, it returns raw counts.

The transition matrix is the matrix of the counts of transitions from one state to another. So the ij-th element of the matrix is the number of transitions from state i to state j (when not normalized), or the probability of transitioning from state i to state j (when normalized).

Returns:

std::vector< epiworld_double >


function get_transmissions [1/2]

Get the transmissions object.

inline void DataBase::get_transmissions (
    std::vector< int > & date,
    std::vector< int > & source,
    std::vector< int > & target,
    std::vector< int > & virus,
    std::vector< int > & source_exposure_date
) const

Parameters:

  • date
  • source
  • target
  • virus
  • source_exposure_date

function get_transmissions [2/2]

inline void DataBase::get_transmissions (
    int * date,
    int * source,
    int * target,
    int * virus,
    int * source_exposure_date
) const

function get_user_data

inline UserData < TSeq > & DataBase::get_user_data () 

function operator!=

inline bool DataBase::operator!= (
    const DataBase < TSeq > & other
) const

function operator==

inline bool DataBase::operator== (
    const DataBase < TSeq > & other
) const

function operator==

inline bool DataBase::operator== (
    const DataBase < std::vector< int > > & other
) const

function record

inline void DataBase::record () 

function record_hospitalization

Record a hospitalization event for an agent.

inline void DataBase::record_hospitalization (
    Agent < TSeq > & agent
) 

Parameters:

  • agent Reference to the agent being hospitalized.

For each hospitalization, the method records: * The current date from the model * The virus ID from the agent's virus * For each tool the agent has, a separate record with weight = 1/N where N is the number of tools * If the agent has no tools, a single record with tool_id = -1 and weight = 1.0


function record_tool

inline void DataBase::record_tool (
    Tool < TSeq > & t
) 

function record_transmission

inline void DataBase::record_transmission (
    int i,
    int j,
    int virus,
    int i_expo_date
) 

function record_virus

Registering a new variant.

inline void DataBase::record_virus (
    Virus < TSeq > & v
) 

Parameters:

  • v Pointer to the new virus. Since viruses are originated in the agent, the numbers simply move around. From the parent virus to the new virus. And the total number of infected does not change.

function reset

inline void DataBase::reset () 

function set_seq_hasher

void DataBase::set_seq_hasher (
    std::function< std::vector< int >(TSeq)> fun
) 

function set_user_data

inline void DataBase::set_user_data (
    std::vector< std::string > names
) 

function size

inline size_t DataBase::size () const

function write_data

inline void DataBase::write_data (
    std::string fn_virus_info,
    std::string fn_virus_hist,
    std::string fn_tool_info,
    std::string fn_tool_hist,
    std::string fn_total_hist,
    std::string fn_transmission,
    std::string fn_transition,
    std::string fn_reproductive_number,
    std::string fn_generation_time,
    std::string fn_active_cases,
    std::string fn_outbreak_size,
    std::string fn_hospitalizations
) const


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