Model#
- class epiworldpy.Model(self: epiworldpy._core.Model)#
Bases:
pybind11_objectAn agent-based model: a population, its states, viruses, and tools.
Modelis the base class of every model inepiworldpy.epimodels. Those come with their states, parameters, and virus already set up, so a typical workflow only needs a population and a call torun():from epiworldpy import epimodels covid = epimodels.ModelSIR("COVID-19", prevalence=0.01, transmission_rate=0.9, recovery_rate=0.1) covid.agents_smallworld(n=1000, k=5, d=False, p=0.01) covid.run(ndays=100, seed=1912) covid.get_db().get_hist_total()
An empty
Model()can be used to build a custom model withadd_state(),add_virus(), andadd_tool().Create an empty model with no states, agents, viruses, or tools.
Methods
Tie two agents.
Add an entity to the model.
Add a global event: a function called at the end of a simulation day.
Add a named parameter, or get it if it already exists.
Overloaded function.
Add a tool to the model.
Add a virus to the model.
Create the population as a Bernoulli (Erdos-Renyi) random graph.
Create a population with no ties.
Create the population from an edge list.
Create the population from a stochastic block model (SBM).
Create the population as a Watts-Strogatz small-world network.
Get an agent by ID.
Get the population.
Get the agents currently in a state.
Get the current state of every agent.
Get the database with the results of the last run.
Get the time the simulations took.
Get an entity by ID.
Get the transmission mode used in the most recent step.
Get the number of entities in the model.
Get the number of global events.
Get the number of replicates run so far.
Get the number of states.
Get the number of tools in the model.
Get the number of viruses in the model.
Get the name of the model type (for example,
"Susceptible-Infected-Recovered (SIR)").Get the number of days the model was last run for.
Get the value of a named parameter.
Get the proportion of ties rewired at each step.
Get the ID of the current simulation.
Get the labels of the model's states.
Get the threshold used by the
"auto"transmission mode.Get the transmission mode set with
set_transmission_mode().Check whether verbose output is on.
Check whether two agents are tied.
Check whether the model has a global event.
Check whether the model has a named parameter.
Set the initial distribution of agents across states.
Check whether the network is directed.
Check whether the queuing system is on.
Create a
run_multiple()callback that writes each run's results to files.Get the value of a named parameter (alias of
get_param()).Get the model's parameters.
Print a summary of the model and its last run.
Print the index and label of each state.
Turn off the queuing system, so every agent is updated at every step.
Turn on the queuing system (the default).
Reset the model to its initial state.
Rewire the network with the model's rewiring function, if it has one.
Remove the tie between two agents.
Remove a global event.
Run the model.
Run the global events scheduled for today.
Run the model several times.
Seed the model's random number generator.
Set the name of the model.
Set the value of a named parameter.
Set the proportion of ties rewired at each step.
Overloaded function.
Set how network transmission is computed.
Get the number of agents.
Get the index of a state from its label.
Get the current simulation day.
Turn off verbose output.
Turn on verbose output (progress bars and messages).
Write the results of the last run to files.
Write the network to a file as an edge list.
- add_edge(self: epiworldpy._core.Model, i: SupportsInt | SupportsIndex, j: SupportsInt | SupportsIndex) bool#
Tie two agents.
Safe to call during a run, for example from a global event. Only works on undirected networks.
- Parameters:
i (int) – ID of the first agent.
j (int) – ID of the second agent.
- Returns:
Trueif the tie was created,Falseif the agents were already tied.- Return type:
bool
- add_entity(self: epiworldpy._core.Model, entity: epiworldpy._core.Entity) None#
Add an entity to the model.
Agents are assigned to the entity when the model is run (see
Entity.set_distribution()).- Parameters:
entity (Entity) – The entity to add.
- add_globalevent(self: epiworldpy._core.Model, fun: collections.abc.Callable[[epiworldpy._core.Model], None], name: str = 'global event', date: SupportsInt | SupportsIndex = -99) None#
Add a global event: a function called at the end of a simulation day.
Global events can, for example, implement interventions that change the network (see
add_edge()) or model parameters.- Parameters:
fun (callable) – Function
fun(model) -> None.name (str, default "global event") – Name of the event, used by
rm_globalevent().date (int, default -99) – Day on which to call
fun. A negative value calls it every day.
- add_param(self: epiworldpy._core.Model, initial_val: SupportsFloat | SupportsIndex, pname: str, overwrite: bool = False) float#
Add a named parameter, or get it if it already exists.
Viruses and tools can read parameters by name (see, for example,
Virus.set_prob_infecting()), so changing a parameter changes every object that uses it.- Parameters:
initial_val (float) – Value of the new parameter.
pname (str) – Name of the parameter. It cannot contain a colon.
overwrite (bool, default False) – If the parameter exists, whether to replace its value with
initial_val.
- Returns:
The parameter’s current value.
- Return type:
float
- add_state(*args, **kwargs)#
Overloaded function.
add_state(self: epiworldpy._core.Model, lab: str, fun: epiworldpy._core.NativeUpdateFun) -> int
Add a state updated by a built-in epiworld function.
- Parameters:
lab (str) – Label of the new state.
fun (NativeUpdateFun) – Update function for agents in this state, from
UpdateFun.susceptible()orUpdateFun.rate().
- Returns:
Index of the new state.
- Return type:
int
add_state(self: epiworldpy._core.Model, lab: str, fun: collections.abc.Callable[[epiworldpy._core.Agent, epiworldpy._core.Model], None] = None) -> int
Add a state to the model.
- Parameters:
lab (str) – Label of the new state.
fun (callable or None, default None) – Update function
fun(agent, model) -> Nonecalled on every agent in this state at each step, orNonefor a state agents only leave through events (for example, recovery). See alsoUpdateFunfor epiworld’s built-in update functions, which are much faster than Python callbacks.
- Returns:
Index of the new state.
- Return type:
int
- add_tool(self: epiworldpy._core.Model, tool: epiworldpy._core.Tool) None#
Add a tool to the model.
The model keeps a copy of
tooland distributes it to agents when the model is run (seeTool.set_distribution()).- Parameters:
tool (Tool) – The tool to add.
- add_virus(self: epiworldpy._core.Model, virus: epiworldpy._core.Virus) None#
Add a virus to the model.
The model keeps a copy of
virusand distributes it to agents when the model is run (seeVirus.set_distribution()).- Parameters:
virus (Virus) – The virus to add.
- agents_bernoulli(self: epiworldpy._core.Model, n: SupportsInt | SupportsIndex, p: SupportsFloat | SupportsIndex, d: bool = False) epiworldpy._core.Model#
Create the population as a Bernoulli (Erdos-Renyi) random graph.
- Parameters:
n (int) – Number of agents.
p (float) – Probability that any two agents are tied.
d (bool, default False) – Whether the network is directed.
- Returns:
The model itself.
- Return type:
- agents_empty_graph(self: epiworldpy._core.Model, n: SupportsInt | SupportsIndex = 1000) None#
Create a population with no ties.
Useful for models that do not use a network, such as the
*CONNand*Mixingmodels.- Parameters:
n (int, default 1000) – Number of agents.
- agents_from_edgelist(self: epiworldpy._core.Model, source: collections.abc.Sequence[SupportsInt | SupportsIndex], target: collections.abc.Sequence[SupportsInt | SupportsIndex], size: SupportsInt | SupportsIndex, directed: bool) None#
Create the population from an edge list.
- Parameters:
source (list of int) – Source agent of each tie.
target (list of int) – Target agent of each tie, of the same length as
source.size (int) – Number of agents. Agent IDs must be in
[0, size).directed (bool) – Whether ties are directed. A directed tie
source -> targetmakestargeta neighbor ofsourceonly, sotargetcan infectsourcebut not the other way around.
- agents_sbm(self: epiworldpy._core.Model, block_sizes: collections.abc.Sequence[SupportsInt | SupportsIndex], mixing_matrix: collections.abc.Sequence[SupportsFloat | SupportsIndex], row_major: bool = True) epiworldpy._core.Model#
Create the population from a stochastic block model (SBM).
- Parameters:
block_sizes (list of int) – Number of agents in each of the
Kblocks (groups).mixing_matrix (list of float) – Flattened
K x Kmatrix; entry(g, h)is the expected number of ties an agent in blockghas with agents in blockh, so the row sums are the expected degrees.row_major (bool, default True) – Whether
mixing_matrixis flattened by rows (NumPy’s defaultorder="C") or by columns (order="F").
- Returns:
The model itself.
- Return type:
- agents_smallworld(self: epiworldpy._core.Model, n: SupportsInt | SupportsIndex, k: SupportsInt | SupportsIndex, d: bool, p: SupportsFloat | SupportsIndex) epiworldpy._core.Model#
Create the population as a Watts-Strogatz small-world network.
Agents are first placed on a ring and tied to their
knearest neighbors; then a proportionpof the ties are rewired at random.- Parameters:
n (int) – Number of agents.
k (int) – Number of neighbors of each agent in the ring (half on each side if the network is undirected).
d (bool) – Whether the network is directed.
p (float) – Proportion of ties to rewire, between 0 and 1.
- Returns:
The model itself.
- Return type:
- get_agent(self: epiworldpy._core.Model, i: SupportsInt | SupportsIndex) epiworldpy._core.Agent#
Get an agent by ID.
- Parameters:
i (int) – ID of the agent.
- Returns:
The agent.
- Return type:
- get_agents(self: epiworldpy._core.Model) list[epiworldpy._core.Agent]#
Get the population.
- Returns:
Every agent in the model, in ID order.
- Return type:
list of Agent
- get_agents_in_state(self: epiworldpy._core.Model, state: SupportsInt | SupportsIndex) numpy.typing.NDArray[numpy.uint64]#
Get the agents currently in a state.
Only available once the model has been run.
- Parameters:
state (int) – Index of the state.
- Returns:
IDs of the agents in that state.
- Return type:
numpy.ndarray
- get_agents_states(self: epiworldpy._core.Model) list[int]#
Get the current state of every agent.
- Returns:
State index of each agent, in ID order.
- Return type:
list of int
- get_db(self: epiworldpy._core.Model) epiworldpy._core.DataBase#
Get the database with the results of the last run.
- Returns:
The model’s database.
- Return type:
- get_elapsed(self: epiworldpy._core.Model, unit: str = 'auto') dict#
Get the time the simulations took.
- Parameters:
unit (str, default "auto") – Time unit:
"auto"(chosen from the magnitude),"nanoseconds","microseconds","milliseconds","seconds","minutes", or"hours".- Returns:
"last": duration of the last run;"total": duration of all runs;"unit": abbreviation of the unit used.- Return type:
dict
- get_entity(self: epiworldpy._core.Model, entity_id: SupportsInt | SupportsIndex) epiworldpy._core.Entity#
Get an entity by ID.
- Parameters:
entity_id (int) – ID of the entity.
- Returns:
The entity.
- Return type:
- get_last_transmission_mode(self: epiworldpy._core.Model) str#
Get the transmission mode used in the most recent step.
- Returns:
"push"or"pull".- Return type:
str
- get_n_entities(self: epiworldpy._core.Model) int#
Get the number of entities in the model.
- Returns:
Number of entities.
- Return type:
int
- get_n_globalevents(self: epiworldpy._core.Model) int#
Get the number of global events.
- Returns:
Number of global events.
- Return type:
int
- get_n_replicates(self: epiworldpy._core.Model) int#
Get the number of replicates run so far.
- Returns:
Number of calls to
run(), including those made byrun_multiple().- Return type:
int
- get_n_states(self: epiworldpy._core.Model) int#
Get the number of states.
- Returns:
Number of states.
- Return type:
int
- get_n_tools(self: epiworldpy._core.Model) int#
Get the number of tools in the model.
- Returns:
Number of tools.
- Return type:
int
- get_n_viruses(self: epiworldpy._core.Model) int#
Get the number of viruses in the model.
- Returns:
Number of viruses.
- Return type:
int
- get_name(self: epiworldpy._core.Model) str#
Get the name of the model type (for example,
"Susceptible-Infected-Recovered (SIR)").- Returns:
Name of the model.
- Return type:
str
- get_ndays(self: epiworldpy._core.Model) int#
Get the number of days the model was last run for.
- Returns:
Number of days (steps).
- Return type:
int
- get_param(self: epiworldpy._core.Model, pname: str) float#
Get the value of a named parameter.
- Parameters:
pname (str) – Name of the parameter.
- Returns:
The parameter’s value.
- Return type:
float
- get_rewire_prop(self: epiworldpy._core.Model) float#
Get the proportion of ties rewired at each step.
- Returns:
Proportion between 0 and 1.
- Return type:
float
- get_sim_id(self: epiworldpy._core.Model) int#
Get the ID of the current simulation.
Useful inside a
run_multiple()callback.- Returns:
ID of the simulation.
- Return type:
int
- get_states(self: epiworldpy._core.Model) list[str]#
Get the labels of the model’s states.
- Returns:
State labels, in index order.
- Return type:
list of str
- get_transmission_kappa(self: epiworldpy._core.Model) float#
Get the threshold used by the
"auto"transmission mode.- Returns:
The
kappathreshold (seeset_transmission_mode()).- Return type:
float
- get_transmission_mode(self: epiworldpy._core.Model) str#
Get the transmission mode set with
set_transmission_mode().- Returns:
"auto","push", or"pull".- Return type:
str
- get_verbose(self: epiworldpy._core.Model) bool#
Check whether verbose output is on.
- Returns:
Trueif verbose output is on.- Return type:
bool
- has_edge(self: epiworldpy._core.Model, i: SupportsInt | SupportsIndex, j: SupportsInt | SupportsIndex) bool#
Check whether two agents are tied.
- Parameters:
i (int) – ID of the first agent.
j (int) – ID of the second agent.
- Returns:
Trueif the agents are tied (i -> jin a directed network).- Return type:
bool
- has_globalevent(self: epiworldpy._core.Model, name: str) bool#
Check whether the model has a global event.
- Parameters:
name (str) – Name of the event.
- Returns:
Trueif the event exists.- Return type:
bool
- has_param(self: epiworldpy._core.Model, pname: str) bool#
Check whether the model has a named parameter.
- Parameters:
pname (str) – Name of the parameter.
- Returns:
Trueif the parameter exists.- Return type:
bool
- initial_states(self: epiworldpy._core.Model, proportions: collections.abc.Sequence[SupportsFloat | SupportsIndex], queue: collections.abc.Sequence[SupportsInt | SupportsIndex] = []) epiworldpy._core.Model#
Set the initial distribution of agents across states.
The meaning of
proportionsis model specific. For the SEIR family, for example,proportions[0]is the share of the initially infected agents placed inInfectedrather thanExposed, andproportions[1]is the share of the remaining agents placed inRecovered. The distribution is applied when the model is reset, which happens at the start of every run. Models without a state-based initializer ignore the call.- Parameters:
proportions (list of float) – Proportions used by the model’s initializer.
queue (list of int, default []) – Queuing flags used by the model’s initializer. Leave empty for the default.
- Returns:
The model itself.
- Return type:
- is_directed(self: epiworldpy._core.Model) bool#
Check whether the network is directed.
- Returns:
Trueif the network is directed.- Return type:
bool
- is_queuing_on(self: epiworldpy._core.Model) bool#
Check whether the queuing system is on.
- Returns:
Trueif queuing is on.- Return type:
bool
- static make_save_run(fmt: str = '%03lu-episimulation.csv', total_hist: bool = True, virus_info: bool = False, virus_hist: bool = False, tool_info: bool = False, tool_hist: bool = False, transmission: bool = False, transition: bool = False, reproductive: bool = False, generation: bool = False, active_cases: bool = False, outbreak_size: bool = False, hospitalizations: bool = False) collections.abc.Callable[[SupportsInt | SupportsIndex, epiworldpy._core.Model], None]#
Create a
run_multiple()callback that writes each run’s results to files.- Parameters:
fmt (str, default "%03lu-episimulation.csv") – File name pattern, which must contain exactly one
%format (the simulation ID). The type of data is appended to each file name.total_hist (bool, default True) – Save the totals per state and day (see
DataBase.get_hist_total()).virus_info (bool, default False) – Save information about the viruses.
virus_hist (bool, default False) – Save the history of each virus (see
DataBase.get_hist_virus()).tool_info (bool, default False) – Save information about the tools.
tool_hist (bool, default False) – Save the history of each tool (see
DataBase.get_hist_tool()).transmission (bool, default False) – Save the transmission events (see
DataBase.get_transmissions()).transition (bool, default False) – Save the transition counts (see
DataBase.get_hist_transition_matrix()).reproductive (bool, default False) – Save the reproductive numbers (see
DataBase.get_reproductive_number()).generation (bool, default False) – Save the generation times (see
DataBase.get_generation_time()).active_cases (bool, default False) – Save the active cases (see
DataBase.get_active_cases()).outbreak_size (bool, default False) – Save the outbreak sizes (see
DataBase.get_outbreak_size()).hospitalizations (bool, default False) – Save the hospitalizations (see
DataBase.get_hospitalizations()).
- Returns:
A function
fun(sim_id, model) -> Noneto pass torun_multiple().- Return type:
callable
- par(self: epiworldpy._core.Model, pname: str) float#
Get the value of a named parameter (alias of
get_param()).- Parameters:
pname (str) – Name of the parameter.
- Returns:
The parameter’s value.
- Return type:
float
- params(self: epiworldpy._core.Model) dict[str, float]#
Get the model’s parameters.
- Returns:
Parameter values by name.
- Return type:
dict of str to float
- print(self: epiworldpy._core.Model, lite: bool = False) None#
Print a summary of the model and its last run.
- Parameters:
lite (bool, default False) – If
True, print a shorter summary.
- print_state_codes(self: epiworldpy._core.Model) None#
Print the index and label of each state.
- queuing_off(self: epiworldpy._core.Model) epiworldpy._core.Model#
Turn off the queuing system, so every agent is updated at every step.
Needed when an update function may change the state of agents that have no infected neighbors.
- Returns:
The model itself.
- Return type:
- queuing_on(self: epiworldpy._core.Model) None#
Turn on the queuing system (the default).
With queuing, each step only updates agents that may change state (for example, susceptible agents with an infected neighbor), which is much faster in large populations. It does not change the results.
- reset(self: epiworldpy._core.Model) None#
Reset the model to its initial state.
Restores the population, clears the database, and redistributes viruses, tools, and entities.
run()calls it before each simulation.
- rewire(self: epiworldpy._core.Model) None#
Rewire the network with the model’s rewiring function, if it has one.
- rm_edge(self: epiworldpy._core.Model, i: SupportsInt | SupportsIndex, j: SupportsInt | SupportsIndex) bool#
Remove the tie between two agents.
Safe to call during a run, for example from a global event. Only works on undirected networks.
- Parameters:
i (int) – ID of the first agent.
j (int) – ID of the second agent.
- Returns:
Trueif a tie was removed,Falseif there was none.- Return type:
bool
- rm_globalevent(self: epiworldpy._core.Model, name: str) None#
Remove a global event.
- Parameters:
name (str) – Name of the event (see
add_globalevent()).
- run(self: epiworldpy._core.Model, ndays: SupportsInt | SupportsIndex, seed: SupportsInt | SupportsIndex = -1) epiworldpy._core.Model#
Run the model.
- Parameters:
ndays (int) – Number of days (steps) to simulate.
seed (int, default -1) – Seed for the random number generator. A negative value keeps the current generator state.
- Returns:
The model itself.
- Return type:
- run_globalevents(self: epiworldpy._core.Model) None#
Run the global events scheduled for today.
- run_multiple(self: epiworldpy._core.Model, ndays: SupportsInt | SupportsIndex, nexperiments: SupportsInt | SupportsIndex, seed_: SupportsInt | SupportsIndex = -1, fun: object = None, reset: bool = True, verbose: bool = True, nthreads: SupportsInt | SupportsIndex = 1) None#
Run the model several times.
Each experiment resets the model (if
resetisTrue), runs it forndaysdays, and then callsfun.- Parameters:
ndays (int) – Number of days (steps) of each experiment.
nexperiments (int) – Number of experiments.
seed (int, default -1) – Seed for the random number generator. A negative value keeps the current generator state.
fun (callable or None, default None) – Function
fun(sim_id, model) -> Nonecalled after each experiment, for example to collect results. WithNone, the results are saved withmake_save_run()’s defaults.reset (bool, default True) – Whether to reset the model before each experiment.
verbose (bool, default True) – Whether to show a progress bar.
nthreads (int, default 1) – Number of threads. With more than one, experiments run in parallel on copies of the model, so
funmust not rely on shared state.
- seed(self: epiworldpy._core.Model, s: SupportsInt | SupportsIndex) None#
Seed the model’s random number generator.
- Parameters:
s (int) – Seed.
- set_name(self: epiworldpy._core.Model, name: str) None#
Set the name of the model.
- Parameters:
name (str) – New name.
- set_param(self: epiworldpy._core.Model, pname: str, val: SupportsFloat | SupportsIndex) None#
Set the value of a named parameter.
- Parameters:
pname (str) – Name of the parameter.
val (float) – New value.
- set_rewire_prop(self: epiworldpy._core.Model, prop: SupportsFloat | SupportsIndex) None#
Set the proportion of ties rewired at each step.
Only used if the model has a rewiring function.
- Parameters:
prop (float) – Proportion between 0 and 1.
- set_state_function(*args, **kwargs)#
Overloaded function.
set_state_function(self: epiworldpy._core.Model, state: typing.SupportsInt | typing.SupportsIndex, fun: epiworldpy._core.NativeUpdateFun) -> epiworldpy._core.Model
Replace a state’s update function with a built-in epiworld function.
- Parameters:
state (int) – Index of the state.
fun (NativeUpdateFun) – New update function, from
UpdateFun.susceptible()orUpdateFun.rate().
- Returns:
The model itself.
- Return type:
set_state_function(self: epiworldpy._core.Model, name: str, fun: epiworldpy._core.NativeUpdateFun) -> epiworldpy._core.Model
Replace a state’s update function with a built-in epiworld function.
- Parameters:
name (str) – Label of the state.
fun (NativeUpdateFun) – New update function, from
UpdateFun.susceptible()orUpdateFun.rate().
- Returns:
The model itself.
- Return type:
set_state_function(self: epiworldpy._core.Model, state: typing.SupportsInt | typing.SupportsIndex, fun: collections.abc.Callable[[epiworldpy._core.Agent, epiworldpy._core.Model], None]) -> epiworldpy._core.Model
Replace a state’s update function.
- Parameters:
state (int) – Index of the state.
fun (callable or None) – New update function
fun(agent, model) -> None, orNoneto remove it.
- Returns:
The model itself.
- Return type:
set_state_function(self: epiworldpy._core.Model, name: str, fun: collections.abc.Callable[[epiworldpy._core.Agent, epiworldpy._core.Model], None]) -> epiworldpy._core.Model
Replace a state’s update function.
- Parameters:
name (str) – Label of the state.
fun (callable or None) – New update function
fun(agent, model) -> None, orNoneto remove it.
- Returns:
The model itself.
- Return type:
- set_transmission_mode(self: epiworldpy._core.Model, mode: str, kappa: SupportsFloat | SupportsIndex = 0.5) epiworldpy._core.Model#
Set how network transmission is computed.
In a pull step, each susceptible agent looks at its infected neighbors; in a push step, each infected agent adds its infection odds to its susceptible neighbors. Both give the same distribution of infections and differ only in speed and in the random numbers drawn. Directed networks always pull.
- Parameters:
mode ({"auto", "push", "pull"}) –
"auto"(the default) chooses each day from the cost of each step: it pushes whenD_c + 4 N_c <= kappa (D_s + 4 N_s), whereDis the sum of degrees andNthe number of agents, over the infected agents that can transmit (c) and the susceptible ones (s), and pulls otherwise."pull"reproduces the random streams of epiworld 0.15 and earlier.kappa (float, default 0.5) – Threshold used by
"auto"; a finite, non-negative number. Smaller values pull more often.
- Returns:
The model itself.
- Return type:
- size(self: epiworldpy._core.Model) int#
Get the number of agents.
- Returns:
Population size.
- Return type:
int
- state_of(self: epiworldpy._core.Model, name: str) int#
Get the index of a state from its label.
- Parameters:
name (str) – Label of the state.
- Returns:
Index of the state.
- Return type:
int
- Raises:
RuntimeError – If the model has no state with that label.
- today(self: epiworldpy._core.Model) int#
Get the current simulation day.
- Returns:
Current day (step), starting at 0.
- Return type:
int
- verbose_off(self: epiworldpy._core.Model) epiworldpy._core.Model#
Turn off verbose output.
- Returns:
The model itself.
- Return type:
- verbose_on(self: epiworldpy._core.Model) epiworldpy._core.Model#
Turn on verbose output (progress bars and messages).
- Returns:
The model itself.
- Return type:
- write_data(self: epiworldpy._core.Model, fn_virus_info: str = '', fn_virus_hist: str = '', fn_tool_info: str = '', fn_tool_hist: str = '', fn_total_hist: str = '', fn_transmission: str = '', fn_transition: str = '', fn_reproductive_number: str = '', fn_generation_time: str = '', fn_active_cases: str = '', fn_outbreak_size: str = '', fn_hospitalizations: str = '') None#
Write the results of the last run to files.
Each argument is the path of a file to write; files with an empty path are skipped.
- Parameters:
fn_virus_info (str, default "") – Information about each virus.
fn_virus_hist (str, default "") – History of each virus (see
DataBase.get_hist_virus()).fn_tool_info (str, default "") – Information about each tool.
fn_tool_hist (str, default "") – History of each tool (see
DataBase.get_hist_tool()).fn_total_hist (str, default "") – Totals per state and day (see
DataBase.get_hist_total()).fn_transmission (str, default "") – Transmission events (see
DataBase.get_transmissions()).fn_transition (str, default "") – Transition counts (see
DataBase.get_hist_transition_matrix()).fn_reproductive_number (str, default "") – Reproductive numbers (see
DataBase.get_reproductive_number()).fn_generation_time (str, default "") – Generation times (see
DataBase.get_generation_time()).fn_active_cases (str, default "") – Active cases (see
DataBase.get_active_cases()).fn_outbreak_size (str, default "") – Outbreak sizes (see
DataBase.get_outbreak_size()).fn_hospitalizations (str, default "") – Hospitalizations (see
DataBase.get_hospitalizations()).
- write_edgelist(self: epiworldpy._core.Model, fn: str) None#
Write the network to a file as an edge list.
- Parameters:
fn (str) – Path of the output file.