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
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-30 13:34 +0000
1"""BeePop+ Global Configuration Options Module.
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.
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.
12The singleton pattern ensures all simulation components access the same configuration
13state, preventing inconsistencies in model behavior across different subsystems.
15Classes:
16 GlobalOptions: Singleton configuration manager for simulation-wide parameters
17"""
20class GlobalOptions:
21 """Singleton configuration manager for simulation-wide behavioral parameters.
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.
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.
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 """
45 # Singleton instance
46 _instance = None
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
54 def _initialize_defaults(self):
55 # Egg laying options
56 self.daylight_hours_threshold = 9.5
58 # Adult aging options
59 self.should_adults_age_based_laid_eggs = True
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
69 # Weather file options
70 self.binary_weather_file_format_identifier = ""
72 # Additional Output Data
73 self.should_output_in_out_counts = False
75 # Example: get the singleton instance
76 @staticmethod
77 def get():
78 return GlobalOptions()
81# Usage:
82# options = GlobalOptions.get()
83# print(options.daylight_hours_threshold)