tlo.events module
Support for creating different kinds of events.
- class Priority(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enumeration for the Priority, which is used in sorting the events in the simulation queue.
- START_OF_DAY = 0
- FIRST_HALF_OF_DAY = 25
- LAST_HALF_OF_DAY = 75
- END_OF_DAY = 100
- class Event(module, *args, priority=Priority.FIRST_HALF_OF_DAY, **kwargs)[source]
Bases:
object
Base event class, from which all others inherit.
Concrete subclasses should also inherit from one of the EventMixin classes defined below, and implement at least an apply method.
- class RegularEvent(module, *, frequency, end_date=None, **kwargs)[source]
Bases:
Event
An event that automatically reschedules itself at a fixed frequency.
- class PopulationScopeEventMixin(*args, **kwargs)[source]
Bases:
object
Makes an event operate on the entire population.
This class is designed to be used via multiple inheritance along with one of the main event classes. It indicates that when an event happens, it is applied to the entire population, rather than a single individual. Contrast IndividualScopeEventMixin.
Subclasses should implement apply(self, population) to contain their behaviour.
- class IndividualScopeEventMixin(*args, person_id, **kwargs)[source]
Bases:
object
Makes an event operate on a single individual.
This class is designed to be used via multiple inheritance along with one of the main event classes. It indicates that when an event happens, it is applied to a single individual, rather than the entire population. Contrast PopulationScopeEventMixin.
Subclasses should implement apply(self, person) to contain their behaviour.