diff --git a/lab2/HookJeeves.py b/lab2/HookJeeves.py index bd3a447..7863f0e 100644 --- a/lab2/HookJeeves.py +++ b/lab2/HookJeeves.py @@ -137,19 +137,23 @@ def sample_search( x2_last = x2.copy() x2_last_err = x2_err.copy() + error_growth_coeff = 0.05 # КОЭФФИЦИЕНТ РОСТА ОШИБКИ + while fit(f(x2), f(x1)): x2_last = x2.copy() x2_last_err = x2_err.copy() - if not r(x2 + (x2 - x1)): + step = x2 - x1 + if not r(x2 + step): log("Ограничение ОДЗ") break - x2, x1 = x2 + (x2 - x1), x2 + x2, x1 = x2 + step, x2 - t_err = x2_err.copy() - x2_err = x2_err + (x2_err + x1_err) - x1_err = t_err.copy() + # Новая погрешность + step_error = error_growth_coeff * np.abs(step) + x2_err = x2_err + step_error + x1_err = x2_err.copy() log("Найдена точка", x2_last, f(x2_last)) return x2_last, x2_last_err @@ -177,7 +181,7 @@ def example(): > - ищем максимум < - ищем минимум """ - return a > b + return a < b def r(x): """