Skip to content

epymorph.simulator.world

The World represents the simulation state at a given point in time. World implementations keep track of how many locations are being simulated, and the compartmental breakdown of individuals in each of those locations. They also keep track of groups of individuals which have moved between locations and will eventually be returning or moving to another location.

Cohort

Bases: Protocol

compartments instance-attribute

compartments: NDArray[SimDType]

return_location instance-attribute

return_location: int

return_tick instance-attribute

return_tick: int

World

Bases: ABC

An abstract world model.

get_cohorts abstractmethod

get_cohorts(location_idx: int) -> Sequence[Cohort]

Iterate over the cohorts present in a single location.

get_cohort_array abstractmethod

get_cohort_array(location_idx: int) -> NDArray[SimDType]

Retrieve an (X,C) array containing all cohorts at a single location, where X is the number of cohorts.

get_local_array abstractmethod

get_local_array() -> NDArray[SimDType]

Get the local populations of each node as an (N,C) array. This is the individuals which are theoretically eligible for movement.

apply_cohort_delta abstractmethod

apply_cohort_delta(
    location_idx: int, delta: NDArray[SimDType]
) -> None

Apply the disease delta for all cohorts at the given location. delta is an (X,C) array where X is the number of cohorts.

apply_travel abstractmethod

apply_travel(
    travelers: NDArray[SimDType], return_tick: int
) -> None

Given an (N,N,C) array determining who should travel -- from-source-to-destination-by-compartment -- modify the world state as a result of that movement.

apply_return abstractmethod

apply_return(
    tick: Tick, *, return_stats: bool
) -> NDArray[SimDType] | None

Modify the world state as a result of returning all movers that are ready to be returned home. If return_stats is True, returns an NxNxC array containing the individuals moved during the return. Otherwise returns None.