Skip to content

Commit

Permalink
refactor(search_methods): update ASHA uniqueness
Browse files Browse the repository at this point in the history
  • Loading branch information
simonprovost committed Dec 9, 2023
1 parent 896c61b commit bdbd54a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion gama/search_methods/asha.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def asha(
maximum_resource: Union[int, float] = 1.0,
minimum_early_stopping_rate: int = 0,
max_full_evaluations: Optional[int] = None,
max_attempts: int = 100000,
) -> List[Individual]:
"""Asynchronous Halving Algorithm by Li et al.
Expand All @@ -115,6 +116,9 @@ def asha(
max_full_evaluations: Optional[int] (default=None)
Maximum number of individuals to evaluate on the max rung (i.e. on all data).
If None, the algorithm will be run indefinitely.
max_attempts: int (default=100000)
Maximum number of attempts to generate a unique individual otherwise raise
an error.
Returns
-------
Expand Down Expand Up @@ -163,7 +167,18 @@ def get_job():

if start_candidates:
return start_candidates.pop(), minimum_early_stopping_rate
return operations.individual(), minimum_early_stopping_rate

attempts = 0
while (new_individual := operations.individual()) and operations.is_evaluated(
new_individual
):
if attempts >= max_attempts:
raise ValueError(
"Maximum attempts reached while trying to generate a"
"unique individual."
)
attempts += 1
return new_individual, minimum_early_stopping_rate

try:
with AsyncEvaluator() as async_:
Expand Down

0 comments on commit bdbd54a

Please sign in to comment.