UpdateFun#
- class epiworldpy.UpdateFun#
Bases:
pybind11_objectFactories for state update functions.
An update function is called on each agent in a state at every step and decides whether the agent moves to another state. Pass the functions returned here to
Model.add_state()orModel.set_state_function().Methods
Get an empty update function: agents in the state never change on their own.
Get epiworld's default update function for infected agents.
Get epiworld's default update function for susceptible agents.
Get a native update function that moves agents at fixed daily rates.
Get a native update function for susceptible agents.
- static default() collections.abc.Callable[[epiworldpy._core.Agent, epiworldpy._core.Model], None]#
Get an empty update function: agents in the state never change on their own.
- Returns:
None, whichModel.add_state()treats as no update function.- Return type:
None
- static default_update_exposed() collections.abc.Callable[[epiworldpy._core.Agent, epiworldpy._core.Model], None]#
Get epiworld’s default update function for infected agents.
Each infected agent can recover or die, with the probabilities set by its virus and tools.
- Returns:
The update function.
- Return type:
callable
- static default_update_susceptible() collections.abc.Callable[[epiworldpy._core.Agent, epiworldpy._core.Model], None]#
Get epiworld’s default update function for susceptible agents.
Each susceptible agent can be infected by the viruses of its neighbors, with probabilities that account for the viruses and the agents’ tools.
- Returns:
The update function.
- Return type:
callable
- static rate(param_names: collections.abc.Sequence[str], target_states: collections.abc.Sequence[SupportsInt | SupportsIndex]) epiworldpy._core.NativeUpdateFun#
Get a native update function that moves agents at fixed daily rates.
Each day, an agent moves to
target_states[i]with the probability given by the model parameterparam_names[i]. With several targets, at most one transition happens per day.- Parameters:
param_names (list of str) – Names of the model parameters holding the daily probabilities.
target_states (list of int) – Index of the state each probability leads to, of the same length as
param_names.
- Returns:
The update function.
- Return type:
- static susceptible(exclude: collections.abc.Sequence[SupportsInt | SupportsIndex] = []) epiworldpy._core.NativeUpdateFun#
Get a native update function for susceptible agents.
Each susceptible agent can be infected by the viruses of its neighbors, except neighbors in the states listed in
exclude. Likedefault_update_susceptible(), the model may push infections from the infected agents instead when that is cheaper (seeModel.set_transmission_mode()).- Parameters:
exclude (list of int, default []) – States whose agents cannot infect others (for example, latent or hospitalized).
- Returns:
The update function.
- Return type: