UpdateFun#

class epiworldpy.UpdateFun#

Bases: pybind11_object

Factories 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() or Model.set_state_function().

Methods

default

Get an empty update function: agents in the state never change on their own.

default_update_exposed

Get epiworld's default update function for infected agents.

default_update_susceptible

Get epiworld's default update function for susceptible agents.

rate

Get a native update function that moves agents at fixed daily rates.

susceptible

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, which Model.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 parameter param_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:

NativeUpdateFun

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. Like default_update_susceptible(), the model may push infections from the infected agents instead when that is cheaper (see Model.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:

NativeUpdateFun