epymorph.event
epymorph's event frameworks. The idea is to have a set of classes which define event protocols for logical components of epymorph.
OnStart
Bases: NamedTuple
The payload of a simulation on_start event.
OnTick
Bases: NamedTuple
The payload of a Simulation tick event.
OnMovementStart
Bases: NamedTuple
The payload for the event when movement processing starts for a tick.
OnMovementClause
Bases: NamedTuple
The payload for the event when a single movement clause has been processed.
requested
instance-attribute
The number of individuals this clause 'wants' to move, that is, the values returned by its clause function. (An NxN array.)
actual
instance-attribute
The actual number of individuals moved, by source, destination, and compartment. (An NxNxC array.)
is_throttled
instance-attribute
is_throttled: bool
Did the clause request to move more people than were available (at any location)?
OnMovementFinish
Bases: NamedTuple
The payload for the event when movement processing finishes for one simulation tick.
DownloadActivity
Bases: NamedTuple
A description of ADRIO network download activity.
All fields are optional, as it may be possible to measure some but not others
depending on the data source. ADRIOs should avoid reporting DownloadActivity
where all fields are None, and should instead just report None for
AdrioProgress.download
ADRIOProgress
Bases: NamedTuple
The payload of AdrioEvents.on_adrio_progress
Perhaps not all ADRIOs will report progress, but those that do
should emit one event when they start (with ratio_complete
== 0)
and one when they finish (with ratio_complete
== 1). They are free
to report as many intermediate progress events as they like.
ratio_complete
instance-attribute
ratio_complete: float
What ratio complete is it? (0: just started; 1: done)
download
instance-attribute
download: DownloadActivity | None
Download activity if any, and if it can be measured.
duration
instance-attribute
duration: float | None
If complete, how long did the ADRIO take overall (in seconds)?
EventBus
The one-stop for epymorph events. This class uses the singleton pattern.
on_start
instance-attribute
Event fires at the start of a simulation run.
on_tick
instance-attribute
Event fires after each tick has been processed.
on_finish
instance-attribute
Event fires after a simulation run is complete.
on_movement_start
instance-attribute
on_movement_start: Event[OnMovementStart] = Event()
Event fires at the start of the movement processing phase for every simulation tick.
on_movement_clause
instance-attribute
on_movement_clause: Event[OnMovementClause] = Event()
Event fires after processing each active movement clause.
on_movement_finish
instance-attribute
on_movement_finish: Event[OnMovementFinish] = Event()
Event fires at the end of the movement processing phase for every simulation tick.
on_adrio_progress
instance-attribute
on_adrio_progress: Event[ADRIOProgress] = Event()
Event fires when an ADRIO is fetching data.