Skip to content

Commit 2246b5f

Browse files
committed
black format
1 parent eb1421b commit 2246b5f

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

examples/function_minimization/evaluator.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,29 @@ def run_with_timeout(func, args=(), kwargs={}, timeout_seconds=5):
2222
Returns:
2323
Result of the function or raises TimeoutError
2424
"""
25+
2526
def wrapper(queue, func, args, kwargs):
2627
try:
2728
result = func(*args, **kwargs)
28-
queue.put(('success', result))
29+
queue.put(("success", result))
2930
except Exception as e:
30-
queue.put(('error', e))
31-
31+
queue.put(("error", e))
32+
3233
queue = multiprocessing.Queue()
3334
process = multiprocessing.Process(target=wrapper, args=(queue, func, args, kwargs))
3435
process.start()
3536
process.join(timeout=timeout_seconds)
36-
37+
3738
if process.is_alive():
3839
process.terminate()
3940
process.join()
4041
raise TimeoutError(f"Function timed out after {timeout_seconds} seconds")
41-
42+
4243
if queue.empty():
4344
raise TimeoutError("Function ended without returning a result")
44-
45+
4546
status, result = queue.get()
46-
if status == 'error':
47+
if status == "error":
4748
raise result
4849
return result
4950

@@ -197,7 +198,11 @@ def evaluate(program_path):
197198
# Value and distance scores (quality of solution) get 90% of the weight
198199
# Speed and reliability get only 10% combined
199200
combined_score = float(
200-
0.35 * value_score + 0.35 * distance_score + standard_deviation_score * 0.20 + 0.05 * speed_score + 0.05 * reliability_score
201+
0.35 * value_score
202+
+ 0.35 * distance_score
203+
+ standard_deviation_score * 0.20
204+
+ 0.05 * speed_score
205+
+ 0.05 * reliability_score
201206
)
202207

203208
# Also compute an "overall" score that will be the primary metric for selection

0 commit comments

Comments
 (0)