Always return minimum point, not current center

This commit is contained in:
Peter Vacho 2025-03-16 21:10:19 +01:00
parent fda8bb5a5d
commit 3510ac1f63
Signed by: school
GPG key ID: 8CFC3837052871B4

View file

@ -44,6 +44,9 @@ def min_search(
x_center = x0
y_min = function(x_center) if include_center else float("inf")
best_x = x_center
best_y = y_min
for _ in range(iterations):
for point in generate_bounded_points(x_center, neighbors_count, std_dev, function.definition_interval, rng):
y_point = function(point)
@ -51,9 +54,13 @@ def min_search(
y_min = y_point
x_center = point
if y_min < best_y:
best_y = y_min
best_x = x_center
# If we're using Stochastic Hill Climber, reset the minimum value, to only
# pick it from the newly generated points, not the current center
if not include_center:
y_min = float("inf")
yield x_center
yield best_x