@@ -325,11 +325,11 @@ class HealthSystem(Module):
325325
326326 # Mode Appt Constraints
327327 'mode_appt_constraints' : Parameter (
328- Types .INT , 'Integer code in `{0, 1, 2}` determining mode of constraints with regards to officer numbers '
329- 'and time - 0: no constraints, all HSI events run with no squeeze factor, 1: elastic constraints '
330- ', all HSI events run with squeeze factor, 2: hard constraints, only HSI events with no squeeze '
331- 'factor run. N.B. This parameter is over-ridden if an argument is provided '
332- ' to the module initialiser.' ,
328+ Types .INT , 'Integer code in `{1, 2}` determining mode of constraints with regards to officer numbers '
329+ 'and time - 1: elastic constraints, all HSI events run with squeeze factor, provided '
330+ 'officers required to deliver the HSI have capabilities > 0 '
331+ '2: hard constraints, only HSI events with no squeeze factor run. N.B. This parameter'
332+ 'is over-ridden if an argument is provided to the module initialiser.' ,
333333 ),
334334 'mode_appt_constraints_postSwitch' : Parameter (
335335 Types .INT , 'Mode considered after a mode switch in year_mode_switch.' ),
@@ -368,10 +368,10 @@ def __init__(
368368 """
369369 :param name: Name to use for module, defaults to module class name if ``None``.
370370 :param service_availability: A list of treatment IDs to allow.
371- :param mode_appt_constraints: Integer code in ``{0, 1, 2}`` determining mode of
372- constraints with regards to officer numbers and time - 0: no constraints,
373- all HSI events run with no squeeze factor, 1: elastic constraints, all HSI
374- events run with squeeze factor, 2: hard constraints, only HSI events with
371+ :param mode_appt_constraints: Integer code in ``{1, 2}`` determining mode of
372+ constraints with regards to officer numbers and time - 1: elastic constraints, all HSI
373+ events run with squeeze factor provided officers required have nonzero capabilities,
374+ 2: hard constraints, only HSI events with
375375 no squeeze factor run.
376376 :param cons_availability: If 'default' then use the availability specified in the ResourceFile; if 'none', then
377377 let no consumable be ever be available; if 'all', then all consumables are always available. When using 'all'
@@ -422,7 +422,7 @@ def __init__(
422422
423423 self .mode_appt_constraints = None # Will be the final determination of the `mode_appt_constraints'
424424 if mode_appt_constraints is not None :
425- assert mode_appt_constraints in {0 , 1 , 2 }
425+ assert mode_appt_constraints in {1 , 2 }
426426 self .arg_mode_appt_constraints = mode_appt_constraints
427427
428428 self .rng_for_hsi_queue = None # Will be a dedicated RNG for the purpose of randomising the queue
@@ -2020,12 +2020,12 @@ def on_end_of_year(self) -> None:
20202020 self ._write_hsi_event_counts_to_log_and_reset ()
20212021 self ._write_never_ran_hsi_event_counts_to_log_and_reset ()
20222022
2023- def run_individual_level_events_in_mode_0_or_1 (self ,
2023+ def run_individual_level_events_in_mode_1 (self ,
20242024 _list_of_individual_hsi_event_tuples :
20252025 List [HSIEventQueueItem ]) -> List :
20262026 """Run a list of individual level events. Returns: list of events that did not run (maybe an empty list)."""
20272027 _to_be_held_over = list ()
2028- assert self .mode_appt_constraints in ( 0 , 1 )
2028+ assert self .mode_appt_constraints == 1
20292029
20302030 if _list_of_individual_hsi_event_tuples :
20312031 # Examine total call on health officers time from the HSI events in the list:
@@ -2044,18 +2044,12 @@ def run_individual_level_events_in_mode_0_or_1(self,
20442044 self .running_total_footprint .update (footprint )
20452045
20462046 # Estimate Squeeze-Factors for today
2047- if self .mode_appt_constraints == 0 :
2048- # For Mode 0 (no Constraints), the squeeze factors are all zero.
2049- squeeze_factor_per_hsi_event = np .zeros (
2050- len (footprints_of_all_individual_level_hsi_event ))
2051- else :
2052- # For Other Modes, the squeeze factors must be computed
2053- squeeze_factor_per_hsi_event = self .get_squeeze_factors (
2054- footprints_per_event = footprints_of_all_individual_level_hsi_event ,
2055- total_footprint = self .running_total_footprint ,
2056- current_capabilities = self .capabilities_today ,
2057- compute_squeeze_factor_to_district_level = self .compute_squeeze_factor_to_district_level ,
2058- )
2047+ squeeze_factor_per_hsi_event = self .get_squeeze_factors (
2048+ footprints_per_event = footprints_of_all_individual_level_hsi_event ,
2049+ total_footprint = self .running_total_footprint ,
2050+ current_capabilities = self .capabilities_today ,
2051+ compute_squeeze_factor_to_district_level = self .compute_squeeze_factor_to_district_level ,
2052+ )
20592053
20602054 for ev_num , event in enumerate (_list_of_individual_hsi_event_tuples ):
20612055 _priority = event .priority
@@ -2065,7 +2059,6 @@ def run_individual_level_events_in_mode_0_or_1(self,
20652059 # store appt_footprint before running
20662060 _appt_footprint_before_running = event .EXPECTED_APPT_FOOTPRINT
20672061
2068- # Mode 0: All HSI Event run, with no squeeze
20692062 # Mode 1: All HSI Events run with squeeze provided latter is not inf
20702063 ok_to_run = True
20712064
@@ -2106,15 +2099,13 @@ def run_individual_level_events_in_mode_0_or_1(self,
21062099 self .running_total_footprint -= original_call
21072100 self .running_total_footprint += updated_call
21082101
2109- # Don't recompute for mode=0
2110- if self .mode_appt_constraints != 0 :
2111- squeeze_factor_per_hsi_event = self .get_squeeze_factors (
2112- footprints_per_event = footprints_of_all_individual_level_hsi_event ,
2113- total_footprint = self .running_total_footprint ,
2114- current_capabilities = self .capabilities_today ,
2115- compute_squeeze_factor_to_district_level = self .
2116- compute_squeeze_factor_to_district_level ,
2117- )
2102+ squeeze_factor_per_hsi_event = self .get_squeeze_factors (
2103+ footprints_per_event = footprints_of_all_individual_level_hsi_event ,
2104+ total_footprint = self .running_total_footprint ,
2105+ current_capabilities = self .capabilities_today ,
2106+ compute_squeeze_factor_to_district_level = self .
2107+ compute_squeeze_factor_to_district_level ,
2108+ )
21182109
21192110 else :
21202111 # no actual footprint is returned so take the expected initial declaration as the actual,
@@ -2277,7 +2268,7 @@ def _get_events_due_today(self) -> List:
22772268
22782269 return due_today
22792270
2280- def process_events_mode_0_and_1 (self , hold_over : List [HSIEventQueueItem ]) -> None :
2271+ def process_events_mode_1 (self , hold_over : List [HSIEventQueueItem ]) -> None :
22812272 while True :
22822273 # Get the events that are due today:
22832274 list_of_individual_hsi_event_tuples_due_today = self ._get_events_due_today ()
@@ -2296,7 +2287,7 @@ def process_events_mode_0_and_1(self, hold_over: List[HSIEventQueueItem]) -> Non
22962287 list_of_individual_hsi_event_tuples_due_today_that_have_essential_equipment .append (item )
22972288
22982289 # Try to run the list of individual-level events that have their essential equipment
2299- _to_be_held_over = self .module .run_individual_level_events_in_mode_0_or_1 (
2290+ _to_be_held_over = self .module .run_individual_level_events_in_mode_1 (
23002291 list_of_individual_hsi_event_tuples_due_today_that_have_essential_equipment ,
23012292 )
23022293 hold_over .extend (_to_be_held_over )
@@ -2494,9 +2485,9 @@ def process_events_mode_2(self, hold_over: List[HSIEventQueueItem]) -> None:
24942485 # were exhausted, so here we traverse the queue again to ensure that if any events expired were
24952486 # left unchecked they are properly removed from the queue, and did_not_run() is invoked for all
24962487 # postponed events. (This should still be more efficient than querying the queue as done in
2497- # mode_appt_constraints = 0 and 1 while ensuring mid-day effects are avoided.)
2488+ # mode_appt_constraints = 1 while ensuring mid-day effects are avoided.)
24982489 # We also schedule a call_never_run for any HSI below the lowest_priority_considered,
2499- # in case any of them where left in the queue due to a transition from mode 0/ 1 to mode 2
2490+ # in case any of them where left in the queue due to a transition from mode 1 to mode 2
25002491 while len (self .module .HSI_EVENT_QUEUE ) > 0 :
25012492
25022493 next_event_tuple = hp .heappop (self .module .HSI_EVENT_QUEUE )
@@ -2527,7 +2518,7 @@ def process_events_mode_2(self, hold_over: List[HSIEventQueueItem]) -> None:
25272518 elif self .sim .date < next_event_tuple .topen :
25282519 # The event is not yet due (before topen). Do not stop querying the queue here if we have
25292520 # reached the lowest_priority_considered, as we want to make sure HSIs with lower priority
2530- # (which may have been scheduled during a prior mode 0/ 1 period) are flushed from the queue.
2521+ # (which may have been scheduled during a prior mode 1 period) are flushed from the queue.
25312522 hp .heappush (list_of_events_not_due_today , next_event_tuple )
25322523
25332524 else :
@@ -2603,11 +2594,11 @@ def apply(self, population):
26032594 # Create hold-over list. This will hold events that cannot occur today before they are added back to the queue.
26042595 hold_over = list ()
26052596
2606- if self .module .mode_appt_constraints in ( 0 , 1 ) :
2597+ if self .module .mode_appt_constraints == 1 :
26072598 # Run all events due today, repeating the check for due events until none are due
26082599 # (this allows for HSI that are added to the queue in the course of other HSI
26092600 # for this today to be run this day).
2610- self .process_events_mode_0_and_1 (hold_over )
2601+ self .process_events_mode_1 (hold_over )
26112602
26122603 elif self .module .mode_appt_constraints == 2 :
26132604 self .process_events_mode_2 (hold_over )
0 commit comments