utils
- utils.create_dir_for_scenario(generation_name: str, scenario_name: str)
Creates directory to store scenario record files
- Parameters
generation_name (str) – name of the generation
scenario_name (str) – name of the scenario
- utils.find_all_files_by_wildcard(base_dir: str, file_name: str, recursive=False) List[str]
Recursively find all files in a given directory based on filename
- Parameters
base_dir (str) – the root of the directory to be searched
filename (str) – filename (wildcard) to be matched
- Returns
all files found
- Return type
List[str]
- utils.get_current_timestamp() float
Retrieve the current timestamp
- Returns
timestamp
- Return type
float
- utils.get_logger(name, filename=None, log_to_file=False) logging.Logger
Gets logger from logging module
- Parameters
filename (str) – filename of the log records
log_to_file (bool) – flag to determine logging to file
- Returns
Logger object
- Return type
Logger
- utils.get_scenario_logger() logging.Logger
Gets logger that always logs on the same line
- Returns
Logger object
- Return type
Logger
- utils.random_numeric_id(length=5) List[int]
Generates a list of random integer ids
- Parameters
length (int) – expected length of the ID
- Returns
list of integer ids
- Return type
List[int]
- utils.remove_record_files(generation_name: str, scenario_name: str)
Remove record files for the specified generation and scenario name
- Parameters
generation_name (str) – name of the generation
scenario_name (str) – name of the scenario
- utils.save_record_files_and_chromosome(generation_name: str, scenario_name: str, ch: dict)
Save the record file and the genetic representation
- Parameters
generation_name (str) – name of the generation
scenario_name (str) – name of the scenario
ch (dict) – the genetic representation