Skip to content

Class epiworld::Model

template <typename TSeq>

ClassList > epiworld > Model

Core class of epiworld. More...

  • #include <epiworld.hpp>

Classes

Type Name
struct TransmissionSums
The sums "auto" compares to choose between push and pull.

Public Attributes

Type Name
std::array< epiworld_double, 1024u *2u > array_double_tmp
std::array< Virus< TSeq > *, 1024u *2u > array_virus_tmp

Public Functions

Type Name
Model ()
Model (const Model< TSeq > & m)
Model (Model< TSeq > && m)
bool add_edge (size_t i, size_t j)
void add_entity (Entity< TSeq > e)
void add_globalevent (std::function< void(Model< TSeq > *)> fun, std::string name="A global action", int date=-99)
Set a global action.
void add_globalevent (GlobalEvent< TSeq > & action)
epiworld_double add_param (epiworld_double initial_val, std::string pname, bool overwrite=false)
epiworld_fast_int add_state (std::string lab, UpdateFun< TSeq > fun=nullptr)
void add_tool (Tool< TSeq > & t)
void add_user_data (epiworld_fast_uint j, epiworld_double x)
void add_user_data (std::vector< epiworld_double > x)
void add_virus (Virus< TSeq > & v)
Model< TSeq > & agents_bernoulli (epiworld_fast_uint n, epiworld_double p, bool d=false)
void agents_empty_graph (epiworld_fast_uint n=1000)
Replaces the network with n agents and no ties (undirected).
void agents_from_adjlist (std::string fn, int size, int skip=0, bool directed=false)
void agents_from_adjlist (const AdjList & al)
void agents_from_edgelist (const std::vector< int > & source, const std::vector< int > & target, int size, bool directed)
Model< TSeq > & agents_sbm (const std::vector< size_t > & block_sizes, const std::vector< double > & mixing_matrix, bool row_major=true)
Initialize agents using a Stochastic Block Model (SBM).
Model< TSeq > & agents_smallworld (epiworld_fast_uint n=1000, epiworld_fast_uint k=5, bool d=false, epiworld_double p=.01)
Model< TSeq > & clear_post_sampling ()
Remove the callback.
void clear_state_set ()
Model< TSeq > & contact_tracing_off ()
Deactivates contact tracing.
Model< TSeq > & contact_tracing_on (size_t max_contacts=EPI_MAX_TRACKING)
Activates contact tracing.
void draw (DiagramType diagram_type=DiagramType::Mermaid, const std::string & fn_output="", bool self=false)
Draws a mermaid diagram of the model.
void events_run ()
Executes the stored action.
Agent< TSeq > & get_agent (size_t i)
const char * get_agent_carrier () const
One flag per agent: 1 if the agent carries a virus.
std::vector< Agent< TSeq > > & get_agents ()
Returns a reference to the vector of agents.
double * get_agents_data ()
size_t get_agents_data_ncols () const
AgentIdsView get_agents_in_state (epiworld_fast_uint state) const
Ids of the agents currently in a state.
std::vector< epiworld_fast_uint > get_agents_states () const
Returns a vector with the states of the agents.
std::vector< Viruses_const< TSeq > > get_agents_viruses () const
Returns a const vector with the viruses of the agents.
std::vector< Viruses< TSeq > > get_agents_viruses ()
Returns a vector with the viruses of the agents.
ContactTracing & get_contact_tracing ()
Retrieve the ContactTracing object.
DataBase< TSeq > & get_db ()
const DataBase< TSeq > & get_db () const
void get_elapsed (std::string unit="auto", epiworld_double * last_elapsed=nullptr, epiworld_double * total_elapsed=nullptr, std::string * unit_abbr=nullptr, bool print=true) const
std::vector< Entity< TSeq > > & get_entities ()
Entity< TSeq > & get_entity (size_t entity_id, int * entity_pos=nullptr)
const Entity< TSeq > & get_entity (size_t entity_id, int * entity_pos=nullptr) const
GlobalEvent< TSeq > & get_globalevent (std::string name)
Retrieve a global action by name.
GlobalEvent< TSeq > & get_globalevent (size_t i)
Retrieve a global action by index.
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.
TransmissionMode get_last_transmission_mode () const
The mode used in the most recent step ( push orpull ).
size_t get_n_entities () const
size_t get_n_globalevents () const
Number of global actions registered.
size_t get_n_params () const
epiworld_fast_uint get_n_replicates () const
size_t get_n_states () const
size_t get_n_tools () const
Number of tools in the model.
size_t get_n_viruses () const
Number of viruses in the model.
std::string get_name () const
epiworld_fast_uint get_ndays () const
epiworld_double get_param (std::string_view pname) const
ParamId get_param_id (std::string_view pname) const
uint32_t get_param_layout_id () const
Queue< TSeq > & get_queue ()
Retrieve the Queue object.
std::shared_ptr< epi_xoshiro256ss > & get_rand_endgine ()
epiworld_double get_rewire_prop () const
size_t get_sim_id () const
const std::vector< UpdateFun< TSeq > > & get_state_fun () const
const std::vector< std::string > & get_states () const
Tool< TSeq > & get_tool (size_t id)
Tool< TSeq > & get_tool (std::string_view name)
const std::vector< ToolPtr< TSeq > > & get_tools () const
double get_transmission_kappa () const
The threshold used by "auto" .
TransmissionMode get_transmission_mode () const
TransmissionSums get_transmission_sums () const
UserData< TSeq > & get_user_data ()
bool get_verbose () const
Virus< TSeq > & get_virus (size_t id)
Virus< TSeq > & get_virus (std::string_view name)
const std::vector< VirusPtr< TSeq > > & get_viruses () const
bool has_edge (size_t i, size_t j) const
Whether i andj are tied. In a directed network, whetheri -> j is.
bool has_globalevent (std::string_view name) const
Whether a global action by that name exists.
bool has_param (std::string_view pname) const
bool has_post_sampling () const
Is a callback installed?
bool has_rewire_fun () const
Whether a rewiring function is set. rewire() calls it on every step, whatever the proportion.
bool has_tool (std::string_view name) const
bool has_virus (std::string_view name) const
virtual Model< TSeq > & initial_states (std::vector< double >, std::vector< int >)
bool is_contact_tracing_on () const
Query if contact tracing is on.
bool is_directed () const
Whether the network was built directed.
bool is_queuing_on () const
Query if the queuing system is on.
bool is_running () const
True while run() is driving the day loop.
void load_agents_entities_ties (const std::vector< int > & agents_ids, const std::vector< int > & entities_ids)
Associate agents-entities from data.
void load_agents_entities_ties (const int * agents_id, const int * entities_id, size_t n)
void mutate_virus ()
virtual void next ()
bool operator!= (const Model< TSeq > & other) const
epiworld_double operator() (std::string_view pname) const
Model< TSeq > & operator= (const Model< TSeq > & m)
bool operator== (const Model< TSeq > & other) const
epiworld_double par (std::string_view pname) const
epiworld_double par_at (ParamId id) const
std::map< std::string, epiworld_double > params () const
Copy of the model parameters, by name.
const Model< TSeq > & print (bool lite=false) const
void print_state_codes () const
Model< TSeq > & queuing_off ()
Deactivates the queuing system.
void queuing_on ()
Activates the queuing system (default.).
int rbinom ()
Draw from the currently configured binomial distribution.
int rbinom (int n, epiworld_double p)
Draw from a binomial distribution with parameters n andp .
Model< TSeq > & read_params (std::string fn, bool overwrite=false)
void record_hospitalization (Agent< TSeq > & agent)
Record a hospitalization event for an agent.
void register_sampled_contact (size_t infectious_id, size_t contacted_id)
void register_sampled_contacts (const size_t * infectious_ids, size_t n, size_t contacted_id)
Same, for several infectious agents in contact with contacted_id .
virtual void reset ()
Reset the model.
void rewire ()
epiworld_double rexp ()
epiworld_double rexp (epiworld_double lambda)
epiworld_double rgamma ()
epiworld_double rgamma (epiworld_double alpha, epiworld_double beta)
int rgeom ()
int rgeom (epiworld_double p)
epiworld_double rlognormal ()
epiworld_double rlognormal (epiworld_double mean, epiworld_double shape)
bool rm_edge (size_t i, size_t j)
void rm_entity (size_t entity_id)
void rm_globalevent (std::string name)
Remove a global action by name.
void rm_globalevent (size_t i)
Remove a global action by index.
void rm_tool (size_t tool_pos)
void rm_virus (size_t virus_pos)
int rnbinom ()
int rnbinom (int n, epiworld_double p)
epiworld_double rnorm ()
epiworld_double rnorm (epiworld_double mean, epiworld_double sd)
int rpoiss ()
int rpoiss (epiworld_double lambda)
virtual Model< TSeq > & run (epiworld_fast_uint ndays, int seed=-1)
Runs the simulation (after initialization).
void run_globalevents ()
Model< TSeq > & run_multiple (epiworld_fast_uint ndays, epiworld_fast_uint nexperiments, int seed_=-1, std::function< void(size_t, Model< TSeq > *)> fun=make_save_run< TSeq >(), bool reset=true, bool verbose=true, int nthreads=1)
epiworld_double runif ()
Draw from the currently configured uniform distribution.
epiworld_double runif (epiworld_double a, epiworld_double b)
uint32_t runif_index (uint32_t n)
int runif_int (int a, int b)
size_t sample_from_probs (size_t n)
Sample from a set of probabilities stored in array_double_tmp.
void seed (size_t s)
void set_agents_data (double * data_, size_t ncols_)
Set the agents data object.
void set_backup ()
void set_name (std::string name)
Set the name object.
void set_ndays (epiworld_fast_uint ndays)
void set_param (std::string_view pname, epiworld_double val)
void set_param_at (ParamId id, epiworld_double val)
Model< TSeq > & set_post_sampling (PostSamplingFun< TSeq > fun)
Install a callback (an empty function clears it).
void set_rand_binom (int n, epiworld_double p)
void set_rand_engine (std::shared_ptr< epi_xoshiro256ss > & eng)
void set_rand_exp (epiworld_double lambda)
void set_rand_gamma (epiworld_double alpha, epiworld_double beta)
void set_rand_geom (epiworld_double p)
void set_rand_lognormal (epiworld_double mean, epiworld_double shape)
void set_rand_nbinom (int n, epiworld_double p)
void set_rand_norm (epiworld_double mean, epiworld_double sd)
void set_rand_poiss (epiworld_double lambda)
void set_rand_unif (epiworld_double a, epiworld_double b)
void set_rewire_fun (std::function< void(std::vector< Agent< TSeq > > *, Model< TSeq > *, epiworld_double)> fun)
void set_rewire_prop (epiworld_double prop)
Model< TSeq > & set_state_function (epiworld_fast_uint state, UpdateFun< TSeq > fun=nullptr)
Model< TSeq > & set_state_function (std::string_view name, UpdateFun< TSeq > fun=nullptr)
Model< TSeq > & set_transmission_mode (TransmissionMode mode, double kappa=EPI_DEFAULT_TRANSMISSION_KAPPA)
Model< TSeq > & set_transmission_mode (std::string_view mode, double kappa=EPI_DEFAULT_TRANSMISSION_KAPPA)
void set_user_data (std::vector< std::string > names)
[@
size_t size () const
epiworld_fast_int state_of (std::string_view name)
int today () const
The current time of the model.
void update_state ()
Model< TSeq > & verbose_off ()
Model< TSeq > & verbose_on ()
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
Wrapper of DataBase::write_data .
void write_edgelist (std::string fn) const
void write_edgelist (std::vector< int > & source, std::vector< int > & target) const
virtual ~Model ()

Protected Attributes

Type Name
std::vector< char > agent_carrier
[agent] 1 if Agent::virus is set, compact for scans
std::vector< unsigned int > agent_state
[agent] Copy of Agent::state , compact for scans
double * agents_data = nullptr
size_t agents_data_ncols = 0u
std::unique_ptr< ContactTracing > contact_tracing
size_t contact_tracing_max_contacts = [**EPI\_MAX\_TRACKING**](config_8hpp.md#define-epi_max_tracking)
int current_date = 0
DataBase< TSeq > db = [**DataBase**](classDataBase.md)&lt;TSeq&gt;(\*this)
bool directed = false
std::shared_ptr< epi_xoshiro256ss > engine = std::make\_shared&lt; [**epi\_xoshiro256ss**](classepi__xoshiro256ss.md) &gt;()
std::vector< Entity< TSeq > > entities = {}
std::vector< Event< TSeq > > events = {}
Variables used to keep track of the events to be made regarding viruses.
std::vector< GlobalEventPtr< TSeq > > globalevents
std::function< void(Model< TSeq > *)> initial_states_fun = /* multi line expression */
int last_seed = 0
epiworld_fast_uint n_replicates = 0u
epiworld_fast_uint nactions = 0u
std::string name = ""
Name of the model.
epiworld_fast_uint ndays = 0
epiworld_fast_uint nstates = 0u
std::map< std::string, size_t, std::less<> > param_index
uint32_t param_layout_id = [**new\_param\_layout\_id**](namespaceepiworld.md#function-new_param_layout_id)()
std::vector< epiworld_double > param_values
Progress pb
std::vector< Agent< TSeq > > population = {}
std::vector< Agent< TSeq > > population_backup = {}
std::vector< size_t > population_left
size_t population_left_n = 0u
PostSamplingFun< TSeq > post_sampling_fun = nullptr
See set_post_sampling() .
bool post_sampling_on = false
post_sampling_fun is set
PostSamplingScratch post_sampling_scratch
Never copied.
std::vector< char > push_default
[state] ...and it is default_update_susceptible
std::vector< char > push_excluded
[target state * nstates + source state]
std::vector< char > push_pushable
[state] Uses the default susceptible sampler
std::vector< int > push_slot
[agent] Index in push_targets, or -1
std::vector< char > push_source_ok
[state] Some pushable state accepts it as source
std::vector< uint64_t > push_sources
[agent bit] Carriers that push this step
std::vector< PushTarget > push_targets
std::vector< uint64_t > push_visit
[agent bit] To update after a push
Queue< TSeq > queue
std::binomial_distribution rbinomd = /* multi line expression */
epiworld_double rbinomd_fast_lambda = 0.0
int rbinomd_n = 1
bool rbinomd_use_poisson = false
std::function< void(std::vector< Agent< TSeq > > *, Model< TSeq > *, epiworld_double)> rewire_fun
epiworld_double rewire_prop = 0.0
std::exponential_distribution rexpd = /* multi line expression */
std::gamma_distribution rgammad = /* multi line expression */
std::geometric_distribution rgeomd = /* multi line expression */
std::lognormal_distribution rlognormald = /* multi line expression */
std::negative_binomial_distribution rnbinomd = /* multi line expression */
std::normal_distribution rnormd = /* multi line expression */
std::poisson_distribution rpoissd = /* multi line expression */
epiworld_double runifd_a = 0.0
epiworld_double runifd_b = 1.0
bool running = false
std::vector< Agent< TSeq > * > sampled_population
size_t sampled_population_n = 0u
size_t sim_id = 0u
std::vector< size_t > state_carrier_degree
std::vector< size_t > state_carriers
std::vector< size_t > state_degree
std::vector< UpdateFun< TSeq > > state_fun = {}
Functions to update states.
bool state_index_ready = false
std::vector< size_t > state_member_pos
[agent] Position in state_order
std::vector< size_t > state_order
[N] Agent ids, grouped by state
std::vector< size_t > state_start
[nstates + 1] Where each state's block starts
std::vector< std::string > states_labels = {}
Labels of the states.
std::chrono::duration< epiworld_double, std::micro > time_elapsed = /* multi line expression */
std::chrono::time_point< std::chrono::steady_clock > time_end
std::chrono::time_point< std::chrono::steady_clock > time_start
std::vector< ToolPtr< TSeq > > tools = {}
double transmission_kappa = [**EPI\_DEFAULT\_TRANSMISSION\_KAPPA**](config_8hpp.md#define-epi_default_transmission_kappa)
TransmissionMode transmission_mode = TransmissionMode::automatic
TransmissionMode transmission_mode_last = TransmissionMode::pull
bool use_contact_tracing = false
bool use_queuing = true
bool using_backup = true
bool verbose = true
std::vector< VirusPtr< TSeq > > viruses = {}

Protected Functions

Type Name
void _add_event (Agent< TSeq > * agent_, VirusPtr< TSeq > virus_, ToolPtr< TSeq > tool_, Entity< TSeq > * entity_, epiworld_fast_int new_state_, epiworld_fast_int queue_, EventAction action_)
Construct a new Event object.
void _event_add_entity (Event< TSeq > & a)
void _event_add_tool (Event< TSeq > & a)
void _event_add_virus (Event< TSeq > & a)
void _event_change_state (Event< TSeq > & a)
void _event_rm_entity (Event< TSeq > & a)
void _event_rm_tool (Event< TSeq > & a)
void _event_rm_virus (Event< TSeq > & a)
void agents_set_neighbors (const std::vector< size_t > & start, std::vector< size_t > & ids)
Sets every agent's neighbors from rows of a flat array.
void check_edge_endpoints (size_t i, size_t j) const
Validates the arguments of add_edge() /rm_edge() .
void chrono_end ()
void chrono_start ()
virtual std::unique_ptr< Model< TSeq > > clone_ptr ()
Advanced usage: Makes a copy of data and returns it as undeleted pointer.
virtual epiworld_double death_reduction_mixer (Agent< TSeq > * agent, VirusPtr< TSeq > & virus)
void dist_entities ()
void dist_tools ()
void dist_virus ()
void post_sampling_dispatch ()
void post_sampling_prepare_scratch ()
Sizes the scratch for the population.
virtual epiworld_double recovery_enhancer_mixer (Agent< TSeq > * agent, VirusPtr< TSeq > & virus)
void set_sim_id (size_t id)
void state_index_build ()
void state_index_degree (Agent< TSeq > & p, size_t n_neighbors_before)
AgentIdsView state_index_members (size_t state) const
void state_index_move (size_t id, unsigned int state_old, unsigned int state_new)
void state_index_update (Agent< TSeq > * p, unsigned int state_old, bool had_virus)
virtual epiworld_double susceptibility_reduction_mixer (Agent< TSeq > * agent, VirusPtr< TSeq > & virus)
bool transmission_choose_push () const
bool transmission_prepare ()
void transmission_push ()
void transmission_push_impl ()
virtual epiworld_double transmission_reduction_mixer (Agent< TSeq > * agent, VirusPtr< TSeq > & virus)
void transmission_update_others ()

Detailed Description

The model class provides the wrapper that puts together Agent, Virus, and Tools.

Template parameters:

  • TSeq Type of sequence. In principle, users can build models in which virus and human sequence is represented as numeric vectors (if needed.)

Public Attributes Documentation

variable array_double_tmp

std::array<epiworld_double, 1024u * 2u> epiworld::Model< TSeq >::array_double_tmp;

variable array_virus_tmp

std::array<Virus<TSeq> *, 1024u * 2u> epiworld::Model< TSeq >::array_virus_tmp;

Public Functions Documentation

function Model [1/3]

inline epiworld::Model::Model () 

function Model [2/3]

inline epiworld::Model::Model (
    const Model < TSeq > & m
) 

function Model [3/3]

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

function add_edge

inline bool epiworld::Model::add_edge (
    size_t i,
    size_t j
) 

Returns:

true if the tie was created, false if the two were already tied. An intervention that has to withdraw its own ties later should record only the ones this returned true for, so it never removes a tie the model already had.


function add_entity

inline void epiworld::Model::add_entity (
    Entity < TSeq > e
) 

function add_globalevent [1/2]

Set a global action.

inline void epiworld::Model::add_globalevent (
    std::function< void( Model < TSeq > *)> fun,
    std::string name="A global action",
    int date=-99
) 

Parameters:

  • fun A function to be called on the prescribed date
  • name Name of the action.
  • date Integer indicating when the function is called (see details)

When date is less than zero, then the function is called at the end of every day. Otherwise, the function will be called only at the end of the indicated date.


function add_globalevent [2/2]

inline void epiworld::Model::add_globalevent (
    GlobalEvent < TSeq > & action
) 

function add_param

inline epiworld_double epiworld::Model::add_param (
    epiworld_double initial_val,
    std::string pname,
    bool overwrite=false
) 

function add_state

inline epiworld_fast_int epiworld::Model::add_state (
    std::string lab,
    UpdateFun < TSeq > fun=nullptr
) 

function add_tool

inline void epiworld::Model::add_tool (
    Tool < TSeq > & t
) 

function add_user_data [1/2]

inline void epiworld::Model::add_user_data (
    epiworld_fast_uint j,
    epiworld_double x
) 

function add_user_data [2/2]

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

function add_virus

inline void epiworld::Model::add_virus (
    Virus < TSeq > & v
) 

function agents_bernoulli

inline Model < TSeq > & epiworld::Model::agents_bernoulli (
    epiworld_fast_uint n,
    epiworld_double p,
    bool d=false
) 

function agents_empty_graph

Replaces the network with n agents and no ties (undirected).

inline void epiworld::Model::agents_empty_graph (
    epiworld_fast_uint n=1000
) 


function agents_from_adjlist [1/2]

inline void epiworld::Model::agents_from_adjlist (
    std::string fn,
    int size,
    int skip=0,
    bool directed=false
) 

function agents_from_adjlist [2/2]

inline void epiworld::Model::agents_from_adjlist (
    const AdjList & al
) 

function agents_from_edgelist

inline void epiworld::Model::agents_from_edgelist (
    const std::vector< int > & source,
    const std::vector< int > & target,
    int size,
    bool directed
) 

function agents_sbm

Initialize agents using a Stochastic Block Model (SBM).

inline Model < TSeq > & epiworld::Model::agents_sbm (
    const std::vector< size_t > & block_sizes,
    const std::vector< double > & mixing_matrix,
    bool row_major=true
) 

Creates agents and connects them according to an SBM defined by block_sizes and mixing_matrix.

Parameters:

  • block_sizes Number of agents per block.
  • mixing_matrix Mixing matrix of size K*K; row sums give average expected degree per group.
  • row_major If true, matrix is row-major; otherwise column-major.

Returns:

Reference to this Model.

See also: rgraph_sbm


function agents_smallworld

inline Model < TSeq > & epiworld::Model::agents_smallworld (
    epiworld_fast_uint n=1000,
    epiworld_fast_uint k=5,
    bool d=false,
    epiworld_double p=.01
) 

function clear_post_sampling

Remove the callback.

inline Model < TSeq > & epiworld::Model::clear_post_sampling () 


function clear_state_set

void epiworld::Model::clear_state_set () 

function contact_tracing_off

Deactivates contact tracing.

inline Model < TSeq > & epiworld::Model::contact_tracing_off () 


function contact_tracing_on

Activates contact tracing.

inline Model < TSeq > & epiworld::Model::contact_tracing_on (
    size_t max_contacts=EPI_MAX_TRACKING
) 


function draw

Draws a mermaid diagram of the model.

inline void epiworld::Model::draw (
    DiagramType diagram_type=DiagramType::Mermaid,
    const std::string & fn_output="",
    bool self=false
) 

Parameters:

  • model The model to draw.
  • fn_output The name of the file to write the diagram. If empty, the diagram will be printed to the standard output.
  • self Whether to allow self-transitions.

function events_run

Executes the stored action.

inline void epiworld::Model::events_run () 

Parameters:

  • model_ Model over which it will be executed.

function get_agent

inline Agent < TSeq > & epiworld::Model::get_agent (
    size_t i
) 

function get_agent_carrier

One flag per agent: 1 if the agent carries a virus.

inline const char * epiworld::Model::get_agent_carrier () const

A compact copy of "has a virus", one byte per agent, so a scan of an agent's neighbors can rule most of them out without loading their Agent (a cache miss each). It is kept current from the moment a run starts. Returns nullptr before that (and after the population changes): callers then have to look at the agents.


function get_agents

Returns a reference to the vector of agents.

inline std::vector< Agent < TSeq > > & epiworld::Model::get_agents () 


function get_agents_data

inline double * epiworld::Model::get_agents_data () 

function get_agents_data_ncols

inline size_t epiworld::Model::get_agents_data_ncols () const

function get_agents_in_state

Ids of the agents currently in a state.

inline AgentIdsView epiworld::Model::get_agents_in_state (
    epiworld_fast_uint state
) const

The list is kept up to date as the model runs, so looking up who is in a state costs nothing (no scan of the population). The ids are in no particular order. The index is built when a run starts, so this is available once run() (or run_multiple()) has been called, and it reflects the model at its current step.

Parameters:

  • state The state code.

Returns:

A view of the ids (iterable, with size() and []); it is invalidated by the next step.

Exception:

  • std::logic_error if the model has not been run yet (or its population changed since).
  • std::range_error if state is not a state of the model.

function get_agents_states

Returns a vector with the states of the agents.

inline std::vector< epiworld_fast_uint > epiworld::Model::get_agents_states () const


function get_agents_viruses [1/2]

Returns a const vector with the viruses of the agents.

inline std::vector< Viruses_const < TSeq > > epiworld::Model::get_agents_viruses () const


function get_agents_viruses [2/2]

Returns a vector with the viruses of the agents.

inline std::vector< Viruses < TSeq > > epiworld::Model::get_agents_viruses () 


function get_contact_tracing

Retrieve the ContactTracing object.

inline ContactTracing & epiworld::Model::get_contact_tracing () 


function get_db [1/2]

inline DataBase < TSeq > & epiworld::Model::get_db () 

function get_db [2/2]

inline const DataBase < TSeq > & epiworld::Model::get_db () const

function get_elapsed

inline void epiworld::Model::get_elapsed (
    std::string unit="auto",
    epiworld_double * last_elapsed=nullptr,
    epiworld_double * total_elapsed=nullptr,
    std::string * unit_abbr=nullptr,
    bool print=true
) const

function get_entities

inline std::vector< Entity < TSeq > > & epiworld::Model::get_entities () 

function get_entity [1/2]

inline Entity < TSeq > & epiworld::Model::get_entity (
    size_t entity_id,
    int * entity_pos=nullptr
) 

function get_entity [2/2]

inline const Entity < TSeq > & epiworld::Model::get_entity (
    size_t entity_id,
    int * entity_pos=nullptr
) const

function get_globalevent [1/2]

Retrieve a global action by name.

GlobalEvent < TSeq > & epiworld::Model::get_globalevent (
    std::string name
) 


function get_globalevent [2/2]

Retrieve a global action by index.

GlobalEvent < TSeq > & epiworld::Model::get_globalevent (
    size_t i
) 


function get_hospitalizations

Get the full time series of hospitalization data.

inline void epiworld::Model::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).

This is a wrapper for DataBase::get_hospitalizations(). 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_last_transmission_mode

The mode used in the most recent step ( push orpull ).

inline TransmissionMode epiworld::Model::get_last_transmission_mode () const


function get_n_entities

inline size_t epiworld::Model::get_n_entities () const

function get_n_globalevents

Number of global actions registered.

inline size_t epiworld::Model::get_n_globalevents () const


function get_n_params

inline size_t epiworld::Model::get_n_params () const

function get_n_replicates

inline epiworld_fast_uint epiworld::Model::get_n_replicates () const

function get_n_states

inline size_t epiworld::Model::get_n_states () const

function get_n_tools

Number of tools in the model.

inline size_t epiworld::Model::get_n_tools () const


function get_n_viruses

Number of viruses in the model.

inline size_t epiworld::Model::get_n_viruses () const


function get_name

inline std::string epiworld::Model::get_name () const

function get_ndays

inline epiworld_fast_uint epiworld::Model::get_ndays () const

function get_param

inline epiworld_double epiworld::Model::get_param (
    std::string_view pname
) const

function get_param_id

inline ParamId epiworld::Model::get_param_id (
    std::string_view pname
) const

function get_param_layout_id

inline uint32_t epiworld::Model::get_param_layout_id () const

function get_queue

Retrieve the Queue object.

inline Queue < TSeq > & epiworld::Model::get_queue () 


function get_rand_endgine

inline std::shared_ptr< epi_xoshiro256ss > & epiworld::Model::get_rand_endgine () 

function get_rewire_prop

inline epiworld_double epiworld::Model::get_rewire_prop () const

function get_sim_id

inline size_t epiworld::Model::get_sim_id () const

function get_state_fun

inline const std::vector< UpdateFun < TSeq > > & epiworld::Model::get_state_fun () const

function get_states

inline const std::vector< std::string > & epiworld::Model::get_states () const

function get_tool [1/2]

inline Tool < TSeq > & epiworld::Model::get_tool (
    size_t id
) 

function get_tool [2/2]

inline Tool < TSeq > & epiworld::Model::get_tool (
    std::string_view name
) 

function get_tools

const std::vector< ToolPtr < TSeq > > & epiworld::Model::get_tools () const

function get_transmission_kappa

The threshold used by "auto" .

inline double epiworld::Model::get_transmission_kappa () const


function get_transmission_mode

inline TransmissionMode epiworld::Model::get_transmission_mode () const

function get_transmission_sums

inline TransmissionSums epiworld::Model::get_transmission_sums () const

function get_user_data

inline UserData < TSeq > & epiworld::Model::get_user_data () 

function get_verbose

inline bool epiworld::Model::get_verbose () const

function get_virus [1/2]

inline Virus < TSeq > & epiworld::Model::get_virus (
    size_t id
) 

function get_virus [2/2]

inline Virus < TSeq > & epiworld::Model::get_virus (
    std::string_view name
) 

function get_viruses

inline const std::vector< VirusPtr < TSeq > > & epiworld::Model::get_viruses () const

function has_edge

Whether i andj are tied. In a directed network, whetheri -> j is.

inline bool epiworld::Model::has_edge (
    size_t i,
    size_t j
) const


function has_globalevent

Whether a global action by that name exists.

inline bool epiworld::Model::has_globalevent (
    std::string_view name
) const


function has_param

inline bool epiworld::Model::has_param (
    std::string_view pname
) const

function has_post_sampling

Is a callback installed?

inline bool epiworld::Model::has_post_sampling () const


function has_rewire_fun

Whether a rewiring function is set. rewire() calls it on every step, whatever the proportion.

inline bool epiworld::Model::has_rewire_fun () const


function has_tool

inline bool epiworld::Model::has_tool (
    std::string_view name
) const

function has_virus

inline bool epiworld::Model::has_virus (
    std::string_view name
) const

function initial_states

inline virtual Model < TSeq > & epiworld::Model::initial_states (
    std::vector< double >,
    std::vector< int >
) 

function is_contact_tracing_on

Query if contact tracing is on.

inline bool epiworld::Model::is_contact_tracing_on () const


function is_directed

Whether the network was built directed.

inline bool epiworld::Model::is_directed () const


function is_queuing_on

Query if the queuing system is on.

inline bool epiworld::Model::is_queuing_on () const


function is_running

True while run() is driving the day loop.

inline bool epiworld::Model::is_running () const

It is set from just before reset() until the last day is done, so global events (including their reset()) can rely on get_ndays() being the run's horizon even when it is zero. It is false when the day loop is driven by hand (reset(), then the steps called directly), where get_ndays() means nothing.


function load_agents_entities_ties [1/2]

Associate agents-entities from data.

inline void epiworld::Model::load_agents_entities_ties (
    const std::vector< int > & agents_ids,
    const std::vector< int > & entities_ids
) 

Agent agents_ids[i] joins entity entities_ids[i] at the start of every run, after the entity's own distribution function (if any).


function load_agents_entities_ties [2/2]

inline void epiworld::Model::load_agents_entities_ties (
    const int * agents_id,
    const int * entities_id,
    size_t n
) 

function mutate_virus

inline void epiworld::Model::mutate_virus () 

function next

inline virtual void epiworld::Model::next () 

function operator!=

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

function operator()

inline epiworld_double epiworld::Model::operator() (
    std::string_view pname
) const

function operator=

inline Model < TSeq > & epiworld::Model::operator= (
    const Model < TSeq > & m
) 

function operator==

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

function par

inline epiworld_double epiworld::Model::par (
    std::string_view pname
) const

function par_at

inline epiworld_double epiworld::Model::par_at (
    ParamId id
) const

function params

Copy of the model parameters, by name.

inline std::map< std::string, epiworld_double > epiworld::Model::params () const

To change a parameter, use set_param().


function print

inline const Model < TSeq > & epiworld::Model::print (
    bool lite=false
) const

function print_state_codes

inline void epiworld::Model::print_state_codes () const

function queuing_off

Deactivates the queuing system.

inline Model < TSeq > & epiworld::Model::queuing_off () 


function queuing_on

Activates the queuing system (default.).

inline void epiworld::Model::queuing_on () 


function rbinom [1/2]

Draw from the currently configured binomial distribution.

inline int epiworld::Model::rbinom () 

When EPI_FAST_BINOM is enabled (default), this uses rpoiss(lambda) with lambda = n * p after set_rand_binom(n, p) in the rare-event regime p <= 0.01 and n * p * p <= 0.1. Define EPI_NO_FAST_BINOM before including epiworld to disable this behavior.

Returns:

A random draw from the configured binomial distribution, or from its Poisson approximation when the fast path is active.


function rbinom [2/2]

Draw from a binomial distribution with parameters n andp .

inline int epiworld::Model::rbinom (
    int n,
    epiworld_double p
) 

When EPI_FAST_BINOM is enabled (default), this uses rpoiss(lambda) with lambda = n * p in the rare-event regime p <= 0.01 and n * p * p <= 0.1. This preserves the mean and is often substantially faster in practice while remaining very accurate in that region. Define EPI_NO_FAST_BINOM before including epiworld to disable this behavior and force the exact binomial draw.

Parameters:

  • n Number of trials.
  • p Success probability.

Returns:

A random draw from the binomial distribution, or from its Poisson approximation when the fast path is active.


function read_params

inline Model < TSeq > & epiworld::Model::read_params (
    std::string fn,
    bool overwrite=false
) 

function record_hospitalization

Record a hospitalization event for an agent.

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

Parameters:

  • agent Reference to the agent being hospitalized.

This is a wrapper for DataBase::record_hospitalization(). 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 register_sampled_contact

inline void epiworld::Model::register_sampled_contact (
    size_t infectious_id,
    size_t contacted_id
) 

Reports that infectious_id was in contact with contacted_id. Samplers call it, only if has_post_sampling().


function register_sampled_contacts

Same, for several infectious agents in contact with contacted_id .

inline void epiworld::Model::register_sampled_contacts (
    const size_t * infectious_ids,
    size_t n,
    size_t contacted_id
) 


function reset

Reset the model.

inline virtual void epiworld::Model::reset () 

Resetting the model will: * clear the database * restore the population (if set_backup() was called before) * re-distribute tools * re-distribute viruses * set the date to 0


function rewire

inline void epiworld::Model::rewire () 

function rexp [1/2]

inline epiworld_double epiworld::Model::rexp () 

function rexp [2/2]

inline epiworld_double epiworld::Model::rexp (
    epiworld_double lambda
) 

function rgamma [1/2]

inline epiworld_double epiworld::Model::rgamma () 

function rgamma [2/2]

inline epiworld_double epiworld::Model::rgamma (
    epiworld_double alpha,
    epiworld_double beta
) 

function rgeom [1/2]

inline int epiworld::Model::rgeom () 

function rgeom [2/2]

inline int epiworld::Model::rgeom (
    epiworld_double p
) 

function rlognormal [1/2]

inline epiworld_double epiworld::Model::rlognormal () 

function rlognormal [2/2]

inline epiworld_double epiworld::Model::rlognormal (
    epiworld_double mean,
    epiworld_double shape
) 

function rm_edge

inline bool epiworld::Model::rm_edge (
    size_t i,
    size_t j
) 

Returns:

true if a tie was removed.


function rm_entity

inline void epiworld::Model::rm_entity (
    size_t entity_id
) 

function rm_globalevent [1/2]

Remove a global action by name.

inline void epiworld::Model::rm_globalevent (
    std::string name
) 


function rm_globalevent [2/2]

Remove a global action by index.

inline void epiworld::Model::rm_globalevent (
    size_t i
) 


function rm_tool

inline void epiworld::Model::rm_tool (
    size_t tool_pos
) 

function rm_virus

inline void epiworld::Model::rm_virus (
    size_t virus_pos
) 

function rnbinom [1/2]

inline int epiworld::Model::rnbinom () 

function rnbinom [2/2]

inline int epiworld::Model::rnbinom (
    int n,
    epiworld_double p
) 

function rnorm [1/2]

inline epiworld_double epiworld::Model::rnorm () 

function rnorm [2/2]

inline epiworld_double epiworld::Model::rnorm (
    epiworld_double mean,
    epiworld_double sd
) 

function rpoiss [1/2]

inline int epiworld::Model::rpoiss () 

function rpoiss [2/2]

inline int epiworld::Model::rpoiss (
    epiworld_double lambda
) 

function run

Runs the simulation (after initialization).

inline virtual Model < TSeq > & epiworld::Model::run (
    epiworld_fast_uint ndays,
    int seed=-1
) 


function run_globalevents

inline void epiworld::Model::run_globalevents () 

function run_multiple

inline Model < TSeq > & epiworld::Model::run_multiple (
    epiworld_fast_uint ndays,
    epiworld_fast_uint nexperiments,
    int seed_=-1,
    std::function< void(size_t, Model < TSeq > *)> fun=make_save_run < TSeq >(),
    bool reset=true,
    bool verbose=true,
    int nthreads=1
) 

function runif [1/2]

Draw from the currently configured uniform distribution.

inline epiworld_double epiworld::Model::runif () 

Returns:

A random draw from the configured uniform distribution.

These uniform draws make use of Lemire's algorithm for fast uniform integer generation, which is both faster and more accurate than the common std::uniform_int_distribution approach.

Lemire, D. (2019). Fast Random Integer Generation in an Interval. ACM Trans. Model. Comput. Simul., 29(1), 3:1-3:12. https://doi.org/10.1145/3230636


function runif [2/2]

inline epiworld_double epiworld::Model::runif (
    epiworld_double a,
    epiworld_double b
) 

function runif_index

inline uint32_t epiworld::Model::runif_index (
    uint32_t n
) 

function runif_int

inline int epiworld::Model::runif_int (
    int a,
    int b
) 

function sample_from_probs

Sample from a set of probabilities stored in array_double_tmp.

inline size_t epiworld::Model::sample_from_probs (
    size_t n
) 

Uses a cumulative probability approach: draws a uniform random number and walks through array_double_tmp[0..n-1], accumulating probabilities until the draw is exceeded. If no event fires, returns n (meaning "none of the above").

Parameters:

  • n Number of probability entries in array_double_tmp to consider.

Returns:

Index in [0, n] of the sampled event (n = no event).


function seed

inline void epiworld::Model::seed (
    size_t s
) 

function set_agents_data

Set the agents data object.

inline void epiworld::Model::set_agents_data (
    double * data_,
    size_t ncols_
) 

The data should be an array with the data stored in a column major order, i.e., by column.

Parameters:

  • data_ Pointer to the first element of an array of size size() * ncols_.
  • ncols_ Number of features included in the data.

function set_backup

inline void epiworld::Model::set_backup () 

function set_name

Set the name object.

inline void epiworld::Model::set_name (
    std::string name
) 

Parameters:

  • name

function set_ndays

inline void epiworld::Model::set_ndays (
    epiworld_fast_uint ndays
) 

function set_param

inline void epiworld::Model::set_param (
    std::string_view pname,
    epiworld_double val
) 

function set_param_at

inline void epiworld::Model::set_param_at (
    ParamId id,
    epiworld_double val
) 

function set_post_sampling

Install a callback (an empty function clears it).

inline Model < TSeq > & epiworld::Model::set_post_sampling (
    PostSamplingFun < TSeq > fun
) 


function set_rand_binom

inline void epiworld::Model::set_rand_binom (
    int n,
    epiworld_double p
) 

function set_rand_engine

inline void epiworld::Model::set_rand_engine (
    std::shared_ptr< epi_xoshiro256ss > & eng
) 

function set_rand_exp

inline void epiworld::Model::set_rand_exp (
    epiworld_double lambda
) 

function set_rand_gamma

inline void epiworld::Model::set_rand_gamma (
    epiworld_double alpha,
    epiworld_double beta
) 

function set_rand_geom

inline void epiworld::Model::set_rand_geom (
    epiworld_double p
) 

function set_rand_lognormal

inline void epiworld::Model::set_rand_lognormal (
    epiworld_double mean,
    epiworld_double shape
) 

function set_rand_nbinom

inline void epiworld::Model::set_rand_nbinom (
    int n,
    epiworld_double p
) 

function set_rand_norm

inline void epiworld::Model::set_rand_norm (
    epiworld_double mean,
    epiworld_double sd
) 

function set_rand_poiss

inline void epiworld::Model::set_rand_poiss (
    epiworld_double lambda
) 

function set_rand_unif

inline void epiworld::Model::set_rand_unif (
    epiworld_double a,
    epiworld_double b
) 

function set_rewire_fun

inline void epiworld::Model::set_rewire_fun (
    std::function< void(std::vector< Agent < TSeq > > *, Model < TSeq > *, epiworld_double )> fun
) 

function set_rewire_prop

inline void epiworld::Model::set_rewire_prop (
    epiworld_double prop
) 

function set_state_function [1/2]

inline Model < TSeq > & epiworld::Model::set_state_function (
    epiworld_fast_uint state,
    UpdateFun < TSeq > fun=nullptr
) 

function set_state_function [2/2]

inline Model < TSeq > & epiworld::Model::set_state_function (
    std::string_view name,
    UpdateFun < TSeq > fun=nullptr
) 

function set_transmission_mode [1/2]

inline Model < TSeq > & epiworld::Model::set_transmission_mode (
    TransmissionMode mode,
    double kappa=EPI_DEFAULT_TRANSMISSION_KAPPA
) 

function set_transmission_mode [2/2]

inline Model < TSeq > & epiworld::Model::set_transmission_mode (
    std::string_view mode,
    double kappa=EPI_DEFAULT_TRANSMISSION_KAPPA
) 

function set_user_data

[@

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


function size

inline size_t epiworld::Model::size () const

function state_of

inline epiworld_fast_int epiworld::Model::state_of (
    std::string_view name
) 

function today

The current time of the model.

inline int epiworld::Model::today () const


function update_state

inline void epiworld::Model::update_state () 

function verbose_off

inline Model < TSeq > & epiworld::Model::verbose_off () 

function verbose_on

inline Model < TSeq > & epiworld::Model::verbose_on () 

function write_data

Wrapper of DataBase::write_data .

inline void epiworld::Model::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

Parameters:

  • fn_virus_info Filename. Information about the virus.
  • fn_virus_hist Filename. History of the virus.
  • fn_tool_info Filename. Information about the tool.
  • fn_tool_hist Filename. History of the tool.
  • fn_total_hist Filename. Aggregated history (state)
  • fn_transmission Filename. Transmission history.
  • fn_transition Filename. Markov transition history.
  • fn_reproductive_number Filename. Case by case reproductive number
  • fn_generation_time Filename. Generation time data.
  • fn_active_cases Filename. Active cases data.
  • fn_outbreak_size Filename. Outbreak size data.
  • fn_hospitalizations Filename. Hospitalization data.

function write_edgelist [1/2]

inline void epiworld::Model::write_edgelist (
    std::string fn
) const

function write_edgelist [2/2]

inline void epiworld::Model::write_edgelist (
    std::vector< int > & source,
    std::vector< int > & target
) const

function ~Model

inline virtual epiworld::Model::~Model () 

Protected Attributes Documentation

variable agent_carrier

[agent] 1 if Agent::virus is set, compact for scans

std::vector< char > epiworld::Model< TSeq >::agent_carrier;


variable agent_state

[agent] Copy of Agent::state , compact for scans

std::vector< unsigned int > epiworld::Model< TSeq >::agent_state;


variable agents_data

double* epiworld::Model< TSeq >::agents_data;

variable agents_data_ncols

size_t epiworld::Model< TSeq >::agents_data_ncols;

variable contact_tracing

std::unique_ptr<ContactTracing> epiworld::Model< TSeq >::contact_tracing;

variable contact_tracing_max_contacts

size_t epiworld::Model< TSeq >::contact_tracing_max_contacts;

variable current_date

int epiworld::Model< TSeq >::current_date;

variable db

DataBase<TSeq> epiworld::Model< TSeq >::db;

variable directed

bool epiworld::Model< TSeq >::directed;

variable engine

std::shared_ptr< epi_xoshiro256ss > epiworld::Model< TSeq >::engine;

variable entities

std::vector< Entity<TSeq> > epiworld::Model< TSeq >::entities;

variable events

Variables used to keep track of the events to be made regarding viruses.

std::vector< Event<TSeq> > epiworld::Model< TSeq >::events;


variable globalevents

std::vector<GlobalEventPtr<TSeq> > epiworld::Model< TSeq >::globalevents;

variable initial_states_fun

std::function<void(Model<TSeq>*)> epiworld::Model< TSeq >::initial_states_fun;

Function to distribute states. Goes along with the function


variable last_seed

int epiworld::Model< TSeq >::last_seed;

variable n_replicates

epiworld_fast_uint epiworld::Model< TSeq >::n_replicates;

variable nactions

epiworld_fast_uint epiworld::Model< TSeq >::nactions;

variable name

Name of the model.

std::string epiworld::Model< TSeq >::name;


variable ndays

epiworld_fast_uint epiworld::Model< TSeq >::ndays;

variable nstates

epiworld_fast_uint epiworld::Model< TSeq >::nstates;

variable param_index

std::map<std::string, size_t, std::less<> > epiworld::Model< TSeq >::param_index;

variable param_layout_id

uint32_t epiworld::Model< TSeq >::param_layout_id;

variable param_values

std::vector< epiworld_double > epiworld::Model< TSeq >::param_values;

variable pb

Progress epiworld::Model< TSeq >::pb;

variable population

std::vector< Agent<TSeq> > epiworld::Model< TSeq >::population;

variable population_backup

std::vector< Agent<TSeq> > epiworld::Model< TSeq >::population_backup;

variable population_left

std::vector< size_t > epiworld::Model< TSeq >::population_left;

variable population_left_n

size_t epiworld::Model< TSeq >::population_left_n;

variable post_sampling_fun

See set_post_sampling() .

PostSamplingFun<TSeq> epiworld::Model< TSeq >::post_sampling_fun;


variable post_sampling_on

post_sampling_fun is set

bool epiworld::Model< TSeq >::post_sampling_on;


variable post_sampling_scratch

Never copied.

PostSamplingScratch epiworld::Model< TSeq >::post_sampling_scratch;


variable push_default

[state] ...and it is default_update_susceptible

std::vector< char > epiworld::Model< TSeq >::push_default;


variable push_excluded

[target state * nstates + source state]

std::vector< char > epiworld::Model< TSeq >::push_excluded;


variable push_pushable

[state] Uses the default susceptible sampler

std::vector< char > epiworld::Model< TSeq >::push_pushable;


variable push_slot

[agent] Index in push_targets, or -1

std::vector< int > epiworld::Model< TSeq >::push_slot;


variable push_source_ok

[state] Some pushable state accepts it as source

std::vector< char > epiworld::Model< TSeq >::push_source_ok;


variable push_sources

[agent bit] Carriers that push this step

std::vector< uint64_t > epiworld::Model< TSeq >::push_sources;


variable push_targets

std::vector< PushTarget > epiworld::Model< TSeq >::push_targets;

variable push_visit

[agent bit] To update after a push

std::vector< uint64_t > epiworld::Model< TSeq >::push_visit;


variable queue

Queue<TSeq> epiworld::Model< TSeq >::queue;

variable rbinomd

std::binomial_distribution epiworld::Model< TSeq >::rbinomd;

variable rbinomd_fast_lambda

epiworld_double epiworld::Model< TSeq >::rbinomd_fast_lambda;

variable rbinomd_n

int epiworld::Model< TSeq >::rbinomd_n;

variable rbinomd_use_poisson

bool epiworld::Model< TSeq >::rbinomd_use_poisson;

variable rewire_fun

std::function<void(std::vector<Agent<TSeq>>*,Model<TSeq>*,epiworld_double)> epiworld::Model< TSeq >::rewire_fun;

variable rewire_prop

epiworld_double epiworld::Model< TSeq >::rewire_prop;

variable rexpd

std::exponential_distribution epiworld::Model< TSeq >::rexpd;

variable rgammad

std::gamma_distribution epiworld::Model< TSeq >::rgammad;

variable rgeomd

std::geometric_distribution epiworld::Model< TSeq >::rgeomd;

variable rlognormald

std::lognormal_distribution epiworld::Model< TSeq >::rlognormald;

variable rnbinomd

std::negative_binomial_distribution epiworld::Model< TSeq >::rnbinomd;

variable rnormd

std::normal_distribution epiworld::Model< TSeq >::rnormd;

variable rpoissd

std::poisson_distribution epiworld::Model< TSeq >::rpoissd;

variable runifd_a

epiworld_double epiworld::Model< TSeq >::runifd_a;

variable runifd_b

epiworld_double epiworld::Model< TSeq >::runifd_b;

variable running

bool epiworld::Model< TSeq >::running;

variable sampled_population

std::vector< Agent<TSeq> * > epiworld::Model< TSeq >::sampled_population;

variable sampled_population_n

size_t epiworld::Model< TSeq >::sampled_population_n;

variable sim_id

size_t epiworld::Model< TSeq >::sim_id;

variable state_carrier_degree

std::vector< size_t > epiworld::Model< TSeq >::state_carrier_degree;

variable state_carriers

std::vector< size_t > epiworld::Model< TSeq >::state_carriers;

variable state_degree

std::vector< size_t > epiworld::Model< TSeq >::state_degree;

variable state_fun

Functions to update states.

std::vector< UpdateFun<TSeq> > epiworld::Model< TSeq >::state_fun;


variable state_index_ready

bool epiworld::Model< TSeq >::state_index_ready;

variable state_member_pos

[agent] Position in state_order

std::vector< size_t > epiworld::Model< TSeq >::state_member_pos;


variable state_order

[N] Agent ids, grouped by state

std::vector< size_t > epiworld::Model< TSeq >::state_order;


variable state_start

[nstates + 1] Where each state's block starts

std::vector< size_t > epiworld::Model< TSeq >::state_start;


variable states_labels

Labels of the states.

std::vector< std::string > epiworld::Model< TSeq >::states_labels;


variable time_elapsed

std::chrono::duration<epiworld_double,std::micro> epiworld::Model< TSeq >::time_elapsed;

variable time_end

std::chrono::time_point<std::chrono::steady_clock> epiworld::Model< TSeq >::time_end;

variable time_start

std::chrono::time_point<std::chrono::steady_clock> epiworld::Model< TSeq >::time_start;

variable tools

std::vector< ToolPtr<TSeq> > epiworld::Model< TSeq >::tools;

variable transmission_kappa

double epiworld::Model< TSeq >::transmission_kappa;

variable transmission_mode

TransmissionMode epiworld::Model< TSeq >::transmission_mode;

variable transmission_mode_last

TransmissionMode epiworld::Model< TSeq >::transmission_mode_last;

variable use_contact_tracing

bool epiworld::Model< TSeq >::use_contact_tracing;

variable use_queuing

bool epiworld::Model< TSeq >::use_queuing;

variable using_backup

bool epiworld::Model< TSeq >::using_backup;

variable verbose

bool epiworld::Model< TSeq >::verbose;

variable viruses

std::vector< VirusPtr<TSeq> > epiworld::Model< TSeq >::viruses;

Protected Functions Documentation

function _add_event

Construct a new Event object.

inline void epiworld::Model::_add_event (
    Agent < TSeq > * agent_,
    VirusPtr < TSeq > virus_,
    ToolPtr < TSeq > tool_,
    Entity < TSeq > * entity_,
    epiworld_fast_int new_state_,
    epiworld_fast_int queue_,
    EventAction action_
) 

Parameters:

  • agent_ Agent over which the action will be called
  • virus_ Virus pointer included in the action
  • tool_ Tool pointer included in the action
  • entity_ Entity pointer included in the action
  • new_state_ New state of the agent
  • queue_ Change in the queue
  • action_ Action to execute when processing the event

function _event_add_entity

inline void epiworld::Model::_event_add_entity (
    Event < TSeq > & a
) 

function _event_add_tool

inline void epiworld::Model::_event_add_tool (
    Event < TSeq > & a
) 

function _event_add_virus

inline void epiworld::Model::_event_add_virus (
    Event < TSeq > & a
) 

function _event_change_state

inline void epiworld::Model::_event_change_state (
    Event < TSeq > & a
) 

function _event_rm_entity

inline void epiworld::Model::_event_rm_entity (
    Event < TSeq > & a
) 

function _event_rm_tool

inline void epiworld::Model::_event_rm_tool (
    Event < TSeq > & a
) 

function _event_rm_virus

inline void epiworld::Model::_event_rm_virus (
    Event < TSeq > & a
) 

function agents_set_neighbors

Sets every agent's neighbors from rows of a flat array.

inline void epiworld::Model::agents_set_neighbors (
    const std::vector< size_t > & start,
    std::vector< size_t > & ids
) 

Row i is ids[start[i]] to ids[start[i + 1] - 1], in any order and with repeats. Each row is sorted and deduplicated in place and copied into agent i's neighbors, allocated once at its final size. The agents must have no ties yet (see agents_empty_graph()).


function check_edge_endpoints

Validates the arguments of add_edge() /rm_edge() .

inline void epiworld::Model::check_edge_endpoints (
    size_t i,
    size_t j
) const


function chrono_end

inline void epiworld::Model::chrono_end () 

function chrono_start

inline void epiworld::Model::chrono_start () 

function clone_ptr

Advanced usage: Makes a copy of data and returns it as undeleted pointer.

inline virtual std::unique_ptr< Model < TSeq > > epiworld::Model::clone_ptr () 

Parameters:

  • copy

function death_reduction_mixer

inline virtual epiworld_double epiworld::Model::death_reduction_mixer (
    Agent < TSeq > * agent,
    VirusPtr < TSeq > & virus
) 

function dist_entities

inline void epiworld::Model::dist_entities () 

function dist_tools

inline void epiworld::Model::dist_tools () 

function dist_virus

inline void epiworld::Model::dist_virus () 

function post_sampling_dispatch

inline void epiworld::Model::post_sampling_dispatch () 

Groups the pairs of the step by infectious agent (only the distinct ids are sorted, never an N-sized array) and runs the callback on each group, in ascending id order. The scratch is left clean even if the callback throws.


function post_sampling_prepare_scratch

Sizes the scratch for the population.

inline void epiworld::Model::post_sampling_prepare_scratch () 

Sizes the scratch for the current population. Copies, moves and assignments of a model leave the scratch empty, so this is also what makes them safe to continue stepping without a reset.


function recovery_enhancer_mixer

inline virtual epiworld_double epiworld::Model::recovery_enhancer_mixer (
    Agent < TSeq > * agent,
    VirusPtr < TSeq > & virus
) 

function set_sim_id

inline void epiworld::Model::set_sim_id (
    size_t id
) 

function state_index_build

inline void epiworld::Model::state_index_build () 

function state_index_degree

inline void epiworld::Model::state_index_degree (
    Agent < TSeq > & p,
    size_t n_neighbors_before
) 

function state_index_members

inline AgentIdsView epiworld::Model::state_index_members (
    size_t state
) const

function state_index_move

inline void epiworld::Model::state_index_move (
    size_t id,
    unsigned int state_old,
    unsigned int state_new
) 

function state_index_update

inline void epiworld::Model::state_index_update (
    Agent < TSeq > * p,
    unsigned int state_old,
    bool had_virus
) 

function susceptibility_reduction_mixer

inline virtual epiworld_double epiworld::Model::susceptibility_reduction_mixer (
    Agent < TSeq > * agent,
    VirusPtr < TSeq > & virus
) 

function transmission_choose_push

inline bool epiworld::Model::transmission_choose_push () const

function transmission_prepare

inline bool epiworld::Model::transmission_prepare () 

function transmission_push

inline void epiworld::Model::transmission_push () 

function transmission_push_impl

template<bool Record>
inline void epiworld::Model::transmission_push_impl () 

function transmission_reduction_mixer

inline virtual epiworld_double epiworld::Model::transmission_reduction_mixer (
    Agent < TSeq > * agent,
    VirusPtr < TSeq > & virus
) 

function transmission_update_others

inline void epiworld::Model::transmission_update_others () 


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