Skip to content

Commit 7d9a428

Browse files
committed
FIXED GA: Tiebreaker Issue, by adding a default value to the next() call so it returns float('inf') instead of raising a StopIeration exception when no match is found from history.
1 parent f086908 commit 7d9a428

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

search/genetic_algorithm.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,10 @@ def evaluate_population(trial_id, params, eval_cache, evaluate_fn, metric_key, v
349349
print(f" -> Current params: {params}")
350350
# Keep the search with less duration
351351
existing_duration = next(
352-
item["duration_sec"]
352+
(item["duration_sec"]
353353
for item in history
354-
if item["params"] == best_params
354+
if item["params"] == best_params),
355+
float('inf') # Default to infinity if not found
355356
)
356357
if duration < existing_duration:
357358
best_score = score

0 commit comments

Comments
 (0)