Class DataBase¶
template <typename TSeq>
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]¶
function DataBase [2/3]¶
function DataBase [3/3]¶
function add_user_data [1/2]¶
function add_user_data [2/2]¶
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_idvectors 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.
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:
dateOutput vector for dates.virus_idOutput vector for virus IDs.tool_idOutput vector for tool IDs.countOutput vector for counts (number of hospitalized individuals).weightOutput 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¶
function get_n_tools¶
Get the number of tools.
function get_n_viruses¶
Get the number of viruses.
function get_nexposed¶
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.
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:
fnFile 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]¶
function get_sequence¶
function get_today_total [1/3]¶
function get_today_total [2/3]¶
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¶
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:
printPrint the transition matrix.normalizeNormalize 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:
datesourcetargetvirussource_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¶
function operator!=¶
function operator==¶
function operator==¶
function record¶
function record_hospitalization¶
Record a hospitalization event for an agent.
Parameters:
agentReference 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¶
function record_transmission¶
function record_virus¶
Registering a new variant.
Parameters:
vPointer 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¶
function set_seq_hasher¶
function set_user_data¶
function size¶
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