automl / DEHB

https://automl.github.io/DEHB/
Apache License 2.0
72 stars 16 forks source link

Keep active brackets in a dictionary #35

Open Bronzila opened 1 year ago

Bronzila commented 1 year ago

Changing the list of active brackets to a dictionary with the bracket_id as keys would make the code on some occasions more readable. For example this:

# pass information of job submission to Bracket Manager
for bracket in self.active_brackets:
    if bracket.bracket_id == job_info['bracket_id']:
        # registering is IMPORTANT for Bracket Manager to perform SH
        bracket.register_job(job_info['budget'])
        break

Could then be rewritten as:

bracket_id = job_info['bracket_id']
self.active_brackets[bracket_id].register_job(job_info['budget'])

This would also have runtime advantages, however these are rather small, given that our active_brackets list is mostly small.

To clean up the dictionary we can then simlpy iterate over the key-value pairs and delete the brackets, that are already done.

eddiebergman commented 1 year ago

Efficient for performing operations on the ends of lists https://docs.python.org/3/library/collections.html#collections.deque

from collections import deque