Coverage for pybeepop/beepop/globaloptions.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-30 13:34 +0000

1"""BeePop+ Global Configuration Options Module. 

2 

3This module contains the GlobalOptions singleton class that manages simulation-wide 

4configuration parameters. These options control various aspects of colony behavior, 

5environmental responses, and computational algorithms throughout the simulation. 

6 

7Global options provide centralized control over model parameters such as aging 

8algorithms, foraging thresholds, weather processing methods, and output formatting. 

9This allows for consistent behavior across all simulation components and easy 

10parameter adjustment for sensitivity analysis or model calibration. 

11 

12The singleton pattern ensures all simulation components access the same configuration 

13state, preventing inconsistencies in model behavior across different subsystems. 

14 

15Classes: 

16 GlobalOptions: Singleton configuration manager for simulation-wide parameters 

17""" 

18 

19 

20class GlobalOptions: 

21 """Singleton configuration manager for simulation-wide behavioral parameters. 

22 

23 Manages global configuration options that control various aspects of the 

24 colony simulation including aging algorithms, environmental thresholds, 

25 foraging behavior, and output formatting. Provides centralized parameter 

26 control for consistent model behavior. 

27 

28 Global options influence how bees respond to environmental conditions, when 

29 aging algorithms are applied, how weather data is processed, and what 

30 outputs are generated. These parameters allow for model calibration and 

31 sensitivity analysis across different scenarios. 

32 

33 Attributes: 

34 daylight_hours_threshold (float): Minimum daylight hours for egg laying 

35 should_adults_age_based_laid_eggs (bool): Whether adult aging depends on egg laying 

36 should_forage_day_election_based_on_temperatures (bool): Temperature-based foraging 

37 windspeed_threshold (float): Maximum wind speed for foraging activity 

38 rainfall_threshold (float): Maximum rainfall for foraging activity 

39 should_compute_hourly_temperature_estimation (bool): Hourly temperature calculations 

40 should_foragers_always_age_based_on_forage_inc (bool): Forager aging algorithm 

41 adult_aging_delay_egg_threshold (float): Egg threshold for aging delays 

42 should_output_in_out_counts (bool): Whether to output detailed transition counts 

43 """ 

44 

45 # Singleton instance 

46 _instance = None 

47 

48 def __new__(cls): 

49 if cls._instance is None: 

50 cls._instance = super(GlobalOptions, cls).__new__(cls) 

51 cls._instance._initialize_defaults() 

52 return cls._instance 

53 

54 def _initialize_defaults(self): 

55 # Egg laying options 

56 self.daylight_hours_threshold = 9.5 

57 

58 # Adult aging options 

59 self.should_adults_age_based_laid_eggs = True 

60 

61 # Forager aging options 

62 self.should_forage_day_election_based_on_temperatures = False 

63 self.windspeed_threshold = 8.94 

64 self.rainfall_threshold = 0.197 

65 self.should_compute_hourly_temperature_estimation = True 

66 self.should_foragers_always_age_based_on_forage_inc = True 

67 self.adult_aging_delay_egg_threshold = 50.0 

68 

69 # Weather file options 

70 self.binary_weather_file_format_identifier = "" 

71 

72 # Additional Output Data 

73 self.should_output_in_out_counts = False 

74 

75 # Example: get the singleton instance 

76 @staticmethod 

77 def get(): 

78 return GlobalOptions() 

79 

80 

81# Usage: 

82# options = GlobalOptions.get() 

83# print(options.daylight_hours_threshold)