Always return minimum point, not current center
This commit is contained in:
parent
fda8bb5a5d
commit
3510ac1f63
1 changed files with 8 additions and 1 deletions
|
@ -44,6 +44,9 @@ def min_search(
|
||||||
x_center = x0
|
x_center = x0
|
||||||
y_min = function(x_center) if include_center else float("inf")
|
y_min = function(x_center) if include_center else float("inf")
|
||||||
|
|
||||||
|
best_x = x_center
|
||||||
|
best_y = y_min
|
||||||
|
|
||||||
for _ in range(iterations):
|
for _ in range(iterations):
|
||||||
for point in generate_bounded_points(x_center, neighbors_count, std_dev, function.definition_interval, rng):
|
for point in generate_bounded_points(x_center, neighbors_count, std_dev, function.definition_interval, rng):
|
||||||
y_point = function(point)
|
y_point = function(point)
|
||||||
|
@ -51,9 +54,13 @@ def min_search(
|
||||||
y_min = y_point
|
y_min = y_point
|
||||||
x_center = 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
|
# If we're using Stochastic Hill Climber, reset the minimum value, to only
|
||||||
# pick it from the newly generated points, not the current center
|
# pick it from the newly generated points, not the current center
|
||||||
if not include_center:
|
if not include_center:
|
||||||
y_min = float("inf")
|
y_min = float("inf")
|
||||||
|
|
||||||
yield x_center
|
yield best_x
|
||||||
|
|
Loading…
Add table
Reference in a new issue