Source code for pyEpiabm.intervention.place_closure

#
# Place closure Class
#

from pyEpiabm.intervention import AbstractIntervention


[docs] class PlaceClosure(AbstractIntervention): """Place closure intervention Close specific types of places based on the number of infectious persons in their microcells and reopen places after their closure period or after the end of the policy. Detailed description of the implementation can be found in github wiki: https://github.com/SABS-R3-Epidemiology/epiabm/wiki/Interventions. """
[docs] def __init__( self, closure_duration, closure_delay, case_microcell_threshold, population, **kwargs ): self.closure_duration = closure_duration self.closure_delay = closure_delay self.case_microcell_threshold = case_microcell_threshold self.name = 'place_closure' super(PlaceClosure, self).__init__(population=population, **kwargs)
[docs] def __call__(self, time): """Run place closure intervention. Parameters ---------- time : float Current simulation time """ for cell in self._population.cells: for microcell in cell.microcells: if (hasattr(microcell, 'closure_start_time')) and ( microcell.closure_start_time is not None): if time > microcell.closure_start_time + self.\ closure_duration: # Reopen places after their closure period microcell.closure_start_time = None else: if (microcell.count_infectious() >= self. case_microcell_threshold): microcell.closure_start_time = time + self.\ closure_delay
[docs] def turn_off(self): """Turn off intervention after intervention stops being active. """ for cell in self._population.cells: for microcell in cell.microcells: if (hasattr(microcell, 'closure_start_time')) and ( microcell.closure_start_time is not None): microcell.closure_start_time = None