epymorph.simulator.world_list
World implementation: ListWorld.
Cohort
Represents a group of individuals, divided into IPM compartments as appropriate for the simulation. These individuals share the same "home location" and a time at which they should return there.
These are somewhat abstract concepts, however; a completely nomadic group doesn't really have a home location, merely the next location in a chain of movements.
SORT_KEY
class-attribute
instance-attribute
SORT_KEY = attrgetter('return_tick', 'return_location')
The natural sort order of a Cohort.
merge_from
merge_from(from_cohort: Self) -> None
Merges another cohort into this one, modifying in-place.
ListWorld
Bases: World
A world model which tracks state with lists: the world is a list of locations, and each location is a list of cohorts.
HOME_TICK
class-attribute
instance-attribute
The value of a population's return_tick
when the population is home.
from_initials
classmethod
Create a world with the given initial compartments: assumes everyone starts at home, no travelers initially. initial_compartments is an (N,C) array.
normalize
Sorts all cohorts within each location and combines mergeable cohorts (in place). The world should be normalized after any modification.
get_cohorts
Iterate over the cohorts present in a single location.
get_cohort_array
Retrieve an (X,C) array containing all cohorts at a single location, where X is the number of cohorts.
get_local_array
Get the local populations of each node as an (N,C) array. This is the individuals which are theoretically eligible for movement.
get_local_cohorts
Iterate over all locations returning just the local cohort from each.
apply_cohort_delta
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
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
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.