epymorph.movement_model
The basis of the movement system in epymorph.
Movement models are responsible for dividing up the day into one or more parts, in accordance with their desired tempo of movement. For example, commuting patterns of work day versus night.
Movement mechanics are expressed as a set of clauses which calculate the "requested" number of individuals that should move between geospatial nodes at a particular time step of the simulation. This is "requested" movement because fewer individuals may wind up moving if there are not enough to satisfy the request.
DayOfWeek
module-attribute
DayOfWeek = Literal['M', 'T', 'W', 'Th', 'F', 'Sa', 'Su']
Type for days of the week values.
ALL_DAYS
module-attribute
All days of the week values.
MovementPredicate
Bases: ABC
Checks the current tick and responds with true or false. Movement predicates are used to determine whether a movement clause should be applied for this simulation tick or not.
EveryDay
Bases: MovementPredicate
Return true for every day.
DayIs
MovementClauseClass
Bases: SimulationFunctionClass
The metaclass for MovementClause
classes; enforces proper implementation.
MovementClause
Bases: SimulationTickFunction[NDArray[SimDType]]
, ABC
A movement clause is basically a function which calculates how many individuals should move between all of the geo nodes.
It's up to epymorph's internal mechanisms to decide by random draw which individuals move (as identified by their disease status, or IPM compartment).
The clause also has various settings which determine when the clause is active (for example, only move people Monday-Friday at the start of the day) and when the individuals that were moved by the clause should return home (for example, stay for two days and then return at the end of the day).
is_active
evaluate
abstractmethod
Implement this method to provide logic for the clause. Use self methods and properties to access the simulation context or defer processing to another function.
Parameters:
-
tick
(Tick
) –The simulation tick being evaluated.
Returns:
MovementModelClass
MovementModel
Bases: ABC
A MovementModel
(MM) describes a pattern of geospatial movement for
individuals in the model.
The MM defines the tau steps which chop the day up into one or more parts, as well as the set of movement clauses which may apply throughout each day.
To create a custom MM, you will write an implementation of this class and of any required clause classes.
clauses
instance-attribute
clauses: Sequence[MovementClause]
The movement clauses that make up the model.
requirements
property
requirements: Sequence[AttributeDef]
The combined requirements of all of the clauses in this model.
parse_days_of_week
Parses a list of days of the week using our standard abbreviations: M, T, W, Th, F, Sa, Su.
Parameters:
-
dow
(str
) –A string containing a list of days of the week. The parser is pretty permissive; it ignores invalid parts of the input while keeping the valid parts. Any separator is allowed between the day of the week themselves.
Returns:
Examples: